/*
 * ============================================================================
 * TRICXO UI — CAPA VISUAL GLOBAL
 * ============================================================================
 * Objetivo:
 *   Unificar el frontend de Tricxo y TricxoJunior sin modificar la lógica PHP,
 *   las consultas SQL, las rutas, los formularios ni los flujos de sesión.
 *
 * Estrategia:
 *   Este archivo se carga DESPUÉS de los estilos particulares de cada pantalla.
 *   Por eso funciona como una capa de normalización visual progresiva: mantiene
 *   estructuras existentes y armoniza color, tipografía, formularios, tablas,
 *   tarjetas, navegación y estados interactivos.
 *
 * Mantenimiento:
 *   Las variables de :root son la fuente principal de la identidad visual.
 *   Si en el futuro cambia la marca, conviene modificar primero esos tokens.
 * ============================================================================
 */

/* -------------------------------------------------------------------------- */
/* 1. TOKENS DE DISEÑO                                                       */
/* -------------------------------------------------------------------------- */
:root {
    /* Fondos oscuros: crean profundidad sin usar negro puro en todos los planos. */
    --tricxo-bg: #05080d;
    --tricxo-bg-soft: #09111a;
    --tricxo-panel: rgba(14, 24, 36, 0.94);
    --tricxo-panel-strong: rgba(18, 31, 46, 0.97);

    /* Colores de marca: azul/cian, verde y naranja como acentos funcionales. */
    --tricxo-blue: #168cff;
    --tricxo-cyan: #47c8ff;
    --tricxo-green: #28d991;
    --tricxo-orange: #ff8a1f;
    --tricxo-red: #fb7185;

    /* Texto y divisores. */
    --tricxo-text: #f6f9fc;
    --tricxo-muted: #9db1c5;
    --tricxo-border: rgba(157, 197, 230, 0.14);
    --tricxo-border-strong: rgba(71, 200, 255, 0.34);

    /* Sombras: se mantienen discretas para no convertir el neón en ruido. */
    --tricxo-shadow: 0 22px 60px rgba(0, 0, 0, 0.36);
    --tricxo-glow-blue: 0 0 24px rgba(22, 140, 255, 0.12);
    --tricxo-glow-green: 0 0 24px rgba(40, 217, 145, 0.12);
    --tricxo-glow-orange: 0 0 24px rgba(255, 138, 31, 0.10);

    /* Radios y transiciones para que todos los módulos se sientan relacionados. */
    --tricxo-radius-sm: 10px;
    --tricxo-radius-md: 16px;
    --tricxo-radius-lg: 24px;
    --tricxo-transition: 180ms ease;
}

/* -------------------------------------------------------------------------- */
/* 2. BASE, TIPOGRAFÍA Y ACCESIBILIDAD                                        */
/* -------------------------------------------------------------------------- */
html {
    color-scheme: dark;
    background: var(--tricxo-bg);
    scroll-behavior: smooth;
}

/* El box model estable evita desbordamientos accidentales en formularios. */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    /* Se conserva cualquier layout propio; solo se normaliza la identidad base. */
    color: var(--tricxo-text);
    font-family: Outfit, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background-color: var(--tricxo-bg);
    background-image:
        radial-gradient(circle at 10% 8%, rgba(22, 140, 255, 0.10), transparent 30rem),
        radial-gradient(circle at 88% 88%, rgba(40, 217, 145, 0.075), transparent 32rem),
        linear-gradient(rgba(71, 200, 255, 0.022) 1px, transparent 1px),
        linear-gradient(90deg, rgba(71, 200, 255, 0.022) 1px, transparent 1px);
    background-size: 100% 100%, 100% 100%, 32px 32px, 32px 32px;
    background-attachment: fixed;
}

/* Selección de texto alineada con la marca. */
::selection {
    color: #04110b;
    background: rgba(40, 217, 145, 0.88);
}

/* Scrollbars finos: aportan consistencia en tablas, sidebars y aulas largas. */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(71, 200, 255, 0.42) rgba(255, 255, 255, 0.035);
}

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.025); }
*::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: 999px;
    background: rgba(71, 200, 255, 0.38);
    background-clip: padding-box;
}

