/* ==========================================================================
   ui-premium.css  —  Capa de pulido final "apple.com"
   Control de Asistencia 15 de Mayo
   --------------------------------------------------------------------------
   Se carga SIEMPRE al final (después de style.css y mobile.css). No cambia la
   estructura ni los datos: sólo refina tipografía, espaciado, sombras, bordes
   y micro-interacciones para una experiencia premium y uniforme en TODAS las
   secciones. Pensado para no romper lo móvil: lo específico de tamaño va dentro
   de media queries.
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. TOKENS DE DISEÑO REFINADOS
   -------------------------------------------------------------------------- */
:root {
    --ux-ink: #1d1d1f;
    --ux-muted: #6e6e73;
    --ux-muted-2: #86868b;
    --ux-blue: #0071e3;
    --ux-blue-hover: #0077ed;
    --ux-hairline: rgba(0, 0, 0, 0.08);

    /* Sombras estratificadas (más cercanas a las de apple.com) */
    --ux-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.05);
    --ux-shadow-md: 0 2px 6px rgba(0, 0, 0, 0.05), 0 14px 40px rgba(0, 0, 0, 0.08);
    --ux-shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.06), 0 24px 64px rgba(0, 0, 0, 0.12);

    /* Curva de animación de Apple */
    --ux-ease: cubic-bezier(0.4, 0, 0.2, 1);
    --ux-ease-spring: cubic-bezier(0.34, 1.3, 0.64, 1);
}

/* --------------------------------------------------------------------------
   1. TIPOGRAFÍA — el sello Apple: interletraje negativo en títulos grandes
   --------------------------------------------------------------------------
   Apple usa tracking negativo en su tipografía de display. Esto es lo que más
   hace "premium" un titular. Se aplica con suavidad y sólo a textos grandes.
   -------------------------------------------------------------------------- */
html {
    scroll-behavior: smooth;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

.page-title,
.dashboard-title,
.navbar-brand,
.login-container h1,
.section-title-row h2,
h1, h2 {
    letter-spacing: -0.022em !important;
}

.dashboard-title,
.page-title {
    letter-spacing: -0.028em !important;
}

.summary-value,
.present-count,
.date-panel strong,
.teacher-hero .display-number {
    letter-spacing: -0.03em !important;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}

/* Cuerpo y subtítulos: un punto más legibles y aireados */
.dashboard-subtitle,
.lead,
.subtitle {
    letter-spacing: -0.01em;
}

/* Color de selección de texto en tono de marca */
::selection {
    background: rgba(0, 113, 227, 0.18);
}

/* --------------------------------------------------------------------------
   2. NAVBAR — barra translúcida más fina y elegante
   -------------------------------------------------------------------------- */
.navbar-custom {
    border-bottom: 0.5px solid var(--ux-hairline) !important;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) !important;
}

.navbar-custom .navbar-brand i {
    color: var(--ux-blue);
}

.navbar-custom .nav-link {
    position: relative;
    transition: color 0.2s var(--ux-ease), background-color 0.2s var(--ux-ease) !important;
}

/* Subrayado animado sutil bajo el ítem activo (estilo apple.com nav) */
@media (min-width: 992px) {
    .navbar-custom .nav-link::after {
        content: "";
        position: absolute;
        left: 12px;
        right: 12px;
        bottom: 2px;
        height: 2px;
        border-radius: 2px;
        background: var(--ux-blue);
        transform: scaleX(0);
        transform-origin: center;
        transition: transform 0.28s var(--ux-ease);
    }
    .navbar-custom .nav-link.active::after,
    .navbar-custom .nav-link:hover::after {
        transform: scaleX(1);
    }
}

/* --------------------------------------------------------------------------
   3. TARJETAS — sombras estratificadas + elevación al pasar el cursor
   -------------------------------------------------------------------------- */
.card-custom,
.apple-card {
    box-shadow: var(--ux-shadow-md) !important;
    border: 0.5px solid var(--ux-hairline) !important;
    transition: transform 0.3s var(--ux-ease), box-shadow 0.3s var(--ux-ease) !important;
}

@media (min-width: 769px) and (hover: hover) {
    .card-custom:hover,
    .apple-card:hover {
        transform: translateY(-2px);
        box-shadow: var(--ux-shadow-lg) !important;
    }
}

/* --------------------------------------------------------------------------
   4. BOTONES — micro-interacciones más vivas y pulsación táctil
   -------------------------------------------------------------------------- */
