/* NOM CertManager - Main Styles */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #0891b2;
  --sidebar-width: 260px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', system-ui, -apple-system, sans-serif; background: #f8fafc; color: #1e293b; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* Layout */
#app { display: flex; min-height: 100vh; }
#sidebar { width: var(--sidebar-width); min-height: 100vh; background: #1e293b; color: white; position: fixed; top: 0; left: 0; z-index: 40; display: flex; flex-direction: column; transition: transform 0.3s; }
#main-content { margin-left: var(--sidebar-width); flex: 1; min-height: 100vh; display: flex; flex-direction: column; }
#topbar { height: 60px; background: white; border-bottom: 1px solid #e2e8f0; display: flex; align-items: center; padding: 0 24px; position: sticky; top: 0; z-index: 30; }
#page-content { flex: 1; padding: 24px; }

/* Sidebar */
.sidebar-logo { padding: 20px 20px 16px; border-bottom: 1px solid #334155; }
.sidebar-logo-text { font-size: 18px; font-weight: 700; color: white; }
.sidebar-logo-sub { font-size: 11px; color: #94a3b8; margin-top: 2px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.nav-section { padding: 16px 16px 4px; font-size: 10px; font-weight: 600; color: #64748b; text-transform: uppercase; letter-spacing: 0.05em; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 16px; cursor: pointer; transition: all 0.15s; color: #94a3b8; font-size: 14px; font-weight: 500; text-decoration: none; border-left: 3px solid transparent; }
.nav-item:hover { background: #334155; color: white; }
.nav-item.active { background: #1d4ed8; color: white; border-left-color: #60a5fa; }
.nav-item i { width: 18px; text-align: center; font-size: 15px; }
.sidebar-footer { padding: 16px; border-top: 1px solid #334155; }
.user-info { display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: #3b82f6; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; }
.user-name { font-size: 13px; font-weight: 500; color: white; }
.user-role { font-size: 11px; color: #64748b; }

/* Topbar */
.topbar-title { font-size: 18px; font-weight: 600; color: #1e293b; flex: 1; }
.topbar-search { display: flex; align-items: center; gap: 8px; background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 8px; padding: 6px 12px; width: 300px; }
.topbar-search input { border: none; background: transparent; outline: none; font-size: 14px; width: 100%; }
.alert-badge { position: relative; }
.badge-dot { position: absolute; top: -2px; right: -2px; width: 10px; height: 10px; background: #ef4444; border-radius: 50%; border: 2px solid white; }

/* Status badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.badge-green { background: #dcfce7; color: #16a34a; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-orange { background: #ffedd5; color: #9a3412; }
.badge-red { background: #fee2e2; color: #dc2626; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-purple { background: #ede9fe; color: #7c3aed; }
.badge-cyan { background: #cffafe; color: #0e7490; }

/* Cards */
.card { background: white; border-radius: 12px; border: 1px solid #e2e8f0; padding: 20px; }
.card-sm { padding: 16px; }
.stat-card { background: white; border-radius: 12px; border: 1px solid #e2e8f0; padding: 20px; transition: box-shadow 0.2s; cursor: pointer; }
.stat-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.stat-value { font-size: 32px; font-weight: 700; color: #1e293b; }
.stat-label { font-size: 13px; color: #64748b; margin-top: 4px; }
.stat-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; }

/* Tables */
.table-container { background: white; border-radius: 12px; border: 1px solid #e2e8f0; overflow: hidden; }
.table-header { padding: 16px 20px; border-bottom: 1px solid #e2e8f0; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.table-header-title { font-size: 15px; font-weight: 600; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 10px 16px; text-align: left; font-size: 11px; font-weight: 600; color: #64748b; text-transform: uppercase; letter-spacing: 0.05em; background: #f8fafc; border-bottom: 1px solid #e2e8f0; }
td { padding: 12px 16px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
tr:hover td { background: #f8fafc; }
tr:last-child td { border-bottom: none; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; border: none; transition: all 0.15s; text-decoration: none; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.btn-secondary:hover { background: #e2e8f0; }
.btn-danger { background: #fee2e2; color: #dc2626; }
.btn-danger:hover { background: #fecaca; }
.btn-success { background: #dcfce7; color: #16a34a; }
.btn-success:hover { background: #bbf7d0; }
.btn-warning { background: #fef3c7; color: #d97706; }
.btn-warning:hover { background: #fde68a; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px; width: 32px; height: 32px; border-radius: 6px; justify-content: center; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: #374151; margin-bottom: 6px; }
.form-label.required::after { content: ' *'; color: #ef4444; }
.form-control { width: 100%; padding: 9px 12px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 14px; outline: none; transition: border-color 0.15s; background: white; }
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.form-control:disabled { background: #f9fafb; color: #6b7280; }
select.form-control { cursor: pointer; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.form-section { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.form-section-title { font-size: 14px; font-weight: 600; color: #374151; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: white; border-radius: 16px; max-width: 800px; width: 100%; max-height: 90vh; overflow-y: auto; }
.modal-lg { max-width: 1100px; }
.modal-sm { max-width: 480px; }
.modal-header { padding: 20px 24px 16px; border-bottom: 1px solid #e2e8f0; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: white; z-index: 1; }
.modal-title { font-size: 18px; font-weight: 600; }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid #e2e8f0; display: flex; justify-content: flex-end; gap: 10px; position: sticky; bottom: 0; background: white; }

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 2px solid #e2e8f0; margin-bottom: 20px; }
.tab { padding: 10px 16px; font-size: 14px; font-weight: 500; color: #64748b; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.15s; display: flex; align-items: center; gap: 6px; }
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-count { background: #e2e8f0; color: #64748b; padding: 1px 7px; border-radius: 20px; font-size: 11px; }
.tab.active .tab-count { background: #dbeafe; color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Alerts */
.alert-item { display: flex; gap: 12px; padding: 12px 16px; border-radius: 8px; margin-bottom: 8px; border: 1px solid; }
.alert-critical { background: #fff1f2; border-color: #fecdd3; }
.alert-error { background: #fff7ed; border-color: #fed7aa; }
.alert-warning { background: #fffbeb; border-color: #fde68a; }
.alert-info { background: #eff6ff; border-color: #bfdbfe; }
.alert-icon { font-size: 16px; margin-top: 2px; }

/* Semáforo de vigencia */
.semaforo { display: flex; align-items: center; gap: 6px; }
.semaforo-dot { width: 8px; height: 8px; border-radius: 50%; }
.semaforo-vigente .semaforo-dot { background: #22c55e; }
.semaforo-6m .semaforo-dot { background: #eab308; }
.semaforo-3m .semaforo-dot { background: #f97316; }
.semaforo-1m .semaforo-dot { background: #ef4444; }
.semaforo-vencido .semaforo-dot { background: #7f1d1d; }
.semaforo-vigente { color: #16a34a; font-size: 12px; font-weight: 500; }
.semaforo-6m { color: #854d0e; font-size: 12px; font-weight: 500; }
.semaforo-3m { color: #9a3412; font-size: 12px; font-weight: 500; }
.semaforo-1m { color: #dc2626; font-size: 12px; font-weight: 500; }
.semaforo-vencido { color: #7f1d1d; font-size: 12px; font-weight: 500; }

/* Progress bar */
.progress { height: 6px; background: #e2e8f0; border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 3px; transition: width 0.3s; }

/* File upload zone */
.drop-zone { border: 2px dashed #d1d5db; border-radius: 10px; padding: 32px; text-align: center; cursor: pointer; transition: all 0.2s; }
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--primary); background: #eff6ff; }
.drop-zone-icon { font-size: 32px; color: #94a3b8; margin-bottom: 8px; }

/* PDF Viewer */
.pdf-viewer { width: 100%; height: 600px; border: 1px solid #e2e8f0; border-radius: 8px; }

/* Toast notifications */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 16px; border-radius: 8px; color: white; font-size: 14px; min-width: 280px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); animation: slideIn 0.3s; display: flex; align-items: center; gap: 10px; }
.toast-success { background: #16a34a; }
.toast-error { background: #dc2626; }
.toast-warning { background: #d97706; }
.toast-info { background: #0891b2; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Loading */
.loading { display: flex; align-items: center; justify-content: center; padding: 40px; color: #94a3b8; gap: 10px; }
.spinner { width: 20px; height: 20px; border: 2px solid #e2e8f0; border-top-color: var(--primary); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Empty state */
.empty-state { text-align: center; padding: 60px 20px; color: #94a3b8; }
.empty-state i { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: #64748b; margin-bottom: 8px; }

/* Timeline */
.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ''; position: absolute; left: 8px; top: 0; bottom: 0; width: 2px; background: #e2e8f0; }
.timeline-item { position: relative; padding-bottom: 20px; }
.timeline-dot { position: absolute; left: -20px; top: 4px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid white; box-shadow: 0 0 0 2px #e2e8f0; }
.timeline-dot-green { background: #22c55e; box-shadow: 0 0 0 2px #dcfce7; }
.timeline-dot-blue { background: #3b82f6; box-shadow: 0 0 0 2px #dbeafe; }
.timeline-dot-orange { background: #f97316; box-shadow: 0 0 0 2px #ffedd5; }
.timeline-dot-red { background: #ef4444; box-shadow: 0 0 0 2px #fee2e2; }

/* Responsive */
@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); }
  #main-content { margin-left: 0; }
}

/* Login page */
.login-container { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1e3a5f 0%, #1e293b 100%); }
.login-card { background: white; border-radius: 16px; padding: 40px; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo-icon { font-size: 40px; color: var(--primary); }
.login-logo-text { font-size: 24px; font-weight: 700; color: #1e293b; margin-top: 8px; }
.login-logo-sub { font-size: 13px; color: #64748b; margin-top: 4px; }

/* Extraction modal */
.extraction-field { display: flex; align-items: flex-start; gap: 12px; padding: 10px; border-radius: 8px; margin-bottom: 8px; background: #f8fafc; border: 1px solid #e2e8f0; }
.extraction-field.found { background: #f0fdf4; border-color: #bbf7d0; }
.extraction-field.missing { background: #fafafa; border-color: #e2e8f0; opacity: 0.7; }
.extraction-status-icon { width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; flex-shrink: 0; margin-top: 8px; }
.extraction-status-icon.found { background: #dcfce7; color: #16a34a; }
.extraction-status-icon.missing { background: #f1f5f9; color: #94a3b8; }

/* Dashboard chart container */
.chart-container { position: relative; height: 200px; }

/* Highlight search term */
.highlight { background: #fef08a; border-radius: 2px; padding: 0 2px; }
