/* doc-gallery.css */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0f172a;
    color: #e2e8f0;
    min-height: 100vh;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-container {
    background: #1e293b;
    border-radius: 16px;
    border: 1px solid #334155;
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-container {
    transform: scale(1);
}

/* Header */
.modal-header {
    padding: 20px 24px;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border-bottom: 1px solid #334155;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #f8fafc;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-title::before {
    content: '📁';
    font-size: 1.5rem;
}

.modal-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 1.5rem;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #334155;
    color: #f8fafc;
}

/* Content */
.modal-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: #0f172a;
}

/* Gallery Grid */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
}

.gallery-item {
    position: relative;
    background: #1e293b;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid #334155;
    cursor: pointer;
    transition: all 0.2s ease;
    aspect-ratio: 3/4;
}

.gallery-item:hover {
    border-color: #38bdf8;
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(56, 189, 248, 0.3);
}

.gallery-item.invalid {
    border-color: #ef4444;
    opacity: 0.8;
}

.gallery-item.invalid::after {
    content: '⚠️';
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 1rem;
    background: rgba(239, 68, 68, 0.9);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-thumb {
    width: 100%;
    height: calc(100% - 40px);
    object-fit: cover;
    background: #0f172a;
}

.gallery-thumb.lazy {
    opacity: 0;
    transition: opacity 0.3s;
}

.gallery-thumb.loaded {
    opacity: 1;
}

.gallery-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px 12px;
    background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
    font-size: 0.75rem;
    color: #cbd5e1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gallery-status {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
}

.gallery-status.ativo { background: #22c55e; color: white; }
.gallery-status.substituido { background: #f59e0b; color: black; }
.gallery-status.revogado { background: #ef4444; color: white; }

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #64748b;
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* Footer */
.modal-footer {
    padding: 16px 24px;
    background: #1e293b;
    border-top: 1px solid #334155;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-primary {
    background: #38bdf8;
    color: #0f172a;
}

.btn-primary:hover {
    background: #0ea5e9;
}

.btn-secondary {
    background: #334155;
    color: #f1f5f9;
}

.btn-secondary:hover {
    background: #475569;
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

/* Lightbox */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1100;
    display: none;
    align-items: center;
    justify-content: center;
}

.lightbox.active {
    display: flex;
}

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.lightbox-img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 8px;
}

/* PDF Container */
.pdf-container {
    flex-direction: column;
    align-items: center;
    background: #1e293b;
    border-radius: 8px;
    padding: 20px;
    max-width: 90vw;
}

#pdfCanvas {
    max-width: 100%;
    max-height: 60vh;
    border-radius: 4px;
}

.pdf-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 16px;
    color: #f8fafc;
}

.pdf-controls button {
    background: #334155;
    border: none;
    color: #f8fafc;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
}

.pdf-controls button:hover {
    background: #475569;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid #334155;
    color: #f8fafc;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
}

.lightbox-nav:hover {
    background: #38bdf8;
    color: #0f172a;
}

.lightbox-prev { left: 20px; }
.lightbox-next { right: 20px; }

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid #334155;
    color: #f8fafc;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.lightbox-info {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    padding: 16px 24px;
    border-radius: 8px;
    text-align: center;
    min-width: 300px;
}

.lightbox-info h4 {
    color: #f8fafc;
    margin-bottom: 4px;
    font-size: 0.875rem;
}

.lightbox-info p {
    color: #94a3b8;
    font-size: 0.75rem;
}

.validation-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 8px;
    cursor: pointer;
}

.validation-badge.valid {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.validation-badge.invalid {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* Loading */
.gallery-skeleton {
    background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 12px;
    aspect-ratio: 3/4;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 16px 20px;
    border-radius: 8px;
    background: #1e293b;
    border: 1px solid #334155;
    color: #f8fafc;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    transform: translateX(120%);
    transition: transform 0.3s ease;
    z-index: 1200;
}

.toast.show {
    transform: translateX(0);
}

.toast.error {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.toast.success {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.1);
}

/* File Input */
.file-input {
    display: none;
}

/* Validation Modal */
.validation-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1300;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.validation-modal.active {
    display: flex;
}

.validation-content {
    background: #1e293b;
    border-radius: 16px;
    padding: 32px;
    max-width: 500px;
    width: 100%;
    text-align: center;
    border: 2px solid #ef4444;
}

.validation-content.valid {
    border-color: #22c55e;
}

.validation-icon {
    font-size: 4rem;
    margin-bottom: 16px;
}

.validation-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: #f8fafc;
}

.validation-details {
    background: #0f172a;
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0;
    text-align: left;
    font-family: monospace;
    font-size: 0.75rem;
    color: #94a3b8;
    word-break: break-all;
    max-height: 200px;
    overflow-y: auto;
}

.validation-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 24px;
}

/* Responsive */
@media (max-width: 640px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 12px;
    }
    
    .lightbox-nav {
        width: 36px;
        height: 36px;
        font-size: 1.25rem;
    }
    
    .lightbox-prev { left: 10px; }
    .lightbox-next { right: 10px; }
}
