/* Temas de pantalla: Claro (el de siempre, sin atributo), Corporativo y Oscuro.
   El shell pone data-tema en <html> (el suyo y el de cada página del iframe,
   js/app.js → aplicarTema) y mete este CSS en cada módulo. Solo cambia las
   variables que ya usan todas las páginas (--primary, --bg, --surface…) y unas
   pocas reglas generales; la impresión y los PDF siguen siempre en claro. */

@media screen {

/* ===== Corporativo: colores del logo de Additius ===== */
html[data-tema="corporativo"] {
    --primary:            #D9561A;
    --primary-dark:       #B8460F;
    --primary-light:      #FDEBDD;
    --primary-soft:       #F6B48C;
    --serie:              #D9561A;
    --serie-light:        #FDEBDD;
    --serie-soft:         #F6B48C;
    --info:               #D9561A;
    --bg:                 #F5F5F4;
    --card-bg:            #ffffff;
    --surface:            #ffffff;
    --text:               #2B2B2A;
    --text-secondary:     #5E5E5C;
    --text-muted:         #8E8E8B;
    --neutral:            #5E5E5C;
    --neutral-light:      #EDEDEC;
    --border:             #DCDCDA;
    --grid:               #EBEBEA;
    --sidebar-bg:         #4A4A48;
    --sidebar-hover:      #575755;
    --sidebar-active:     #FB8447;
    --sidebar-text:       #EDEDEB;
    --sidebar-text-muted: #B5B5B2;
    --sidebar-border:     rgba(255, 255, 255, 0.10);
}
html[data-tema="corporativo"] .logo i { color: #FB8447; }
html[data-tema="corporativo"] .menu-item:hover { color: #ffffff; }
html[data-tema="corporativo"] .menu-title { color: var(--sidebar-text-muted); }
html[data-tema="corporativo"] .menu-item.active {
    color: #2E251D;
    border-left-color: #FFD2B8;
}

/* ===== Oscuro ===== */
html[data-tema="oscuro"] {
    color-scheme: dark;
    --primary:            #D9724E;
    --primary-dark:       #F0A080;
    --primary-light:      #3D2A22;
    --primary-soft:       #7A4A37;
    --serie:              #D9724E;
    --serie-light:        #3D2A22;
    --serie-soft:         #7A4A37;
    --bg:                 #1B1A18;
    --card-bg:            #262522;
    --surface:            #262522;
    --text:               #ECE9E4;
    --text-secondary:     #ABA59C;
    --text-muted:         #8C867D;
    --neutral:            #ABA59C;
    --neutral-light:      #302E2B;
    --border:             #3B3935;
    --grid:               #302E2B;
    --ly:                 #6E685F;
    --success:            #6F9E5F;
    --success-light:      #243020;
    --warning:            #C99845;
    --warning-light:      #3A3020;
    --warn:               #C99845;
    --warn-light:         #3A3020;
    --danger:             #D45A45;
    --danger-light:       #3F2520;
    --info:               #82A6CC;
    --info-light:         #1F2A36;
    --shadow:             0 1px 3px rgba(0,0,0,0.5), 0 1px 2px rgba(0,0,0,0.4);
    --shadow-md:          0 4px 6px rgba(0,0,0,0.45), 0 2px 4px rgba(0,0,0,0.35);
    --sidebar-bg:         #211F1D;
    --sidebar-hover:      #2E2C29;
    --sidebar-active:     #3D2A22;
    --sidebar-text:       #E2DED8;
    --sidebar-text-muted: #9C958C;
    --sidebar-border:     rgba(255, 255, 255, 0.08);
}
html[data-tema="oscuro"] body { background-color: var(--bg); color: var(--text); }
html[data-tema="oscuro"] .menu-item:hover { color: #ffffff; }
/* Iconos de los KPI del panel: el tinte claro de fondo, apagado. */
html[data-tema="oscuro"] .kpi-icon { background: rgba(255, 255, 255, 0.06) !important; }

/* Colores que los módulos tenían escritos a mano (ahora var(--tm-…, color)):
   solo existen en este tema. */
html[data-tema="oscuro"] {
    --tm-fondo2: #2A2826;
    --tm-fondo3: #34322E;
    --tm-texto:  #ECE9E4;
    --tm-texto2: #ABA59C;
    --tm-borde:  #3B3935;
}

/* Vistas previas de documentos (hoja de papel): siguen en blanco. */
html[data-tema="oscuro"] :is(.pl-sheet, .pl-page) {
    color-scheme: light;
    --surface: #fff; --bg: #FAF9F5; --text: #1F1F1E; --text-secondary: #6E6961;
    --border: #E0D9CF; --tm-fondo2: #f2f2f2; --tm-fondo3: #e8eaed;
    --tm-texto: #111; --tm-texto2: #555; --tm-borde: #ccc;
}

/* Imágenes y logos sobre fondo oscuro: un borde claro para que no se pierdan. */
html[data-tema="oscuro"] img[src*="logo"] { background-color: #F5F2EC; border-radius: 4px; }

/* Barras de desplazamiento */
html[data-tema="oscuro"] ::-webkit-scrollbar-track { background: #1F1E1C; }
html[data-tema="oscuro"] ::-webkit-scrollbar-thumb { background: #44413C; border-radius: 6px; }

} /* @media screen */

/* Selector de tema del menú de usuario (solo en el shell). */
.tema-switch {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    font-size: 0.85rem;
}
.tema-switch-label { color: var(--text-secondary); display: flex; align-items: center; gap: 10px; }
.tema-switch-label i { width: 16px; text-align: center; }
.tema-switch-opts {
    margin-left: auto;
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.tema-switch-opts button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    width: 34px;
    height: 28px;
    cursor: pointer;
    font-size: 0.85rem;
}
.tema-switch-opts button + button { border-left: 1px solid var(--border); }
.tema-switch-opts button:hover { background: var(--primary-light); color: var(--primary); }
.tema-switch-opts button[aria-pressed="true"] { background: var(--primary); color: #fff; }
