/* Accesibilidad de PRISMA: tamaño del texto y modo nocturno.
   ==========================================================================

   Dos preferencias, una sola pieza. Viven en el navegador de cada persona y no
   en su cuenta, porque son de la pantalla que está usando: el mismo usuario
   necesita otro tamaño en el notebook de la oficina que en la sala de reuniones.

   El tamaño se cambia moviendo `font-size` del <html>, no con el zoom del
   navegador: así crece el texto y las cajas lo acompañan —todo está en `rem`—,
   sin que aparezca una barra horizontal.

   La hoja es **aditiva**: todo lo de noche cuelga de `html[data-tema="noche"]`,
   así que el modo claro sigue siendo exactamente el mismo CSS de siempre.
   Ninguna regla de acá se aplica mientras nadie encienda el modo nocturno. */


/* ==========================================================================
   1. El botón, en la barra de arriba
   ========================================================================== */

.a11y {
    position: relative;
}

.a11y__btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    background: transparent;
    border: 1px solid #009fe3;
    color: #009fe3;
    border-radius: 999px;
    padding: .25rem .7rem;
    font-size: .8rem;
    font-weight: 500;
    line-height: 1.4;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.a11y__btn:hover,
.a11y__btn[aria-expanded="true"] {
    background: #009fe3;
    color: #ffffff;
}

.a11y__icono {
    font-size: 1rem;
    line-height: 1;
}

.a11y__panel {
    position: absolute;
    right: 0;
    top: calc(100% + .5rem);
    z-index: 1100;
    width: 17rem;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, .12);
    padding: .9rem 1rem 1rem;
    text-align: left;
}

.a11y__panel[hidden] {
    display: none;
}

.a11y__titulo {
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #9ca3af;
    margin: 0 0 .5rem;
}

.a11y__grupo + .a11y__grupo {
    margin-top: 1rem;
    padding-top: .9rem;
    border-top: 1px solid #eef0f3;
}

