/* ======================================
   LINCE — Gestor Documental
   Design System & Styles
   ====================================== */

:root {
    /* Colors */
    --color-bg: #f5f6fa;
    --color-surface: #ffffff;
    --color-surface-hover: #f0f2f8;
    --color-border: #e4e7ef;
    --color-border-light: #f0f2f8;
    
    --color-primary: #4f46e5;
    --color-primary-light: #eef2ff;
    --color-primary-hover: #4338ca;
    
    --color-danger: #ef4444;
    --color-danger-light: #fef2f2;
    --color-danger-hover: #dc2626;
    
    --color-success: #10b981;
    --color-success-light: #ecfdf5;
    
    --color-warning: #f59e0b;
    --color-warning-light: #fffbeb;
    
    --color-text: #1e293b;
    --color-text-secondary: #64748b;
    --color-text-muted: #94a3b8;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.08);
    --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.12);
    
    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    
    /* Transitions */
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Sidebar */
    --sidebar-width: 260px;
}

/* ============= RESET ============= */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
}

/* ============= LAYOUT ============= */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ============= SIDEBAR ============= */
.sidebar {
    width: var(--sidebar-width);
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 24px 20px 16px;
    border-bottom: 1px solid var(--color-border-light);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.logo-icon {
    font-size: 28px;
}

.logo-text {
    font-size: 22px;
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.5px;
}

.logo-subtitle {
    font-size: 12px;
    color: var(--color-text-muted);
    font-weight: 500;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--color-surface-hover);
    color: var(--color-text);
}

.nav-item.active {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.nav-item .material-icons-round {
    font-size: 20px;
    opacity: 0.7;
}

.nav-item.active .material-icons-round {
    opacity: 1;
}

.nav-item .badge {
    margin-left: auto;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-muted);
    min-width: 22px;
    text-align: center;
}

.nav-item.active .badge {
    color: var(--color-primary);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--color-border-light);
}

.btn-upload {
    width: 100%;
    justify-content: center;
}

/* ============= MAIN CONTENT ============= */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

/* ============= TOPBAR ============= */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 32px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.3px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ============= SEARCH ============= */
.search-form {
    display: flex;
    align-items: center;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 0 14px;
    transition: all var(--transition);
}

.search-form:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.search-icon {
    color: var(--color-text-muted);
    font-size: 20px;
}

.search-input {
    border: none;
    outline: none;
    background: none;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    color: var(--color-text);
    width: 240px;
}

.search-input::placeholder {
    color: var(--color-text-muted);
}

/* ============= BUTTONS ============= */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--color-primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    background: var(--color-surface-hover);
    color: var(--color-text);
}

.btn-danger {
    background: var(--color-danger);
    color: #fff;
}

.btn-danger:hover {
    background: var(--color-danger-hover);
}

.btn-text {
    background: none;
    color: var(--color-primary);
    padding: 6px 12px;
}

.btn-text:hover {
    background: var(--color-primary-light);
}

.btn-lg {
    padding: 14px 28px;
    font-size: 15px;
    border-radius: var(--radius-lg);
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: none;
    background: none;
    cursor: pointer;
    color: var(--color-text-muted);
    transition: all var(--transition);
}

.btn-icon:hover {
    background: var(--color-surface-hover);
    color: var(--color-text);
}

.btn-icon-danger:hover {
    background: var(--color-danger-light);
    color: var(--color-danger);
}

.btn-icon .material-icons-round {
    font-size: 18px;
}

/* ============= ALERTS ============= */
.messages-container {
    padding: 16px 32px 0;
}

.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    animation: slideDown 0.3s ease;
}

.alert-success {
    background: var(--color-success-light);
    color: #065f46;
}

.alert-error {
    background: var(--color-danger-light);
    color: #991b1b;
}

.alert-close {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    opacity: 0.5;
    display: flex;
}

.alert-close:hover {
    opacity: 1;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============= PAGE CONTENT ============= */
.page-content {
    padding: 24px 32px;
}

/* ============= DOCUMENTS GRID ============= */
.documents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.doc-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition);
    position: relative;
}

.doc-card:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.doc-card-link {
    display: block;
}

.doc-card-preview {
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
    overflow: hidden;
}

.doc-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.doc-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 70px;
    height: 70px;
    border-radius: var(--radius-lg);
}

.doc-icon .material-icons-round {
    font-size: 32px;
}

.doc-icon-pdf {
    background: #fee2e2;
    color: #ef4444;
}

.doc-icon-audio {
    background: #e0e7ff;
    color: #6366f1;
}

.doc-icon-video {
    background: #fce7f3;
    color: #ec4899;
}

.doc-icon-other {
    background: #f0f9ff;
    color: #0ea5e9;
}

.doc-card-info {
    padding: 14px 16px 8px;
}

.doc-card-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 6px;
}

