/* =============================================================================
   theme.css - tema oscuro de todo el sitio.
   Se activa con <html data-theme="dark"> (lo pone el script del <head> segun la eleccion guardada o
   el tema del sistema, y el boton .theme-toggle del menu la cambia). Sin atributo = tema claro.
   Se carga la ULTIMA para poder sobrescribir app.css, course.css y home.css.
   ============================================================================= */

/* ---- Variables del curso ---- */
html[data-theme="dark"] {
    --c-bg: #0b1020;
    --c-panel: #131a2e;
    --c-text: #e5e7eb;
    --c-muted: #9aa6bd;
    --c-border: #26304f;
    --c-primary: #818cf8;
    --c-primary-dark: #c7d2fe;
    --c-primary-soft: #1e2347;
    --c-shadow: 0 1px 3px rgba(0, 0, 0, .5);

    color-scheme: dark;}

/* ---- Base ---- */
html[data-theme="dark"] body,
html[data-theme="dark"] body:has(.course-layout) { background: #0b1020; color: #e5e7eb; }

/* ---- Cabecera y menu ---- */
html[data-theme="dark"] .main-header { background: #131a2e; border-bottom-color: #26304f; box-shadow: 0 1px 6px rgba(0, 0, 0, .4); }
html[data-theme="dark"] .logo-title { color: #a5b4fc; }
html[data-theme="dark"] .logo-version,
html[data-theme="dark"] .tool-version { color: #9aa6bd; }
html[data-theme="dark"] .logo-container:hover { background: rgba(129, 140, 248, .12); }
html[data-theme="dark"] .line { stroke: #e5e7eb; }
html[data-theme="dark"] .menu-toggle svg { stroke: #e5e7eb; }
html[data-theme="dark"] .nav-links { background: #131a2e; border-left-color: #818cf8; }
html[data-theme="dark"] .nav-links::before { color: #9aa6bd; }
html[data-theme="dark"] .nav-links a,
html[data-theme="dark"] .main-header .nav-links a { color: #a5b4fc; }
html[data-theme="dark"] .nav-links a:hover,
html[data-theme="dark"] .main-header .nav-links a:hover { background: rgba(129, 140, 248, .14); color: #c7d2fe; }
html[data-theme="dark"] .main-header .nav-links a.active { color: #f3f4f6; border-bottom-color: #e5484d; }
html[data-theme="dark"] #menuOverlay { background: rgba(0, 0, 0, .6); }
@media (min-width: 901px) {
    html[data-theme="dark"] .main-header .nav-links a { color: #b6c0d4; }
    html[data-theme="dark"] .main-header .nav-links a:hover { background: none; color: #c7d2fe; }
}

/* ---- Pie ---- */
html[data-theme="dark"] .site-footer { background: #0f1528; border-top-color: #26304f; color: #a5b0c5; }
html[data-theme="dark"] .footer-brand,
html[data-theme="dark"] .footer-links a { color: #a5b4fc; }
html[data-theme="dark"] .footer-links a:hover { color: #c7d2fe; }
html[data-theme="dark"] .footer-links.legal-links a,
html[data-theme="dark"] .footer-meta,
html[data-theme="dark"] .footer-version { color: #a5b0c5; }
html[data-theme="dark"] .footer-links.legal-links a:hover { color: #c7d2fe; }
html[data-theme="dark"] .lang-dropdown summary { color: #a5b0c5; }
html[data-theme="dark"] .lang-dropdown summary::after { border-top-color: #a5b0c5; }
html[data-theme="dark"] .lang-dropdown summary:hover { color: #c7d2fe; }
html[data-theme="dark"] .lang-menu { background: #131a2e; border-color: #26304f; box-shadow: 0 6px 24px rgba(0, 0, 0, .5); }
html[data-theme="dark"] .lang-menu a { color: #e5e7eb; }
html[data-theme="dark"] .lang-menu a:hover { background: rgba(129, 140, 248, .14); }

/* ---- Botones genericos ---- */
html[data-theme="dark"] .btn-secondary { background: #131a2e; color: #e5e7eb; border: 1px solid #26304f; }
html[data-theme="dark"] .btn-secondary:hover { background: #1a2340; }
html[data-theme="dark"] .lucide-icon { color: #818cf8; }

/* ---- Curso: textos, paneles y tarjetas ---- */
html[data-theme="dark"] .breadcrumbs li + li::before { color: #667085; }
html[data-theme="dark"] .page-title,
html[data-theme="dark"] .section-heading,
html[data-theme="dark"] .side-card h2,
html[data-theme="dark"] .side-card h3,
html[data-theme="dark"] .side-card .side-subtitle,
html[data-theme="dark"] .ex-card h3,
html[data-theme="dark"] .exercise-section h2,
html[data-theme="dark"] .lesson-node { color: #f3f4f6; }
html[data-theme="dark"] .page-lead { color: #b6c0d4; }
html[data-theme="dark"] .roadmap-row + .roadmap-row::before { border-left-color: #34456e; }
html[data-theme="dark"] .count-badge { border-color: #131a2e; }
html[data-theme="dark"] .side-list a { color: #b6c0d4; }
html[data-theme="dark"] .side-list a:hover { background: #1a2340; }
html[data-theme="dark"] .side-list a.active { background: var(--c-primary-soft); color: var(--c-primary-dark); }
html[data-theme="dark"] .num { background: #2a3350; }
html[data-theme="dark"] .ex-card { background: #131a2e; }
html[data-theme="dark"] .ex-card:hover { border-color: #3b5b85; box-shadow: 0 4px 14px rgba(0, 0, 0, .45); }
html[data-theme="dark"] .chip-theory { background: #1e2d57; color: #93b4ff; }
html[data-theme="dark"] .chip-practice { background: #123524; color: #86efac; }
html[data-theme="dark"] .chip-d1 { background: #0f2e22; color: #6ee7b7; }
html[data-theme="dark"] .chip-d2 { background: #3a2a0c; color: #fbbf24; }
html[data-theme="dark"] .chip-d3 { background: #3b1519; color: #fca5a5; }
html[data-theme="dark"] .exercise-problem { color: #d6dbe6; }
html[data-theme="dark"] .exercise-problem a { color: #8ab4f8; }
html[data-theme="dark"] .exercise-problem pre,
html[data-theme="dark"] .code-block { background: #0f1528; border-color: #26304f; color: #cbd5e1; }
html[data-theme="dark"] .exercise-problem code { color: #e2e8f0; }
html[data-theme="dark"] .solution-box { border-color: #26304f; }
html[data-theme="dark"] .solution-box .code-block { background: #070b16; color: #e2e8f0; border-top-color: #26304f; }
html[data-theme="dark"] .btn-ghost { background: #131a2e; color: var(--c-primary-dark); border-color: #34456e; }
html[data-theme="dark"] .btn-ghost:hover { background: var(--c-primary-soft); }
html[data-theme="dark"] .course-hero hr { border-top-color: #26304f; }

/* ---- Caracteristicas ---- */
html[data-theme="dark"] .features-header h1,
html[data-theme="dark"] .feature-card h3,
html[data-theme="dark"] .coming-soon h2,
html[data-theme="dark"] .share-app h2,
html[data-theme="dark"] .course-header h1,
html[data-theme="dark"] .course-block h2,
html[data-theme="dark"] .course-lessons h2 { color: #f3f4f6; }
html[data-theme="dark"] .features-header p,
html[data-theme="dark"] .feature-card p,
html[data-theme="dark"] .coming-soon p,
html[data-theme="dark"] .share-app p,
html[data-theme="dark"] .course-header p,
html[data-theme="dark"] .course-block p,
html[data-theme="dark"] .course-lessons p { color: #b6c0d4; }
html[data-theme="dark"] .feature-card,
html[data-theme="dark"] .lesson-card,
html[data-theme="dark"] .coming-list li { background: #131a2e; color: #e5e7eb; box-shadow: 0 6px 16px rgba(0, 0, 0, .35); }
html[data-theme="dark"] .course-block { background: #131a2e; box-shadow: 0 6px 18px rgba(0, 0, 0, .35); }
html[data-theme="dark"] .coming-soon,
html[data-theme="dark"] .share-app,
html[data-theme="dark"] .course-lessons { background: #0f1528; }
html[data-theme="dark"] .lesson-card span { box-shadow: 0 0 0 3px #131a2e; }

/* ---- Paginas legales ---- */
html[data-theme="dark"] .legal-page { background: #131a2e; color: #d6dbe6; }
html[data-theme="dark"] .legal-page h1 { color: #f3f4f6; }
html[data-theme="dark"] .legal-page h2 { color: #e5e7eb; border-left-color: #818cf8; }
html[data-theme="dark"] .legal-page p,
html[data-theme="dark"] .legal-page ul { color: #c3cad9; }
html[data-theme="dark"] .legal-page a { color: #a5b4fc; }
html[data-theme="dark"] .legal-page hr { border-top-color: #26304f; }

/* ---- Contacto ---- */
html[data-theme="dark"] .contact-section { color: #e5e7eb; }
html[data-theme="dark"] .contact-section h1 { color: #a5b4fc; }
html[data-theme="dark"] .contact-section .subtitle,
html[data-theme="dark"] .contact-right-text { color: #b6c0d4; }
html[data-theme="dark"] .contact-form label { color: #d6dbe6; }
html[data-theme="dark"] .contact-form input[type="text"],
html[data-theme="dark"] .contact-form input[type="email"],
html[data-theme="dark"] .contact-form textarea { background: #0f1528; border-color: #34456e; color: #e5e7eb; }
html[data-theme="dark"] .contact-form input::placeholder,
html[data-theme="dark"] .contact-form textarea::placeholder { color: #7c88a3; }
html[data-theme="dark"] .text-danger { color: #ff6b6b; }
html[data-theme="dark"] .summary-box { background: rgba(229, 57, 53, .12); }

/* ---- Boton de cambio de tema ---- */
html[data-theme="dark"] .theme-toggle .tt-moon { display: none; }
html[data-theme="dark"] .theme-toggle .tt-sun { display: inline-block; }
html[data-theme="dark"] .theme-toggle .tt-label-to-dark { display: none; }
html[data-theme="dark"] .theme-toggle .tt-label-to-light { display: inline; }

/* ---- Boton de cambio de tema (tema claro) ---- */
.theme-toggle {
    display: inline-flex; align-items: center; gap: .5rem; cursor: pointer;
    background: transparent; border: 1px solid transparent; color: inherit; font: inherit; line-height: 1;
    border-radius: 999px; padding: .5rem; transition: background .2s ease, color .2s ease;
}
.theme-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .tt-sun { display: none; }
.theme-toggle .tt-label-to-light { display: none; }
.theme-toggle:hover { background: rgba(79, 70, 229, .10); }
.theme-toggle:focus-visible { outline: 2px solid #818cf8; outline-offset: 2px; }
.nav-links .theme-toggle { color: #2e7dd8; font-size: 1.05rem; font-weight: 600; padding: .6rem .75rem; border-radius: 6px; width: 100%; text-align: left; }
.main-header .theme-toggle { color: #475467; }
html[data-theme="dark"] .nav-links .theme-toggle, html[data-theme="dark"] .main-header .theme-toggle { color: #b6c0d4; }
html[data-theme="dark"] .theme-toggle:hover { background: rgba(129, 140, 248, .16); }
/* En escritorio solo icono; en el cajon movil icono + texto */
@media (min-width: 769px) {
    .nav-links .theme-toggle { width: auto; padding: .5rem; }
    .theme-toggle .tt-text { display: none; }
}


/* ---- Pagina de leccion (tema oscuro) ---- */
html[data-theme="dark"] .section-count { background: #1a2a45; color: #a9cdf2; }
html[data-theme="dark"] .ex-theory { border-top-color: #4a6fb5; }
html[data-theme="dark"] .ex-theory .btn-read { background: #4a78d8; }
html[data-theme="dark"] .pager-link { background: #131a2e; border-color: #26304f; color: #e5e7eb; }
html[data-theme="dark"] .pager-link:hover { border-color: #6aa5de; box-shadow: 0 6px 16px rgba(0, 0, 0, .45); }
html[data-theme="dark"] .pager-link small { color: #9aa6bd; }
html[data-theme="dark"] .lesson-hero { box-shadow: 0 10px 28px rgba(0, 0, 0, .5); }


/* ---- Pagina de ejercicio (tema oscuro) ---- */
html[data-theme="dark"] .exercise-hero { box-shadow: 0 8px 22px rgba(0, 0, 0, .5); }
html[data-theme="dark"] .exercise-problem :not(pre) > code { background: #1a2a45; color: #a9cdf2; }
html[data-theme="dark"] .exercise-problem ul.lead { background: #16213a; }
html[data-theme="dark"] .exercise-problem th { background: #16213a; }
html[data-theme="dark"] .io-card { border-color: #26304f; background: #070b16; }
html[data-theme="dark"] .io-card .code-block { background: #070b16; }


/* ---- Indice del curso (tema oscuro) ---- */
html[data-theme="dark"] .course-banner {
    background:
        radial-gradient(30rem 16rem at 100% 0%, rgba(255, 212, 59, .14), transparent 60%),
        linear-gradient(135deg, #14253d, #1d4268 60%, #25577f);
    box-shadow: 0 10px 28px rgba(0, 0, 0, .5);
}
html[data-theme="dark"] .lesson-node:hover { background: #1a2340; border-color: #34456e; box-shadow: 0 10px 24px rgba(0, 0, 0, .5); }


/* ---- Marca (tema oscuro) ---- */
html[data-theme="dark"] .logo-title { color: #f3f4f6; }
html[data-theme="dark"] .logo-title .logo-accent { background: linear-gradient(90deg, #6aa5de, #8ec1ee 55%, #ffd43b); -webkit-background-clip: text; background-clip: text; color: transparent; }
html[data-theme="dark"] .logo-img { filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .5)); }
html[data-theme="dark"] .logo-container:hover { background: rgba(129, 140, 248, .14); }


/* ---- Tarjetas de la leccion (tema oscuro) ---- */
html[data-theme="dark"] .ex-theory { --ex: #8aa8f0; }
html[data-theme="dark"] .ex-practice { --ex: color-mix(in srgb, var(--c, #6aa5de) 55%, #ffffff); }
html[data-theme="dark"] .ex-card { box-shadow: 0 6px 16px rgba(0, 0, 0, .35); }
html[data-theme="dark"] .ex-card:hover { box-shadow: 0 14px 28px rgba(0, 0, 0, .55); }
html[data-theme="dark"] .ex-theory .btn-read, html[data-theme="dark"] .btn-read { background: none; }
html[data-theme="dark"] .ex-card-meta { border-bottom-color: #2a3555; }
html[data-theme="dark"] .ex-card:hover { border-color: var(--ex); }


/* ---- Paleta unificada (tema oscuro) ---- */
html[data-theme="dark"] .ex-practice, html[data-theme="dark"] .ex-theory { --ex: #818cf8; }
html[data-theme="dark"] .lesson-content .section-heading::before, html[data-theme="dark"] .exercise-section h2::before { background: #818cf8; }
html[data-theme="dark"] .exercise-problem ul.lead { border-left-color: #818cf8; background: #1a2040; }
html[data-theme="dark"] .exercise-problem ol.instructions-exercise > li::before { background: #6366f1; }
html[data-theme="dark"] .lesson-node-num { color: #a5b4fc; }
html[data-theme="dark"] .ex-practice .num, html[data-theme="dark"] .count-badge { background: #6366f1; }
html[data-theme="dark"] .section-count { background: #1e2347; color: #c7d2fe; }
html[data-theme="dark"] .exercise-problem :not(pre) > code { background: #1e2347; color: #c7d2fe; }
html[data-theme="dark"] .exercise-problem th { background: #1a2040; }
html[data-theme="dark"] .chip-theory { background: #1e2347; color: #c7d2fe; }
html[data-theme="dark"] .chip-practice { background: transparent; color: #e5e7eb; }
html[data-theme="dark"] .chip-d1, html[data-theme="dark"] .chip-d2, html[data-theme="dark"] .chip-d3 { background: transparent; color: #9aa6bd; }
html[data-theme="dark"] .lesson-hero .chip, html[data-theme="dark"] .exercise-hero .chip { background: rgba(255, 255, 255, .16); color: #fff; }
html[data-theme="dark"] .lesson-hero, html[data-theme="dark"] .exercise-hero, html[data-theme="dark"] .course-banner {
    background:
        radial-gradient(28rem 14rem at 100% 0%, rgba(255, 255, 255, .08), transparent 60%),
        linear-gradient(135deg, #1e1b4b 0%, #3730a3 100%);
}
html[data-theme="dark"] .lesson-hero-icon .count-badge { background: #fff; color: #4f46e5; }
html[data-theme="dark"] .pager-link:hover, html[data-theme="dark"] .ex-card:hover { border-color: #818cf8; }

/* menu desplegable del usuario */
html[data-theme="dark"] .user-menu > summary { color: #e5e7eb; }
html[data-theme="dark"] .user-menu > summary:hover { color: #c7d2fe; }
html[data-theme="dark"] .user-menu-list { background: #131a2e; border-color: #26304f; box-shadow: 0 8px 24px rgba(0, 0, 0, .55); }
html[data-theme="dark"] .nav-links .user-menu-list a,
html[data-theme="dark"] .main-header .nav-links .user-menu-list a,
html[data-theme="dark"] .user-menu-list button { color: #e5e7eb; background: none; }
html[data-theme="dark"] .nav-links .user-menu-list a:hover,
html[data-theme="dark"] .main-header .nav-links .user-menu-list a:hover,
html[data-theme="dark"] .user-menu-list button:hover { background: rgba(129, 140, 248, .16); color: #c7d2fe; }
html[data-theme="dark"] .user-menu-list form { border-top-color: #26304f; }

html[data-theme="dark"] .user-menu-trigger:hover .user-avatar,
html[data-theme="dark"] .user-menu[open] .user-avatar { filter: brightness(1.2); }

/* ---- Tema dentro del menu del usuario (con sesion): fila de menu con icono + texto ---- */
.nav-links .user-menu-list .theme-toggle.um-theme,
.main-header .nav-links .user-menu-list .theme-toggle.um-theme {
    display: flex; align-items: center; gap: .6rem; width: 100%; padding: .5rem .9rem; margin: 0;
    border: 0; border-radius: 0; background: none; font: inherit; font-size: inherit; font-weight: 400;
    color: var(--c-text); text-align: left;
}
.nav-links .user-menu-list .theme-toggle.um-theme:hover { background: rgba(79, 70, 229, .08); color: var(--c-primary); }
.user-menu-list .theme-toggle.um-theme svg { width: 18px; height: 18px; flex: none; }
.user-menu-list .theme-toggle.um-theme .tt-text { display: inline; }
html[data-theme="dark"] .nav-links .user-menu-list .theme-toggle.um-theme,
html[data-theme="dark"] .main-header .nav-links .user-menu-list .theme-toggle.um-theme { color: #e5e7eb; }
html[data-theme="dark"] .nav-links .user-menu-list .theme-toggle.um-theme:hover { background: rgba(129, 140, 248, .16); color: #c7d2fe; }
/* Sin sesion: el icono va justo antes del boton de registro, que queda el ultimo */
@media (min-width: 769px) { .nav-links > .theme-toggle { margin-right: .25rem; } }
