/* ═══════════════════════════════════════════
   CORE — Design tokens, reset, shared utils
   ═══════════════════════════════════════════ */

:root {
    /* ── Corporate palette ──────────────────────────── */
    --brand-primary:   #008ecf;   /* IPS medium blue  */
    --brand-dark:      #004f9f;   /* IPS dark blue    */
    --brand-navy:      #243d75;   /* IPS navy         */
    --brand-light:     #c9e8fb;   /* IPS sky          */
    --brand-teal:      #62b6be;   /* complementary    */
    --brand-purple:    #785ea5;   /* complementary    */
    --brand-coral:     #ec6769;   /* complementary    */
    --brand-orange:    #ef8b58;   /* complementary    */
    --brand-amber:     #f2d55b;   /* complementary    */
    --brand-pink:      #ea90bc;   /* complementary    */
    --brand-charcoal:  #504f4f;   /* complementary    */
    --brand-near-black:#282728;   /* complementary    */

    /* ── Semantic aliases (used across all modules) ── */
    --accent-cyan:    var(--brand-primary);   /* was #0284c7 */
    /* Azul de acento para iconos, toggles y textos enlazados. Se usaba en varios
       módulos sin estar declarado: la variable inválida tumbaba la propiedad
       entera (fondos transparentes, outlines que no salían). */
    --accent-blue:    var(--brand-dark);
    --accent-purple:  var(--brand-purple);    /* was #7c3aed */
    --accent-emerald: #059669;
    --accent-amber:   var(--brand-orange);    /* was #d97706 */
    --accent-red:     var(--brand-coral);     /* was #dc2626 */
    --accent-teal:    var(--brand-teal);

    /* ── Background & text ── */
    --bg-primary:    #f8fafc;     /* lienzo del área principal (= --ui-canvas) */
    --bg-secondary:  #f4f4f4;
    --bg-tertiary:   #fff;
    --bg-card:       #ffffff;

    --text-primary:   #1a2744;   /* brand-navy-derived dark      */
    --text-secondary: #334155;
    --text-muted:     #64748b;

    --border-color: rgba(0, 78, 159, 0.08);
    --glass-bg:     rgba(255, 255, 255, 0.88);
    --glass-border: rgba(0, 142, 207, 0.1);

    /* ── Spacing ── */
    --space-xs:  0.25rem;
    --space-sm:  0.5rem;
    --space-md:  1rem;
    --space-lg:  1.5rem;
    --space-xl:  2rem;
    --space-2xl: 3rem;

    /* ── Radius ── */
    --radius-sm:   6px;
    --radius-md:   10px;
    --radius-lg:   16px;
    --radius-xl:   20px;
    --radius-full: 9999px;

    /* ── Typography ── */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-xs:  0.75rem;
    --font-sm:  0.875rem;
    --font-md:  1rem;
    --font-lg:  1.25rem;
    --font-xl:  1.5rem;
    --font-2xl: 2rem;

    /* ── Transitions ── */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --duration: 0.3s;

    /* ── Shadows ── */
    --shadow-sm:  0 1px 3px rgba(0,78,159,0.05);
    --shadow-md:  0 4px 12px rgba(0,78,159,0.07);
    --shadow-lg:  0 8px 30px rgba(0,78,159,0.10);
    --shadow-glow-cyan:   0 0 20px rgba(0,142,207,0.18);
    --shadow-glow-purple: 0 0 20px rgba(120,94,165,0.15);

    /* ── Sistema de componentes UI (assets/css/components/*, prefijo .ui-) ──
       Estilo "clínico": superficies blancas, bordes slate muy suaves y el azul
       corporativo como acento. Los componentes SOLO leen estos tokens; una vista
       no debería redefinirlos, sino usar los componentes tal cual. */
    --ui-canvas:       #f8fafc;
    --ui-surface:      #ffffff;
    --ui-surface-2:    #f8fafc;   /* pies de tarjeta, inputs en reposo */
    --ui-border:       #e2e8f0;
    --ui-border-soft:  #f1f5f9;   /* separadores dentro de una tarjeta */

    --ui-text:         #0f172a;
    --ui-text-2:       #475569;
    --ui-text-3:       #94a3b8;   /* etiquetas, metadatos */
    --ui-icon:         #94a3b8;

    --ui-accent:        var(--brand-primary);
    --ui-accent-strong: var(--brand-dark);
    --ui-accent-soft:   #eef7fc;
    --ui-accent-border: rgba(0, 142, 207, 0.22);
    --ui-ring:          0 0 0 3px rgba(0, 142, 207, 0.18);
    --ui-on-solid:      #ffffff;  /* texto e iconos sobre un relleno de marca o de acento */

    --ui-radius-sm:   8px;
    --ui-radius-md:   12px;
    --ui-radius-lg:   16px;

    --ui-shadow-xs:  0 1px 2px rgba(15, 23, 42, 0.04);
    --ui-shadow-sm:  0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.03);
    --ui-shadow-md:  0 6px 18px rgba(15, 23, 42, 0.07);

    /* Gráficas (UI.chart y el XLSX de reportes). Las series toman estos colores
       EN ESTE ORDEN, nunca ciclados: una sola serie siempre es la 1 (la
       categoría la dice el eje, no el color). La pareja pasó el validador de la
       skill dataviz sobre blanco (daltonismo, luminosidad y contraste); cambiar
       uno obliga a validarla de nuevo. */
    --ui-chart-1:    #008ecf;
    --ui-chart-2:    #eb6834;
    --ui-chart-grid: #e8edf3;   /* rejilla del eje de valores: se ve, no compite */
    --ui-chart-axis: #cbd5e1;   /* línea base de las barras */

    /* Impresión: lo que sale en papel, en negro y grises (la hoja de Reglamento Interno). */
    --ui-print-ink:    #000000;
    --ui-print-line:   #999999;   /* bordes de las fichas */
    --ui-print-border: #cccccc;   /* bordes de las secciones */
}

/* ─── Reset ─── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: clamp(14px, 0.875rem + 0.25vw, 16px);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    position: relative;
    overflow-x: hidden;
}

body {
    font-family: var(--font-family);
    color: var(--text-primary);
    background: var(--bg-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
    border: none;
    cursor: pointer;
    background: none;
    padding: 0;
    line-height: inherit;
}

input:not([type="checkbox"]):not([type="radio"]), select, textarea {
    font-family: inherit;
    font-size: inherit;
    -webkit-appearance: none;
    appearance: none;
}
input[type="checkbox"], input[type="radio"] {
    -webkit-appearance: auto;
    appearance: auto;
}

img { max-width: 100%; display: block; }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--text-muted) var(--bg-secondary);
}

/* ─── Accessibility ─── */
:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}

/* ─── Utility classes ─── */
.hidden { display: none !important; }

/* ─── Shared utilities ─── */
.spa-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

.spa-loader__spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-cyan);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.view-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    min-height: 400px;
    color: var(--text-secondary);
}

.view-error .material-symbols-rounded {
    font-size: 3rem;
    color: var(--accent-red);
}

/* ─── Avatar Component ─── */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: 50%;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
    overflow: hidden;
}
.avatar--sm { width: 36px; height: 36px; }
.avatar--md { width: 48px; height: 48px; }
.avatar--lg { width: 64px; height: 64px; }

/* Material Symbols config */
.material-symbols-rounded {
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* ─── Responsive spacing ─── */
@media (max-width: 768px) {
    :root {
        --space-lg:  1rem;
        --space-xl:  1.25rem;
        --space-2xl: 1.5rem;
    }
}

/* ─── Reduced motion ─── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