.btn,
.btn-apple,
.action-button,
.grade-tab,
.quick-action {
    transition: transform 0.18s var(--ux-ease-spring),
                background-color 0.2s var(--ux-ease),
                box-shadow 0.2s var(--ux-ease),
                color 0.2s var(--ux-ease) !important;
}

.btn:active,
.btn-apple:active,
.action-button:active,
.grade-tab:active,
.quick-action:active,
.icon-action:active {
    transform: scale(0.96) !important;
}

.btn-apple-primary,
.btn-primary,
.btn-login,
.action-button.primary {
    box-shadow: 0 6px 16px rgba(0, 113, 227, 0.24) !important;
}

.btn-apple-primary:hover,
.btn-primary:hover,
.btn-login:hover,
.action-button.primary:hover {
    box-shadow: 0 10px 26px rgba(0, 113, 227, 0.32) !important;
}

/* Botones de icono: realce más limpio */
.btn-icon,
.icon-action {
    transition: transform 0.18s var(--ux-ease-spring), background-color 0.2s var(--ux-ease) !important;
}

/* --------------------------------------------------------------------------
   5. CAMPOS DE CAPTURA — foco con anillo más limpio (mantiene los campos)
   -------------------------------------------------------------------------- */
.form-control,
.form-select,
.form-control-apple,
.form-control-login,
.search-field input {
    transition: background-color 0.2s var(--ux-ease),
                box-shadow 0.2s var(--ux-ease),
                border-color 0.2s var(--ux-ease) !important;
}

.form-control:focus,
.form-select:focus,
.form-control-apple:focus,
.form-control-login:focus {
    box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.16) !important;
    border-color: rgba(0, 113, 227, 0.45) !important;
}

/* Placeholder más suave y consistente */
::placeholder {
    color: rgba(60, 60, 67, 0.42) !important;
    opacity: 1;
}

/* --------------------------------------------------------------------------
   6. TABLAS — filas con realce suave al pasar el cursor
   -------------------------------------------------------------------------- */
@media (min-width: 769px) and (hover: hover) {
    .table tbody tr {
        transition: transform 0.2s var(--ux-ease), box-shadow 0.2s var(--ux-ease);
    }
    .table tbody tr:hover td {
        background: #ffffff !important;
        box-shadow: 0 10px 24px rgba(0, 0, 0, 0.06) !important;
    }
}

/* --------------------------------------------------------------------------
   7. DASHBOARD — refinado de los componentes propios
   -------------------------------------------------------------------------- */
.summary-item,
.classroom-card,
.teacher-group-card,
.teacher-list-card,
.date-panel {
    box-shadow: var(--ux-shadow-md) !important;
    border: 0.5px solid var(--ux-hairline) !important;
}

@media (min-width: 769px) and (hover: hover) {
    .classroom-card {
        transition: transform 0.3s var(--ux-ease), box-shadow 0.3s var(--ux-ease) !important;
    }
    .classroom-card:hover {
        transform: translateY(-3px);
        box-shadow: var(--ux-shadow-lg) !important;
    }
}

/* La línea de acento inferior de cada tarjeta-resumen, un poco más sutil */
.summary-item::after {
    opacity: 0.9 !important;
    height: 3px !important;
}

/* Barras de progreso con transición fluida al cargar */
.progress-bar {
    transition: width 0.9s var(--ux-ease) !important;
}

/* Eyebrow consistente (mayúsculas finas con tracking abierto, estilo Apple) */
.eyebrow {
    letter-spacing: 0.04em !important;
}

/* --------------------------------------------------------------------------
   8. BARRA INFERIOR MÓVIL — pestaña activa con "pill" de fondo
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    .mobile-tabbar .tabbar-item {
        transition: color 0.2s var(--ux-ease), background-color 0.2s var(--ux-ease);
    }
    .mobile-tabbar .tabbar-item.active {
        background: rgba(0, 113, 227, 0.10);
    }
    .mobile-tabbar .tabbar-item:active {
        transform: scale(0.94);
    }
}

/* --------------------------------------------------------------------------
   9. MODALES Y TOASTS — sombra más profunda y entrada suave
   -------------------------------------------------------------------------- */
/* Ventana flotante SÓLIDA y NÍTIDA (sin translucidez ni desenfoque encima).
   El "efecto opaco" debe quedar SOLO en el fondo, no en el modal.
   Selectores de ALTA especificidad para ganarle a las capas previas de style.css
   (que dejan el modal al 86-98% translúcido). */