.a11y__zoom {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.a11y__paso {
    flex: 0 0 auto;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    color: #374151;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: all .15s ease;
}

.a11y__paso:hover:not(:disabled) {
    border-color: #009fe3;
    color: #009fe3;
}

.a11y__paso:disabled {
    opacity: .4;
    cursor: not-allowed;
}

.a11y__nivel {
    flex: 1 1 auto;
    text-align: center;
    font-size: .95rem;
    font-weight: 600;
    color: #374151;
    font-variant-numeric: tabular-nums;
}

.a11y__reset {
    display: block;
    width: 100%;
    margin-top: .5rem;
    background: none;
    border: 0;
    padding: .2rem;
    font-size: .75rem;
    color: #6b7280;
    text-decoration: underline;
    cursor: pointer;
}

.a11y__reset:hover {
    color: #009fe3;
}

.a11y__fila {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
}

.a11y__etiqueta {
    font-size: .85rem;
    font-weight: 500;
    color: #374151;
}

/* Interruptor. Es un checkbox de verdad debajo: se puede llegar con el
   tabulador y la barra espaciadora lo cambia, que es lo que espera quien no
   usa el ratón. */
.a11y__switch {
    position: relative;
    flex: 0 0 auto;
    width: 2.9rem;
    height: 1.6rem;
}

.a11y__switch input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.a11y__switch span {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: #d1d5db;
    transition: background .2s ease;
    pointer-events: none;
}

.a11y__switch span::after {
    content: "";
    position: absolute;
    top: .2rem;
    left: .2rem;
    width: 1.2rem;
    height: 1.2rem;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
    transition: transform .2s ease;
}

.a11y__switch input:checked + span {
    background: #009fe3;
}

.a11y__switch input:checked + span::after {
    transform: translateX(1.3rem);
}

.a11y__switch input:focus-visible + span {
    outline: 2px solid #009fe3;
    outline-offset: 2px;
}

.a11y__nota {
    margin: .6rem 0 0;
    font-size: .7rem;
    line-height: 1.35;
    color: #9ca3af;
}

/* En la pantalla de ingreso no hay barra donde colgarlo, así que flota. */
.a11y-flotante {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1100;
}

/* La barra lateral medía 260 px fijos, así que al agrandar el texto los
   nombres del menú se partían en dos líneas. En `rem` acompaña al tamaño
   elegido, y a tamaño normal mide exactamente los mismos 260 px de siempre.
   El `:not(.hidden)` es para no pisar el ancho cero con que se repliega. */
.sidebar:not(.hidden),
.sidebar:not(.hidden) .sidebar-content {
    width: 16.25rem;
}

/* La barra de arriba tenía la altura clavada en 60 px: al agrandar el texto,
   el botón se salía por abajo. */
.topbar {
    height: auto;
    min-height: 60px;
    padding-top: .4rem;
    padding-bottom: .4rem;
    gap: .5rem;
    flex-wrap: wrap;
}


/* ==========================================================================
   2. Modo nocturno — la paleta
   ========================================================================== */

html[data-tema="noche"] {
    --noche-fondo: #12161c;
    --noche-superficie: #1b212a;
    --noche-superficie-alta: #222a35;
    --noche-hundido: #161c24;
    --noche-borde: #303a48;
    --noche-borde-suave: #262f3a;
    --noche-texto: #e6eaf0;
    --noche-texto-suave: #b9c2cf;
    --noche-texto-apagado: #8b95a5;
    --noche-acento: #3fb5f0;

    color-scheme: dark;
}

/* El armazón */
html[data-tema="noche"] body {
    background-color: var(--noche-fondo);
    color: var(--noche-texto-suave);
}

html[data-tema="noche"] .sidebar {
    background-color: #0e1319;
}

html[data-tema="noche"] .topbar {
    background-color: var(--noche-superficie);
    border-bottom-color: var(--noche-borde);
}

html[data-tema="noche"] .content {
    color: var(--noche-texto-suave);
}

html[data-tema="noche"] .btn-volver {
    background: var(--noche-superficie-alta);
    border-color: var(--noche-borde);
    color: var(--noche-texto-suave);
}

html[data-tema="noche"] .btn-volver:hover {
    background: var(--noche-superficie-alta);
    border-color: var(--noche-acento);
    color: var(--noche-acento);
}

html[data-tema="noche"] .btn-outline-secondary {
    border-color: var(--noche-acento);
    color: var(--noche-acento);
}

html[data-tema="noche"] .btn-outline-secondary:hover {
    background-color: var(--noche-acento);
    color: #0e1319;
}

/* El panel del propio botón */
html[data-tema="noche"] .a11y__panel {
    background: var(--noche-superficie-alta);
    border-color: var(--noche-borde);
    box-shadow: 0 12px 32px rgba(0, 0, 0, .5);
}

html[data-tema="noche"] .a11y__grupo + .a11y__grupo {
    border-top-color: var(--noche-borde-suave);
}

html[data-tema="noche"] .a11y__paso {
    background: var(--noche-superficie);
    border-color: var(--noche-borde);
    color: var(--noche-texto);
}

html[data-tema="noche"] .a11y__nivel,
html[data-tema="noche"] .a11y__etiqueta {
    color: var(--noche-texto);
}

html[data-tema="noche"] .a11y__btn {
    border-color: var(--noche-acento);
    color: var(--noche-acento);
}

html[data-tema="noche"] .a11y__btn:hover,
html[data-tema="noche"] .a11y__btn[aria-expanded="true"] {
    background: var(--noche-acento);
    color: #0e1319;
}

html[data-tema="noche"] .a11y__switch span {
    background: #3f4a5a;
}


/* ==========================================================================
   3. Modo nocturno — las paletas que cada app ya tenía en variables
   --------------------------------------------------------------------------
   OTEC y Proyectos definen sus superficies y sus textos como variables, así
   que basta redefinirlas: todo lo que las usa se da vuelta solo. `html[...]`
   pesa más que el `:root` donde están declaradas, así que gana sin `!important`.
   ========================================================================== */

html[data-tema="noche"] {
    /* OTEC */
    --otec-text: var(--noche-texto);
    --otec-muted: var(--noche-texto-suave);
    --otec-faint: var(--noche-texto-apagado);
    --otec-line: var(--noche-borde);
    --otec-surface: var(--noche-superficie);
    --otec-bg-soft: var(--noche-hundido);
    --otec-primary: var(--noche-acento);
    --otec-ok: #4ade80;
    --otec-warn: #fbbf24;
    --otec-danger: #f87171;
    --otec-shadow: 0 1px 2px rgba(0, 0, 0, .4);

    /* Proyectos */
    --proy-bg: var(--noche-fondo);
    --proy-surface: var(--noche-superficie);
    --proy-surface-elev: var(--noche-superficie-alta);
    --proy-border: var(--noche-borde);
    --proy-border-soft: var(--noche-borde-suave);
    --proy-border-col: var(--noche-borde-suave);
    --proy-text: var(--noche-texto);
    --proy-text-soft: var(--noche-texto-suave);
    --proy-text-muted: var(--noche-texto-apagado);
    --proy-primary: #60a5fa;
    --proy-primary-soft: #1e293b;
    --proy-success: #4ade80;
    --proy-success-soft: #14321f;
    --proy-warning: #fbbf24;
    --proy-warning-soft: #33250a;
    --proy-danger: #f87171;
    --proy-danger-soft: #3a1717;
    --proy-shadow-xs: 0 1px 2px rgba(0, 0, 0, .35);
    --proy-shadow-sm: 0 1px 3px rgba(0, 0, 0, .4);
    --proy-shadow-md: 0 4px 16px rgba(0, 0, 0, .45);
    --proy-shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
}


/* ==========================================================================
   4. Lo impreso se queda en blanco
   --------------------------------------------------------------------------
   Un informe se imprime en papel o se manda en PDF, y ahí el fondo oscuro no
   es una preferencia de pantalla: es tinta. Al imprimir, el modo nocturno se
   apaga entero.
   ========================================================================== */

@media print {
    html[data-tema="noche"] {
        color-scheme: light;
    }

    html[data-tema="noche"] body,
    html[data-tema="noche"] .content {
        background: #ffffff !important;
        color: #111827 !important;
    }
}