/* Foco visible para navegación por teclado; no depende solo del color del control. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 2px solid var(--tricxo-cyan);
    outline-offset: 3px;
}

/* -------------------------------------------------------------------------- */
/* 3. NAVEGACIÓN Y CABECERAS                                                  */
/* -------------------------------------------------------------------------- */
:where(.top, .topbar, .header, .navbar, .barra-superior, header.top) {
    border-bottom-color: rgba(71, 200, 255, 0.22);
    background-color: rgba(5, 8, 13, 0.90);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

/* Los enlaces de navegación ganan feedback sin desplazar el layout. */
:where(.nav, .navegacion, .nav-links, .top nav, .topbar nav) a {
    transition: color var(--tricxo-transition), border-color var(--tricxo-transition), background-color var(--tricxo-transition), box-shadow var(--tricxo-transition);
}

:where(.nav, .navegacion, .nav-links, .top nav, .topbar nav) a:hover {
    border-color: rgba(71, 200, 255, 0.30);
    background-color: rgba(71, 200, 255, 0.055);
}

/* -------------------------------------------------------------------------- */
/* 4. SUPERFICIES: TARJETAS, PANELES Y CONTENEDORES                          */
/* -------------------------------------------------------------------------- */
:where(
    .card, .panel, .box, .form-card, .info-card, .account-card, .order-card,
    .table-card, .course, .academy-card, .program, .tool, .subject,
    .summary-card, .detail-card, .payment-step, .attempt, .season-card,
    .stat-card, .metric-card, .content-card, .section-card
) {
    border-color: var(--tricxo-border);
    background-color: var(--tricxo-panel);
    box-shadow: 0 14px 42px rgba(0, 0, 0, 0.16);
}

/* Hover solo en superficies que normalmente son interactivas o navegables. */
:where(.course, .academy-card, .program, .tool, .subject, .season-card):hover {
    border-color: rgba(71, 200, 255, 0.34);
    box-shadow: var(--tricxo-glow-blue);
}

/* Los bloques principales reciben un borde ligeramente más técnico. */
:where(.hero, .heading, .cta-box, .payments-box) {
    border-color: rgba(71, 200, 255, 0.24);
    box-shadow: var(--tricxo-shadow), var(--tricxo-glow-blue);
}

/* -------------------------------------------------------------------------- */
/* 5. TÍTULOS, ETIQUETAS Y TEXTO AUXILIAR                                    */
/* -------------------------------------------------------------------------- */
:where(.eyebrow, .section-label, .kicker, .label-upper) {
    color: var(--tricxo-green);
    letter-spacing: 0.12em;
}

:where(.muted, .help, .lead, .subtitle, .description, .hint, small) {
    color: var(--tricxo-muted);
}

/* -------------------------------------------------------------------------- */
/* 6. FORMULARIOS                                                             */
/* -------------------------------------------------------------------------- */
:where(input, select, textarea) {
    color: var(--tricxo-text);
    border-color: var(--tricxo-border);
    background-color: rgba(4, 10, 16, 0.68);
    transition: border-color var(--tricxo-transition), box-shadow var(--tricxo-transition), background-color var(--tricxo-transition);
}

:where(input, select, textarea):hover {
    border-color: rgba(157, 197, 230, 0.26);
    background-color: rgba(7, 16, 24, 0.82);
}

:where(input, select, textarea):focus {
    border-color: rgba(40, 217, 145, 0.72);
    box-shadow: 0 0 0 3px rgba(40, 217, 145, 0.09), var(--tricxo-glow-green);
}

:where(input, textarea)::placeholder {
    color: rgba(157, 177, 197, 0.58);
}

/* Checkbox y radio adoptan el verde de éxito de la plataforma. */
:where(input[type="checkbox"], input[type="radio"]) {
    accent-color: var(--tricxo-green);
}

/* Los archivos deben conservar la zona clicable nativa del navegador. */
input[type="file"]::file-selector-button {
    margin-right: 10px;
    padding: 8px 11px;
    color: var(--tricxo-text);
    border: 1px solid rgba(71, 200, 255, 0.24);
    border-radius: 8px;
    background: rgba(71, 200, 255, 0.07);
    cursor: pointer;
}

/* -------------------------------------------------------------------------- */
/* 7. BOTONES Y ACCIONES                                                      */
/* -------------------------------------------------------------------------- */
:where(.button, .btn, button, input[type="submit"], input[type="button"]) {
    transition: transform var(--tricxo-transition), border-color var(--tricxo-transition), box-shadow var(--tricxo-transition), filter var(--tricxo-transition);
}

:where(.button, .btn, button, input[type="submit"], input[type="button"]):not(:disabled):hover {
    transform: translateY(-1px);
}

/* Acciones principales: verde/cian para comunicar avance o confirmación. */
:where(.button.primary, .btn.primary, .primary.button, .pay, button.primary, input[type="submit"].primary) {
    color: #04110b;
    border-color: rgba(40, 217, 145, 0.78);
    background: linear-gradient(135deg, var(--tricxo-green), #8ef1c9);
    box-shadow: 0 6px 20px rgba(40, 217, 145, 0.16);
}

:where(.button.primary, .btn.primary, .primary.button, .pay, button.primary, input[type="submit"].primary):not(:disabled):hover {
    box-shadow: 0 8px 26px rgba(40, 217, 145, 0.24), var(--tricxo-glow-green);
}

/* Acciones secundarias: mantienen contraste sin competir con el CTA. */
:where(.button.secondary, .btn.secondary, .secondary.button) {
    color: #bfe9ff;
    border-color: rgba(71, 200, 255, 0.28);
    background: rgba(71, 200, 255, 0.055);
}

/* Estados deshabilitados conservan legibilidad y eliminan interacción visual. */
:where(button, .button, .btn, input[type="submit"]):disabled,
:where(.disabled, [aria-disabled="true"]) {
    cursor: not-allowed;
    filter: grayscale(0.35);
    opacity: 0.56;
    transform: none;
}

/* -------------------------------------------------------------------------- */
/* 8. TABLAS Y DATOS                                                          */
/* -------------------------------------------------------------------------- */
:where(table) {
    border-color: var(--tricxo-border);
    background: rgba(8, 15, 23, 0.72);
}

:where(th) {
    color: #b8ccdf;
    border-color: var(--tricxo-border);
    background: rgba(71, 200, 255, 0.045);
}

:where(td) {
    border-color: var(--tricxo-border);
}

:where(tbody tr) {
    transition: background-color var(--tricxo-transition);
}

:where(tbody tr):hover {
    background: rgba(71, 200, 255, 0.028);
}

/* -------------------------------------------------------------------------- */
/* 9. BADGES, MENSAJES Y ESTADOS                                              */
/* -------------------------------------------------------------------------- */
:where(.badge, .tag, .chip, .status) {
    border-color: var(--tricxo-border);
}

:where(.mensaje-exito, .success, .success-box, .alert-success, .status.ok) {
    color: #b8f8dc;
    border-color: rgba(40, 217, 145, 0.28);
    background-color: rgba(40, 217, 145, 0.09);
}

:where(.mensaje-error, .error, .error-box, .alert-error, .danger) {
    color: #ffd0d8;
    border-color: rgba(251, 113, 133, 0.30);
    background-color: rgba(251, 113, 133, 0.085);
}

:where(.warning, .warning-box, .notice) {
    border-color: rgba(255, 138, 31, 0.28);
    background-color: rgba(255, 138, 31, 0.07);
}

/* -------------------------------------------------------------------------- */
/* 10. AULA Y CONTENIDO MULTIMEDIA                                            */
/* -------------------------------------------------------------------------- */
/* El visor se mantiene oscuro para que video/PDF sean el foco principal. */
:where(.viewer, .ratio, .document-frame) {
    border-color: rgba(71, 200, 255, 0.18);
}

/* La lección actual se identifica con cian; completada con verde. */
:where(.lesson-link.current) {
    border-left-color: var(--tricxo-cyan);
    background-color: rgba(71, 200, 255, 0.07);
}

:where(.lesson-link.done) {
    color: #aff5d3;
}

/* -------------------------------------------------------------------------- */
/* 11. DOCUMENTOS LEGALES                                                     */
/* -------------------------------------------------------------------------- */
/*
 * Privacidad y términos conservan su contenido y jerarquía, pero adoptan la
 * misma lectura oscura de Tricxo. La clase `legal-page` limita estas reglas a
 * esos documentos para no afectar otras vistas con una clase `.container`.
 */
body.legal-page {
    max-width: 1180px;
    padding: 38px 20px 70px;
    color: var(--tricxo-text);
}

body.legal-page .container {
    padding: clamp(26px, 5vw, 58px);
    color: var(--tricxo-text);
    border: 1px solid rgba(71, 200, 255, 0.22);
    border-radius: var(--tricxo-radius-lg);
    background: linear-gradient(145deg, rgba(14, 24, 36, 0.97), rgba(7, 13, 21, 0.98));
    box-shadow: var(--tricxo-shadow), var(--tricxo-glow-blue);
}

body.legal-page h1,
body.legal-page h2,
body.legal-page h3 {
    color: var(--tricxo-text);
}

body.legal-page h1 {
    border-bottom-color: rgba(71, 200, 255, 0.18);
}

body.legal-page h2 {
    color: var(--tricxo-cyan);
}

body.legal-page h3 {
    color: #9de3ff;
}

body.legal-page p,
body.legal-page li {
    color: #c7d5e2;
}

body.legal-page a {
    color: #8ed8ff;
}

body.legal-page :where(.scope, .notice, .warning, .safe) {
    color: #d8e5ef;
    background: rgba(255, 255, 255, 0.035);
}

body.legal-page .scope { border-left-color: var(--tricxo-blue); }
body.legal-page .notice { border-left-color: var(--tricxo-orange); }
body.legal-page .warning { border-left-color: var(--tricxo-red); }
body.legal-page .safe { border-left-color: var(--tricxo-green); }

body.legal-page .roles th {
    color: #061018;
    background: linear-gradient(135deg, var(--tricxo-cyan), var(--tricxo-green));
}

body.legal-page .roles td {
    color: #cbd9e5;
    border-color: var(--tricxo-border);
    background: rgba(255, 255, 255, 0.018);
}

body.legal-page .print-button {
    color: #04110b;
    border: 1px solid rgba(40, 217, 145, 0.72);
    border-radius: 12px;
    background: linear-gradient(135deg, var(--tricxo-green), #8ef1c9);
    box-shadow: var(--tricxo-glow-green);
}

@media print {
    /* La impresión vuelve a un documento claro para ahorrar tinta y mantener legibilidad. */
    body.legal-page {
        color: #111827;
        background: #fff !important;
    }

    body.legal-page .container {
        color: #111827;
        border: 0;
        background: #fff;
        box-shadow: none;
    }

    body.legal-page :where(h1, h2, h3, p, li, a) {
        color: #111827;
    }
}

/* -------------------------------------------------------------------------- */
/* 12. RESPONSIVE GLOBAL                                                      */
/* -------------------------------------------------------------------------- */
@media (max-width: 760px) {
    /* Evita que botones agrupados queden demasiado pequeños en pantallas táctiles. */
    :where(.actions, .form-actions, .button-row) {
        gap: 10px;
    }

    /* Las tablas siguen siendo accesibles por desplazamiento horizontal. */
    :where(.table-card, .scroll, .table-wrap, .table-responsive) {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Los campos usan 16px para evitar zoom automático en Safari/iOS. */
    :where(input, select, textarea) {
        font-size: max(16px, 1em);
    }
}

/* -------------------------------------------------------------------------- */
/* 13. USUARIOS QUE PREFIEREN MENOS MOVIMIENTO                                */
/* -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }

    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
