/* ============================================================
   VigiaEC — Estilos
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #0f172a; color: #e2e8f0; min-height: 100vh; }

/* Layout */
.app-layout { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: #0f172a; border-right: 1px solid rgba(255,255,255,0.07); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; z-index: 100; transition: transform 0.3s; }
.sidebar-logo { padding: 20px 16px; border-bottom: 1px solid rgba(255,255,255,0.07); display: flex; align-items: center; gap: 12px; }
.sidebar-logo-icon { width: 42px; height: 42px; background: linear-gradient(135deg, #ef4444, #dc2626); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0; }
.main-content { margin-left: 240px; flex: 1; min-height: 100vh; background: #0f172a; }
.topbar { background: #0f172a; border-bottom: 1px solid rgba(255,255,255,0.07); padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50; }
.section-page { padding: 24px; max-width: 1200px; }

/* Nav */
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 16px; width: 100%; border: none; background: none; color: rgba(255,255,255,0.5); cursor: pointer; font-size: 0.88rem; font-weight: 600; border-radius: 10px; margin: 2px 8px; width: calc(100% - 16px); text-align: left; transition: all 0.15s; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: white; }
.nav-item.active { background: linear-gradient(135deg, rgba(239,68,68,0.2), rgba(220,38,38,0.1)); color: #ef4444; border: 1px solid rgba(239,68,68,0.2); }

/* Cards */
.card { background: #1e293b; border-radius: 16px; border: 1px solid rgba(255,255,255,0.06); }
.card-stat { background: #1e293b; border-radius: 14px; border: 1px solid rgba(255,255,255,0.06); padding: 20px; display: flex; align-items: center; gap: 14px; }

/* Botones */
.btn-primary { background: linear-gradient(135deg, #ef4444, #dc2626); color: white; border: none; border-radius: 10px; padding: 10px 18px; font-weight: 700; cursor: pointer; font-size: 0.88rem; display: inline-flex; align-items: center; gap: 8px; transition: all 0.2s; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(239,68,68,0.4); }
.btn-secondary { background: rgba(255,255,255,0.08); color: #e2e8f0; border: 1px solid rgba(255,255,255,0.1); border-radius: 10px; padding: 10px 18px; font-weight: 700; cursor: pointer; font-size: 0.88rem; display: inline-flex; align-items: center; gap: 8px; }
.btn-green { background: linear-gradient(135deg, #22c55e, #16a34a); color: white; border: none; border-radius: 10px; padding: 10px 18px; font-weight: 700; cursor: pointer; font-size: 0.88rem; display: inline-flex; align-items: center; gap: 8px; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-danger { background: rgba(239,68,68,0.15); color: #ef4444; border: 1px solid rgba(239,68,68,0.2); border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 0.82rem; font-weight: 700; }

/* Inputs */
.rf-input { width: 100%; padding: 10px 14px; background: rgba(255,255,255,0.05); border: 1.5px solid rgba(255,255,255,0.1); border-radius: 10px; color: #e2e8f0; font-size: 0.88rem; outline: none; transition: border-color 0.2s; }
.rf-input:focus { border-color: #ef4444; background: rgba(255,255,255,0.08); }
.rf-input option { background: #1e293b; color: #e2e8f0; }
.rf-label { font-size: 0.78rem; font-weight: 700; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.05em; display: block; margin-bottom: 6px; }
.rf-group { display: flex; flex-direction: column; }

/* Alertas nivel */
.nivel-rojo    { background: rgba(239,68,68,0.15);  color: #ef4444;  border: 1.5px solid rgba(239,68,68,0.3);  border-radius: 8px; padding: 3px 10px; font-size: 0.75rem; font-weight: 800; }
.nivel-naranja { background: rgba(249,115,22,0.15); color: #f97316; border: 1.5px solid rgba(249,115,22,0.3); border-radius: 8px; padding: 3px 10px; font-size: 0.75rem; font-weight: 800; }
.nivel-amarillo{ background: rgba(234,179,8,0.15);  color: #eab308; border: 1.5px solid rgba(234,179,8,0.3);  border-radius: 8px; padding: 3px 10px; font-size: 0.75rem; font-weight: 800; }
.nivel-verde   { background: rgba(34,197,94,0.15);  color: #22c55e; border: 1.5px solid rgba(34,197,94,0.3);  border-radius: 8px; padding: 3px 10px; font-size: 0.75rem; font-weight: 800; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.8); z-index: 9999; display: flex; align-items: center; justify-content: center; padding: 16px; backdrop-filter: blur(4px); }
.modal-box { background: #1e293b; border-radius: 20px; width: 100%; max-width: 520px; border: 1px solid rgba(255,255,255,0.1); max-height: 90vh; display: flex; flex-direction: column; }
.modal-header { padding: 20px 24px 16px; border-bottom: 1px solid rgba(255,255,255,0.07); display: flex; align-items: center; justify-content: space-between; }
.modal-body { padding: 20px 24px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 16px 24px; border-top: 1px solid rgba(255,255,255,0.07); display: flex; gap: 10px; justify-content: flex-end; }

/* Tabla */
.rf-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.rf-table th { padding: 12px 16px; text-align: left; font-size: 0.72rem; color: #64748b; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; border-bottom: 1px solid rgba(255,255,255,0.06); }
.rf-table td { padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,0.04); color: #cbd5e1; vertical-align: middle; }
.rf-table tr:hover td { background: rgba(255,255,255,0.03); }

/* Cámara */
.camera-container { position: relative; width: 100%; background: #000; border-radius: 0 0 16px 16px; overflow: hidden; border: 2px solid rgba(239,68,68,0.3); min-height: 280px; }
.camera-overlay { position: absolute; inset: 0; pointer-events: none; }
.scan-line { position: absolute; left: 5%; right: 5%; height: 3px; background: linear-gradient(90deg, transparent, #ef4444, transparent); animation: scanMove 2.5s linear infinite; box-shadow: 0 0 12px #ef4444; border-radius: 2px; }
.scan-frame { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 80%; height: 50%; border: 2px solid rgba(239,68,68,0.6); border-radius: 8px; box-shadow: inset 0 0 20px rgba(239,68,68,0.05); }
.scan-corner { position: absolute; width: 24px; height: 24px; border-color: #ef4444; border-style: solid; }
.scan-corner.tl { top: -2px; left: -2px; border-width: 3px 0 0 3px; border-radius: 4px 0 0 0; }
.scan-corner.tr { top: -2px; right: -2px; border-width: 3px 3px 0 0; border-radius: 0 4px 0 0; }
.scan-corner.bl { bottom: -2px; left: -2px; border-width: 0 0 3px 3px; border-radius: 0 0 0 4px; }
.scan-corner.br { bottom: -2px; right: -2px; border-width: 0 3px 3px 0; border-radius: 0 0 4px 0; }

/* Tesseract status */
.ocr-badge { display:inline-flex; align-items:center; gap:6px; padding:4px 12px; border-radius:99px; font-size:0.72rem; font-weight:700; }
.ocr-badge.loading { background: rgba(234,179,8,0.15); color:#eab308; border:1px solid rgba(234,179,8,0.3); }
.ocr-badge.ready { background: rgba(34,197,94,0.15); color:#22c55e; border:1px solid rgba(34,197,94,0.3); }

/* Resultado escaneo */
.result-card { border-radius: 16px; padding: 20px; margin-top: 16px; display: flex; align-items: center; gap: 16px; animation: fadeIn 0.4s ease; }
.result-rojo    { background: rgba(239,68,68,0.1);  border: 2px solid #ef4444; }
.result-naranja { background: rgba(249,115,22,0.1); border: 2px solid #f97316; }
.result-amarillo{ background: rgba(234,179,8,0.1);  border: 2px solid #eab308; }
.result-verde   { background: rgba(34,197,94,0.1);  border: 2px solid #22c55e; }
.result-icon { width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; flex-shrink: 0; }

/* Animaciones */
@keyframes scanMove { 0%{top:15%} 50%{top:75%} 100%{top:15%} }
@keyframes fadeIn { from{opacity:0;transform:translateY(10px)} to{opacity:1;transform:translateY(0)} }
@keyframes spin { from{transform:rotate(0deg)} to{transform:rotate(360deg)} }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }
.spin { animation: spin 1s linear infinite; }
.pulse { animation: pulse 2s infinite; }
.fade-in { animation: fadeIn 0.3s ease; }

/* Badge */
.badge { padding: 3px 10px; border-radius: 99px; font-size: 0.72rem; font-weight: 800; }

/* Login */
.login-bg { min-height: 100vh; background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%); display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { background: #1e293b; border-radius: 24px; padding: 40px; width: 100%; max-width: 400px; border: 1px solid rgba(255,255,255,0.1); box-shadow: 0 25px 50px rgba(0,0,0,0.5); }

/* Toast */
.toast { background: #1e293b; border-radius: 12px; padding: 12px 16px; display: flex; align-items: center; gap: 10px; box-shadow: 0 4px 20px rgba(0,0,0,0.4); font-size: 0.88rem; font-weight: 500; color: #e2e8f0; animation: fadeIn 0.3s ease; max-width: 300px; border: 1px solid rgba(255,255,255,0.1); }

/* Indicador grabando */
.rec-dot { width: 10px; height: 10px; background: #ef4444; border-radius: 50%; animation: pulse 1s infinite; display: inline-block; }

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

/* Mobile */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .section-page { padding: 16px; }
  .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 99; }
  .sidebar-overlay.show { display: block; }
  .hide-mobile { display: none !important; }
  .show-mobile { display: flex !important; }
}
@media (min-width: 769px) {
  .show-mobile { display: none !important; }
}