.doc-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.doc-type-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.doc-type-pdf { background: #fee2e2; color: #dc2626; }
.doc-type-imagen { background: #dcfce7; color: #16a34a; }
.doc-type-audio { background: #e0e7ff; color: #4f46e5; }
.doc-type-video { background: #fce7f3; color: #db2777; }
.doc-type-otro { background: #f0f9ff; color: #0284c7; }

.doc-size {
    font-size: 12px;
    color: var(--color-text-muted);
}

.doc-card-actions {
    display: flex;
    justify-content: flex-end;
    padding: 4px 10px 10px;
    gap: 2px;
    opacity: 0;
    transition: opacity var(--transition);
}

.doc-card:hover .doc-card-actions {
    opacity: 1;
}

/* ============= EMPTY STATE ============= */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 32px;
    text-align: center;
}

.empty-icon {
    font-size: 72px;
    color: var(--color-text-muted);
    opacity: 0.4;
    margin-bottom: 20px;
}

.empty-state h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--color-text-muted);
    margin-bottom: 24px;
}

/* ============= UPLOAD ============= */
.upload-container {
    max-width: 640px;
    margin: 0 auto;
}

.dropzone {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-xl);
    padding: 60px 40px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--color-surface);
}

.dropzone:hover,
.dropzone-active {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

.dropzone-icon {
    font-size: 56px;
    color: var(--color-primary);
    opacity: 0.6;
    margin-bottom: 16px;
    display: block;
}

.dropzone:hover .dropzone-icon,
.dropzone-active .dropzone-icon {
    opacity: 1;
    transform: translateY(-4px);
    transition: all var(--transition);
}

.dropzone-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

.dropzone-subtitle {
    color: var(--color-text-secondary);
    font-size: 14px;
}

.dropzone-hint {
    color: var(--color-text-muted);
    font-size: 12px;
    margin-top: 12px;
}

.dropzone-input {
    display: none;
}

/* File list */
.file-list {
    margin-top: 20px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.file-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--color-border-light);
}

.file-list-header h3 {
    font-size: 14px;
    font-weight: 600;
}

.file-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--color-border-light);
}

.file-list-item:last-child {
    border-bottom: none;
}

.file-list-icon {
    color: var(--color-primary);
    font-size: 22px;
}

.file-list-info {
    flex: 1;
    min-width: 0;
}

.file-list-name {
    font-size: 13px;
    font-weight: 500;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-list-size {
    font-size: 12px;
    color: var(--color-text-muted);
}

.upload-actions {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

/* ============= DETAIL ============= */
.detail-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 24px;
    align-items: start;
}

.detail-preview {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pdf-viewer {
    width: 100%;
    height: 80vh;
    border: none;
}

.image-viewer {
    width: 100%;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-viewer img {
    max-width: 100%;
    max-height: 80vh;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.audio-viewer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    padding: 48px;
    width: 100%;
}

.audio-icon {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
    display: flex;
    align-items: center;
    justify-content: center;
}

.audio-icon .material-icons-round {
    font-size: 44px;
    color: var(--color-primary);
}

.audio-player {
    width: 100%;
    max-width: 400px;
}

.video-viewer {
    width: 100%;
}

.video-player {
    width: 100%;
    max-height: 80vh;
}

.generic-viewer {
    text-align: center;
    padding: 60px;
}

.generic-icon {
    font-size: 72px;
    color: var(--color-text-muted);
    opacity: 0.4;
    margin-bottom: 16px;
}

.generic-viewer p {
    color: var(--color-text-muted);
    margin-bottom: 20px;
}

/* Info card */
.info-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.info-card h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-border-light);
}

.info-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.info-label {
    font-size: 13px;
    color: var(--color-text-muted);
    font-weight: 500;
}

.info-value {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text);
    text-align: right;
}

.status-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
}

.status-pendiente { background: var(--color-warning-light); color: #92400e; }
.status-procesando { background: #e0e7ff; color: #3730a3; }
.status-procesado { background: var(--color-success-light); color: #065f46; }
.status-error { background: var(--color-danger-light); color: #991b1b; }

.detail-actions {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ============= MODAL ============= */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    width: 420px;
    max-width: 90vw;
    box-shadow: var(--shadow-xl);
    animation: scaleIn 0.2s ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 0;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-body {
    padding: 20px 24px;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 0 24px 20px;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
    color: var(--color-text);
    background: var(--color-bg);
    outline: none;
    transition: all var(--transition);
}

.form-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.text-muted {
    color: var(--color-text-muted);
    font-size: 13px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* ============= RESPONSIVE ============= */
@media (max-width: 900px) {
    .sidebar {
        display: none;
    }
    .main-content {
        margin-left: 0;
    }
    .detail-layout {
        grid-template-columns: 1fr;
    }
    .documents-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
}
