/* =====================================================================
   ControlID - Estilos base de marca
   Paleta:
     --ci-primary   Azul oscuro (identidad)
     --ci-green      Permitido
     --ci-yellow     Revision
     --ci-red        Bloqueo
     --ci-blue       Extranjero
   ===================================================================== */

:root {
    --ci-primary: #0f2c52;
    --ci-primary-600: #16407a;
    --ci-primary-050: #eaf1fb;
    --ci-green: #1e9e5a;
    --ci-yellow: #e6a700;
    --ci-red: #d13438;
    --ci-blue: #2b6cb0;
    --ci-gray-050: #f4f6f9;
    --ci-gray-100: #e9edf2;
    --ci-gray-600: #5a6472;
    --ci-ink: #1b2430;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--ci-ink);
    background: var(--ci-gray-050);
}

/* Marca --------------------------------------------------------------*/
.ci-brand {
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--ci-primary);
}
.ci-brand span { color: var(--ci-green); }

.text-primary-ci { color: var(--ci-primary) !important; }
.bg-primary-ci { background-color: var(--ci-primary) !important; }

.btn-ci {
    background: var(--ci-primary);
    border-color: var(--ci-primary);
    color: #fff;
}
.btn-ci:hover { background: var(--ci-primary-600); border-color: var(--ci-primary-600); color: #fff; }

/* Navbar publica -----------------------------------------------------*/
.navbar-ci {
    background: #fff;
    border-bottom: 1px solid var(--ci-gray-100);
}

/* Hero ---------------------------------------------------------------*/
.ci-hero {
    background: linear-gradient(135deg, var(--ci-primary) 0%, var(--ci-primary-600) 100%);
    color: #fff;
    padding: 5rem 0;
}
.ci-hero .lead { opacity: 0.92; }

/* Tarjetas -----------------------------------------------------------*/
.ci-card {
    background: #fff;
    border: 1px solid var(--ci-gray-100);
    border-radius: 14px;
    box-shadow: 0 1px 2px rgba(15, 44, 82, 0.04);
}
.ci-metric { border-radius: 14px; border: 1px solid var(--ci-gray-100); background: #fff; }
.ci-metric .value { font-size: 1.9rem; font-weight: 700; color: var(--ci-primary); }
.ci-metric .label { color: var(--ci-gray-600); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em; }

/* Estados de acceso (semaforo) --------------------------------------*/
.badge-permitido { background: var(--ci-green); }
.badge-revision  { background: var(--ci-yellow); color: #3a2e00; }
.badge-bloqueo   { background: var(--ci-red); }
.badge-extranjero{ background: var(--ci-blue); }

/* Auth ---------------------------------------------------------------*/
.ci-auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, var(--ci-primary) 0%, #0a1f3c 100%);
}
.ci-auth-card { border-radius: 16px; }

/* Panel --------------------------------------------------------------*/
.ci-sidebar {
    background: var(--ci-primary);
    color: #cdd8ea;
    min-height: 100vh;
    width: 260px;
}
.ci-sidebar a { color: #cdd8ea; text-decoration: none; border-radius: 8px; }
.ci-sidebar a:hover, .ci-sidebar a.active { background: rgba(255, 255, 255, 0.10); color: #fff; }
.ci-sidebar .brand { color: #fff; }
.ci-topbar { background: #fff; border-bottom: 1px solid var(--ci-gray-100); }

.ci-footer { background: var(--ci-primary); color: #aab8cf; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.ci-footer a { color: #cdd8ea; text-decoration: none; }
.ci-footer a:hover { color: #fff; }

/* Variante clara: sin fondo, texto/enlaces azules (para fondos claros). */
.ci-footer-light { background: transparent; color: var(--ci-gray-600); border-top: 1px solid var(--ci-gray-100); }
.ci-footer-light a { color: var(--ci-primary); text-decoration: none; }
.ci-footer-light a:hover { color: var(--ci-primary-600); text-decoration: underline; }

/* El modal de registro manual debe quedar por ENCIMA del overlay del
   semaforo (z-index 1080), o el formulario abre "por detras". */
#manualModal { z-index: 1090; }
.modal-backdrop { z-index: 1085; }

/* Menu movil (hamburguesa) para admin y operador --------------------*/
.ci-hamburger { display: none; border: 0; background: transparent; font-size: 1.5rem; line-height: 1; padding: .25rem .5rem; cursor: pointer; }
.ci-sidebar-backdrop { display: none; }
@media (max-width: 768px) {
    .ci-hamburger { display: inline-flex; align-items: center; }
    .ci-sidebar {
        position: fixed; top: 0; left: 0; bottom: 0;
        width: 250px; min-height: 100vh; z-index: 1200;
        transform: translateX(-100%); transition: transform .25s ease;
        overflow-y: auto;
    }
    .ci-sidebar.open { transform: translateX(0); box-shadow: 0 0 30px rgba(0, 0, 0, .4); }
    .ci-sidebar-backdrop.show {
        display: block; position: fixed; inset: 0;
        background: rgba(0, 0, 0, .45); z-index: 1150;
    }
}

/* Captura de la MRZ (reverso): cámara acotada + botón siempre visible */
.pdf-capture { flex-direction: column !important; justify-content: flex-start !important; padding: 0 !important; }
.pdf-capture .pdf-head { flex: 0 0 auto; width: 100%; padding: .7rem 1rem .3rem; text-align: center; }
.pdf-capture .pdf-cam {
    flex: 1 1 auto; width: 100%; min-height: 0; position: relative;
    display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.pdf-capture .pdf-cam video { max-width: 100%; max-height: 100%; border-radius: 10px; background: #0b1a30; }
.pdf-capture .pdf-foot {
    flex: 0 0 auto; width: 100%; padding: .7rem 1rem calc(.9rem + env(safe-area-inset-bottom, 0px));
    background: rgba(0, 0, 0, .18);
}
/* Horizontal / pantallas bajas: compactar para que todo quepa. */
@media (max-height: 520px) {
    .pdf-capture .pdf-head { padding: .35rem .8rem .1rem; }
    .pdf-capture .pdf-head h1 { font-size: 1rem; }
    .pdf-capture .pdf-head p { display: none; }
    .pdf-capture .pdf-foot { padding: .4rem .8rem calc(.5rem + env(safe-area-inset-bottom, 0px)); }
    .pdf-capture .pdf-foot .btn { padding: .4rem 1rem; font-size: 1rem; }
    .pdf-capture #pdfStatus { font-size: .85rem; margin-bottom: .35rem !important; }
}

/* Escaneo QR - resultado a pantalla completa (semaforo) --------------*/
.scan-overlay {
    position: fixed;
    inset: 0;
    z-index: 1080;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #fff;
    padding: 1.5rem;
}
.scan-overlay.verde    { background: var(--ci-green); }
.scan-overlay.rojo     { background: var(--ci-red); }
.scan-overlay.azul     { background: var(--ci-blue); }
.scan-overlay.amarillo { background: var(--ci-yellow); color: #3a2e00; }
.scan-inner { max-width: 560px; width: 100%; }
.scan-icon {
    width: 96px; height: 96px; margin: 0 auto 1rem;
    border-radius: 50%; background: rgba(255, 255, 255, 0.2);
    display: flex; align-items: center; justify-content: center;
    font-size: 3rem; font-weight: 700;
}
.scan-title { font-size: 2.4rem; font-weight: 800; margin-bottom: .25rem; }
.scan-name { font-size: 1.5rem; font-weight: 700; margin-bottom: .25rem; }
.scan-rut { font-size: 1.1rem; opacity: .9; }
.scan-msg { font-size: 1.05rem; opacity: .95; margin: 1rem 0 1.5rem; }
#reader { border-radius: 12px; overflow: hidden; }