.modal .modal-content,
.modal .modal-content-apple,
.modal-content.modal-content-apple,
.modal.show .modal-dialog .modal-content,
.modal.show .modal-dialog .modal-content.modal-content-apple {
    background: #ffffff !important;
    background-color: #ffffff !important;
    background-image: none !important;
    opacity: 1 !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.32) !important;
}

/* Las secciones internas heredan el blanco sólido (nada translúcido) */
.modal .modal-body,
.modal .modal-header,
.modal .modal-footer {
    background: transparent !important;
    background-color: transparent !important;
}

/* El fondo: oscurecido suave + desenfoque gausiano. Seguro porque el modal es
   blanco 100% opaco (no se transparenta el blur del fondo a través de él). */
.modal-backdrop,
.modal-backdrop.show {
    background: rgba(0, 0, 0, 0.28) !important;
    background-color: rgba(0, 0, 0, 0.28) !important;
    -webkit-backdrop-filter: blur(7px) saturate(118%) !important;
    backdrop-filter: blur(7px) saturate(118%) !important;
    opacity: 1 !important;
}

/* Por si alguna capa previa puso desenfoque sobre el contenedor del modal */
.modal,
.modal-dialog {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
}

/* CAUSA RAÍZ del modal "tapado": .main-content tiene z-index:1 y atrapa el modal
   por debajo del .modal-backdrop. Al abrir un modal liberamos ese contexto. */
body.modal-open .main-content {
    z-index: auto !important;
}
.modal { z-index: 5000 !important; }
.modal-backdrop { z-index: 4990 !important; }

.toast {
    box-shadow: var(--ux-shadow-md) !important;
}

/* --------------------------------------------------------------------------
   10. ENTRADA EN ESCENA — aparición suave del contenido (respeta accesibilidad)
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
    .dashboard,
    .summary-grid,
    .classroom-grid {
        animation: uxFadeUp 0.55s var(--ux-ease) both;
    }
    .summary-grid { animation-delay: 0.06s; }
    .classroom-grid { animation-delay: 0.12s; }

    @keyframes uxFadeUp {
        from { opacity: 0; transform: translateY(14px); }
        to   { opacity: 1; transform: translateY(0); }
    }
}

/* --------------------------------------------------------------------------
   11. DETALLES FINOS
   -------------------------------------------------------------------------- */
/* Barra de scroll discreta en escritorio */
@media (min-width: 769px) {
    * {
        scrollbar-width: thin;
        scrollbar-color: rgba(60, 60, 67, 0.28) transparent;
    }
    *::-webkit-scrollbar { width: 10px; height: 10px; }
    *::-webkit-scrollbar-thumb {
        background: rgba(60, 60, 67, 0.24);
        border-radius: 999px;
        border: 3px solid transparent;
        background-clip: content-box;
    }
    *::-webkit-scrollbar-thumb:hover {
        background: rgba(60, 60, 67, 0.4);
        background-clip: content-box;
    }
}

/* Foco visible accesible para navegación con teclado */
a:focus-visible,
button:focus-visible,
.btn:focus-visible,
.nav-link:focus-visible {
    outline: 2px solid var(--ux-blue);
    outline-offset: 2px;
    border-radius: 8px;
}

/* Imágenes y logos con render más nítido */
.school-logo,
.teacher-avatar img {
    image-rendering: -webkit-optimize-contrast;
}

/* --------------------------------------------------------------------------
   12. INDICADOR DE MODO DE ESCÁNER (Entrada / Salida / Salida Anticipada)
   --------------------------------------------------------------------------
   Deja CLARÍSIMO en qué modo está el usuario al escanear, para evitar
   confusiones (p. ej. registrar entrada creyendo que es salida).
   Colores: Entrada = verde · Salida = naranja · Anticipada = morado.
   -------------------------------------------------------------------------- */
.scan-mode {
    --sm-color: var(--ux-blue);
    --sm-tint: rgba(0, 113, 227, 0.10);
    margin: 0 auto 22px;
    max-width: 560px;
}

