/* ── Fase 4: Reportes, Impresión, Configuración y UX ── */

/* ══ DARK MODE VARIABLES ══════════════════════════════════ */
body.dark-mode {
  --bg-main: #111827;
  --bg-sidebar: #1f2937;
  --bg-card: #1f2937;
  --bg-hover: #374151;
  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --border-color: #374151;
  background-color: var(--bg-main);
  color: var(--text-main);
}

body.dark-mode .sidebar { background: var(--bg-sidebar); border-right: 1px solid var(--border-color); }
body.dark-mode .topbar { background: var(--bg-sidebar); border-bottom: 1px solid var(--border-color); }
body.dark-mode .section-card, body.dark-mode .stat-card, body.dark-mode .ot-detail-section { 
  background: var(--bg-card); border-color: var(--border-color); color: var(--text-main);
}
body.dark-mode .stat-label, body.dark-mode .ot-info-label { color: var(--text-muted); }
body.dark-mode .ot-info-value { color: var(--text-main); }
body.dark-mode .crud-table th { background: var(--bg-sidebar); border-color: var(--border-color); color: var(--text-muted); }
body.dark-mode .crud-table td { border-color: var(--border-color); color: var(--text-main); }
body.dark-mode .crud-table tr:hover td { background: var(--bg-hover); }
body.dark-mode .table-filters input, body.dark-mode .table-filters select {
  background: var(--bg-main); color: var(--text-main); border-color: var(--border-color);
}
body.dark-mode .action-bar { background: var(--bg-hover); border-color: var(--border-color); }
body.dark-mode .tab-btn { color: var(--text-muted); }
body.dark-mode .tab-btn.active { color: #60a5fa; background: var(--bg-hover); border-bottom-color: #60a5fa; }
body.dark-mode .timeline::before { background: var(--border-color); }

/* Toggle Button */
.theme-toggle {
  background: none; border: none; cursor: pointer; color: #6b7280; font-size: 1.1rem; padding: 0.5rem; transition: color 0.2s;
}
.theme-toggle:hover { color: #2563eb; }
body.dark-mode .theme-toggle { color: #fcd34d; }

/* ══ SKELETON LOADERS ═════════════════════════════════════ */
.skeleton {
  background: #e5e7eb;
  background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: 0.25rem;
}
body.dark-mode .skeleton {
  background: #374151;
  background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
  background-size: 200% 100%;
}
@keyframes skeleton-loading { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.skeleton-text { height: 1rem; width: 100%; margin-bottom: 0.5rem; }
.skeleton-title { height: 1.5rem; width: 60%; margin-bottom: 1rem; }
.skeleton-avatar { width: 3rem; height: 3rem; border-radius: 50%; }

/* ══ EMPTY STATES ═════════════════════════════════════════ */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 4rem 2rem; text-align: center; color: #9ca3af;
}
.empty-state i { font-size: 4rem; color: #d1d5db; margin-bottom: 1rem; }
.empty-state h3 { font-size: 1.2rem; color: #374151; margin-bottom: 0.5rem; font-weight: 600; }
body.dark-mode .empty-state h3 { color: #d1d5db; }
body.dark-mode .empty-state i { color: #4b5563; }

/* ══ OFFLINE INDICATOR ════════════════════════════════════ */
.offline-banner {
  position: fixed; top: 0; left: 0; right: 0; background: #ef4444; color: white;
  text-align: center; padding: 0.5rem; font-weight: 600; font-size: 0.85rem;
  z-index: 10000; transform: translateY(-100%); transition: transform 0.3s;
}
.offline-banner.show { transform: translateY(0); }

/* ══ CHARTS CONTAINER ═════════════════════════════════════ */
.chart-container {
  position: relative; height: 300px; width: 100%;
}
.reports-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 1.5rem; margin-bottom: 2rem;
}

/* ══ IMPRESIÓN A6 (THERMAL/LASER) ═════════════════════════ */
.print-a6-container { display: none; }

@media print {
  body { background: #fff !important; margin: 0; padding: 0; color: #000 !important; font-family: monospace !important;}
  .sidebar, .topbar, .action-bar, #toastContainer, .mobile-header, .drawer-overlay, .main-content > div:not(.print-a6-container) { display: none !important; }
  
  .print-a6-container {
    display: block !important;
    width: 105mm; /* A6 width */
    height: 148mm; /* A6 height */
    padding: 5mm;
    margin: 0 auto;
    box-sizing: border-box;
    font-size: 10px;
    line-height: 1.3;
  }
  
  .a6-header { text-align: center; border-bottom: 1px dashed #000; padding-bottom: 5mm; margin-bottom: 5mm; }
  .a6-logo { width: 40mm; margin-bottom: 2mm; }
  .a6-title { font-size: 14px; font-weight: bold; margin-bottom: 2mm; }
  .a6-ot-num { font-size: 18px; font-weight: bold; }
  
  .a6-section { border-bottom: 1px dashed #000; padding-bottom: 5mm; margin-bottom: 5mm; }
  .a6-row { display: flex; justify-content: space-between; margin-bottom: 1mm; }
  .a6-label { font-weight: bold; }
  
  .a6-barcode { text-align: center; margin-top: 5mm; }
  .a6-barcode img { max-width: 100%; height: 15mm; }
  .a6-qr { text-align: center; margin-top: 5mm; }
  .a6-qr img { width: 25mm; height: 25mm; display: inline-block; }
  
  .a6-footer { text-align: center; font-size: 8px; margin-top: 5mm; }
  
}

/* ══ SEARCH MODAL (Ctrl+K) ════════════════════════════════ */
.search-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 9999;
  display: flex; align-items: flex-start; justify-content: center; padding-top: 10vh;
  opacity: 0; pointer-events: none; transition: opacity 0.2s; backdrop-filter: blur(2px);
}
.search-modal-overlay.open { opacity: 1; pointer-events: auto; }
.search-modal {
  background: var(--bg-card, #fff); width: 90%; max-width: 600px; border-radius: 0.75rem;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
  overflow: hidden; transform: translateY(-20px); transition: transform 0.2s;
}
.search-modal-overlay.open .search-modal { transform: translateY(0); }
.search-input-wrap {
  display: flex; align-items: center; padding: 1rem 1.5rem; border-bottom: 1px solid var(--border-color, #e5e7eb);
}
.search-input-wrap i { color: #9ca3af; font-size: 1.2rem; margin-right: 1rem; }
.search-input-wrap input {
  flex: 1; border: none; outline: none; font-size: 1.1rem; background: transparent; color: var(--text-main, #111827);
}
.search-results { max-height: 400px; overflow-y: auto; padding: 0.5rem; }
.search-result-item {
  display: flex; align-items: center; gap: 1rem; padding: 0.75rem 1rem; border-radius: 0.5rem;
  cursor: pointer; transition: background 0.15s; color: var(--text-main, #111827); text-decoration: none;
}
.search-result-item:hover, .search-result-item.active { background: var(--bg-hover, #f3f4f6); }

/* ══ MFA PREMIUM & RESPONSIVE ══════════════════════════════ */
#mfaScreen .auth-card {
  max-width: 400px;
  padding: 1.5rem 1.5rem; /* Compacto */
}

.mfa-enroll-box {
  background: #f8fafc;
  border-radius: 1rem;
  padding: 1rem;
  margin-bottom: 1rem;
  border: 1px solid #e2e8f0;
}

body.dark-mode .mfa-enroll-box {
  background: #1f2937;
  border-color: #374151;
}

.mfa-qr-wrap {
  background: #fff;
  padding: 0.75rem;
  border-radius: 0.75rem;
  margin: 0 auto 1.25rem;
  width: 150px; /* Tamaño reducido */
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

.mfa-manual-key {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #fff;
  padding: 0.6rem;
  border-radius: 0.5rem;
  border: 1px dashed #cbd5e1;
  margin-bottom: 1rem;
}

body.dark-mode .mfa-manual-key {
  background: #111827;
  border-color: #4b5563;
}

.key-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  white-space: nowrap;
}

.key-code {
  flex: 1;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: #1e293b;
  word-break: break-all;
}

body.dark-mode .key-code { color: #f1f5f9; }

.mfa-inputs {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin: 1.25rem 0;
}

.mfa-digit {
  width: 40px; /* Un poco más pequeños */
  height: 50px;
  text-align: center;
  font-size: 1.3rem;
  font-weight: 700;
  border: 2px solid #e2e8f0;
  border-radius: 0.6rem;
  background: #fff;
  transition: all 0.2s;
  color: var(--primary);
}

body.dark-mode .mfa-digit {
  background: #111827;
  border-color: #374151;
}

.mfa-digit:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37,99,235,0.1);
  outline: none;
}

.mfa-download-links {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.mfa-app-link {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  background: #000;
  color: #fff;
}

@media (max-width: 480px) {
  .mfa-inputs { gap: 0.35rem; }
  .mfa-digit { width: 38px; height: 50px; font-size: 1.25rem; }
  .mfa-enroll-box { padding: 1rem; }
  #mfaScreen .auth-card { padding: 2rem 1.25rem; }
}