.scan-mode.mode-entrada   { --sm-color: #34c759; --sm-tint: rgba(52, 199, 89, 0.12); }
.scan-mode.mode-salida    { --sm-color: #ff9500; --sm-tint: rgba(255, 149, 0, 0.12); }
.scan-mode.mode-anticipada{ --sm-color: #af52de; --sm-tint: rgba(175, 82, 222, 0.12); }

/* Banner grande con el modo actual */
.scan-mode-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    border-radius: 20px;
    background: var(--sm-tint);
    border: 1px solid color-mix(in srgb, var(--sm-color) 28%, transparent);
    text-align: left;
}

.scan-mode-banner .sm-icon {
    flex: 0 0 auto;
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: var(--sm-color);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    box-shadow: 0 8px 20px color-mix(in srgb, var(--sm-color) 35%, transparent);
}

.scan-mode-banner .sm-text { min-width: 0; }

.scan-mode-banner .sm-eyebrow {
    display: block;
    color: var(--ux-muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 2px;
}

.scan-mode-banner .sm-name {
    display: block;
    color: var(--sm-color);
    font-size: clamp(22px, 6vw, 30px);
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -0.02em;
}

/* Indicador "en vivo" parpadeante para reforzar que está activo */
.scan-mode-banner .sm-live {
    margin-left: auto;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--sm-color);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.scan-mode-banner .sm-live::before {
    content: "";
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--sm-color);
    animation: smPulse 1.4s ease-in-out infinite;
}
@keyframes smPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.35; transform: scale(0.75); }
}

/* Selector segmentado para cambiar de modo */
.scan-mode-switch {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    margin-top: 10px;
    padding: 4px;
    border-radius: 16px;
    background: rgba(118, 118, 128, 0.10);
}

.scan-seg {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 52px;
    padding: 6px 4px;
    border-radius: 12px;
    text-decoration: none;
    color: var(--ux-muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: -0.01em;
    transition: background-color 0.2s var(--ux-ease), color 0.2s var(--ux-ease), transform 0.15s var(--ux-ease);
}
.scan-seg i { font-size: 18px; line-height: 1; }
.scan-seg:active { transform: scale(0.95); }

.scan-seg.active {
    background: #fff;
    color: var(--seg-color, var(--ux-blue));
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.10);
}
.scan-seg.seg-entrada    { --seg-color: #34c759; }
.scan-seg.seg-salida     { --seg-color: #ff9500; }
.scan-seg.seg-anticipada { --seg-color: #af52de; }

@media (max-width: 360px) {
    .scan-seg span { font-size: 11px; }
}

/* --------------------------------------------------------------------------
   13. VISOR DEL ESCÁNER — experiencia premium tipo cámara
   -------------------------------------------------------------------------- */
#qr-reader {
    position: relative;
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    min-height: 280px;
    border-radius: 24px !important;
    overflow: hidden;
    background:
        radial-gradient(circle at 50% 40%, rgba(0, 113, 227, 0.06), transparent 60%),
        #0b0b0d !important;
    border: 1px solid rgba(60, 60, 67, 0.18) !important;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04), var(--ux-shadow-md);
}

/* El video que inyecta la librería: que llene el visor de forma elegante */
#qr-reader video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block;
}

/* La librería del escáner ya dibuja su propio recuadro de enfoque. No añadimos
   marcos ni líneas extra para evitar el efecto de "doble recuadro". */

/* Suaviza el recuadro que dibuja la propia librería (html5-qrcode) para que
   combine con el diseño: borde fino claro, sin sombras duras. */
#qr-reader__scan_region {
    background: transparent !important;
}
#qr-reader__scan_region img { display: none !important; } /* quita el ícono por defecto */
#qr-reader video { border-radius: 0 !important; }

/* Placeholder dentro del visor antes de encender la cámara */
.qr-placeholder {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: rgba(255, 255, 255, 0.72);
    pointer-events: none;
}
.qr-placeholder i {
    font-size: 54px;
    line-height: 1;
    opacity: 0.9;
}
.qr-placeholder span {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.01em;
}

/* Botón de inicio del escáner: grande, claro e invitador */
#start-scan-btn {
    min-height: 56px !important;
    padding: 0 28px !important;
    font-size: 17px !important;
    border-radius: 18px !important;
}

/* Texto pequeño de permisos de cámara */
.scan-permite {
    margin: 10px 0 0 !important;
    font-size: 12px;
    color: var(--ux-muted);
    display: inline-flex;
    align-items: center;
    gap: 2px;
    line-height: 1.35;
}
.scan-permite i { font-size: 12px; }

/* Estado del escáner en pastilla */
#scanner-footer {
    margin-top: 16px !important;
}
#scanner-footer small {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(118, 118, 128, 0.10);
    color: var(--ux-muted);
    font-weight: 600;
    font-size: 12.5px;
}
