:root {
    --color-fondo:        #F5F1E8;
    --color-blanco:       #FFFFFF;
    --color-acento:       #6B93C7;
    --color-acento-hover: #4F7CB5;
    --color-texto:        #2a2a2a;
    --fuente-titulo:      'Inter', 'Open Sans', sans-serif;
    --fuente-mono:        'Courier New', Courier, monospace;
}

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

body {
    background-color: var(--color-fondo);
    font-family: var(--fuente-titulo);
    font-size: 18px;        /* base ampliada para adultos mayores */
    line-height: 1.7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    color: var(--color-texto);
}

/* ─── Header compartido ───────────────────────────────── */

.header {
    background-color: var(--color-fondo);
    border-bottom: 1px solid rgba(107, 147, 199, 0.25);
    padding: 1.25rem 1.5rem;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    position: relative;
    z-index: 100;
}

.header__inicio {
    grid-column: 2;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-texto);
    text-decoration: none;
    letter-spacing: -0.02em;
    transition: color 0.2s ease;
    text-align: center;
    white-space: nowrap;
}

.header__inicio:hover {
    color: var(--color-acento-hover);
}

.header__nav {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Clase semántica usada por global.js para ocultar el enlace de perfil */
.header__link-nav {
    display: none; /* oculto — está en el menú hamburguesa */
}

.header__boton {
    background-color: var(--color-acento);
    color: var(--color-blanco);
    text-decoration: none;
    padding: 0.625rem 1.25rem;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background-color 0.2s ease;
    white-space: nowrap;
    border: none;
    cursor: pointer;
    font-family: var(--fuente-titulo);
}

.header__boton:hover {
    background-color: var(--color-acento-hover);
}

/* ─── Menú hamburguesa ────────────────────────────────── */

.hdr-izq {
    display: flex;
    align-items: center;
}

.hdr-menu {
    position: relative;
}

.hdr-menu__btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.6rem;
    border-radius: 0.5rem;
    min-height: 44px;
    width: 44px;
    transition: background 0.15s;
}

.hdr-menu__btn:hover {
    background: rgba(107, 147, 199, 0.12);
}

.hdr-menu__btn span {
    display: block;
    height: 2px;
    width: 22px;
    background: var(--color-texto);
    border-radius: 2px;
}

.hdr-menu__panel {
    display: none;
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    background: #fff;
    border-radius: 0.75rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.13);
    min-width: 200px;
    padding: 0.5rem 0;
    z-index: 200;
}

.hdr-menu__panel--visible {
    display: block;
}

.hdr-menu__link {
    display: block !important; /* override .header__link-nav { display:none } */
    padding: 0.75rem 1.25rem;
    color: var(--color-texto);
    text-decoration: none;
    font-size: 0.95rem;
    border: none !important;
    border-radius: 0 !important;
    min-height: unset !important;
    transition: background 0.15s;
}

.hdr-menu__link:hover {
    background: rgba(107, 147, 199, 0.1);
    color: var(--color-acento);
}

.hdr-menu__item {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
    color: var(--color-texto);
    cursor: default;
    transition: background 0.15s;
}

.hdr-menu__item:hover {
    background: rgba(107, 147, 199, 0.1);
}

.hdr-menu__flecha {
    font-size: 0.65rem;
    color: #aaa;
    flex-shrink: 0;
}

/* Texto de Cursos como link */
.hdr-menu__item-link {
    flex: 1;
    color: var(--color-texto);
    text-decoration: none;
    font-size: 0.95rem;
}

.hdr-menu__item-link:hover {
    color: var(--color-acento);
}

/* Botón ▶ que abre el submenú */
.hdr-menu__flecha-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.65rem;
    color: #aaa;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}

.hdr-menu__flecha-btn:hover {
    background: rgba(107, 147, 199, 0.15);
    color: var(--color-acento);
}

.hdr-menu__submenu {
    display: none;
    position: absolute;
    left: 100%;
    top: -0.5rem;
    background: #fff;
    border-radius: 0.75rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.13);
    min-width: 230px;
    padding: 0.5rem 0;
    z-index: 300;
}

.hdr-menu__item--cursos:hover .hdr-menu__submenu {
    display: block;
}

.hdr-menu__sublink {
    display: block;
    padding: 0.75rem 1.25rem;
    color: var(--color-texto);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.15s, color 0.15s;
}

.hdr-menu__sublink:hover {
    background: rgba(107, 147, 199, 0.1);
    color: var(--color-acento);
}

/* Ocultar botón de login en páginas de acceso */
.pagina-auth .header__boton {
    display: none !important;
}

/* ─── Botón ← Volver (inyectado por JS) ──────────────── */
.header__volver {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-acento-hover);
    background: none;
    border: 1.5px solid var(--color-acento);
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    transition: background-color 0.2s ease, color 0.2s ease;
    font-family: var(--fuente-titulo);
    white-space: nowrap;
    min-height: 40px;
}

.header__volver:hover {
    background-color: var(--color-acento);
    color: var(--color-blanco);
}

/* ─── Botón primario reutilizable ─────────────────────── */

.boton-primario {
    display: inline-block;
    background-color: var(--color-acento);
    color: var(--color-blanco);
    text-decoration: none;
    padding: 1rem 3rem;      /* más grande para adultos mayores */
    border-radius: 999px;
    font-size: 1.1rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s ease;
    text-align: center;
    min-height: 52px;        /* área de toque mínima */
    min-width: 44px;
}

.boton-primario:hover:not(:disabled) {
    background-color: var(--color-acento-hover);
}

.boton-primario:disabled {
    background-color: #b0bec5;
    cursor: not-allowed;
    opacity: 0.75;
}

/* ─── Dropdown de perfil de usuario ──────────────────── */

.perfil-dropdown {
    position: relative;
}

.perfil-dropdown__trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: 1.5px solid var(--color-acento);
    border-radius: 999px;
    padding: 0.5rem 1rem 0.5rem 0.6rem;
    cursor: pointer;
    font-family: var(--fuente-titulo);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-acento-hover);
    transition: background-color 0.2s ease;
    min-height: 44px;
    white-space: nowrap;
}

.perfil-dropdown__trigger:hover,
.perfil-dropdown--abierto .perfil-dropdown__trigger {
    background-color: var(--color-acento);
    color: var(--color-blanco);
}

.perfil-dropdown__avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: rgba(107, 147, 199, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    overflow: hidden;
    flex-shrink: 0;
}

.perfil-dropdown__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.perfil-dropdown__nombre {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.perfil-dropdown__flecha {
    font-size: 0.65rem;
    transition: transform 0.2s ease;
}

.perfil-dropdown--abierto .perfil-dropdown__flecha {
    transform: rotate(180deg);
}

.perfil-dropdown__menu {
    display: none;
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background-color: var(--color-blanco);
    border: 1.5px solid rgba(107, 147, 199, 0.25);
    border-radius: 0.875rem;
    padding: 0.4rem;
    min-width: 180px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    z-index: 100;
    flex-direction: column;
    gap: 0.15rem;
}

.perfil-dropdown--abierto .perfil-dropdown__menu {
    display: flex;
}

.perfil-dropdown__item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    border-radius: 0.625rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-texto);
    text-decoration: none;
    cursor: pointer;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    font-family: var(--fuente-titulo);
    transition: background-color 0.15s ease;
}

.perfil-dropdown__item:hover {
    background-color: rgba(107, 147, 199, 0.08);
}

.perfil-dropdown__divisor {
    height: 1px;
    background-color: #eee;
    margin: 0.25rem 0.5rem;
}

.perfil-dropdown__item--salir {
    color: #c0392b;
}

.perfil-dropdown__item--salir:hover {
    background-color: rgba(192, 57, 43, 0.07);
}

/* ─── Aviso de actividades pendientes ─────────────────── */

.actividades-aviso {
    font-family: var(--fuente-mono);
    font-size: 0.85rem;
    color: #888;
    text-align: center;
    padding: 0.4rem 0;
}

/* ─── Imágenes fluidas globales ───────────────────────── */

img {
    max-width: 100%;
    height: auto;
}

/* ─── Submenú de Cursos activo (JS) ──────────────────── */

.hdr-menu__item--abierto .hdr-menu__submenu {
    display: block;
}

@media (min-width: 640px) {
    .header {
        padding: 1.5rem 3rem;
    }
    .header__boton {
        font-size: 1rem;
        padding: 0.75rem 1.75rem;
    }
}

/* ─── Mobile ──────────────────────────────────────────── */

@media (max-width: 768px) {
    /* Submenú: abre hacia abajo dentro del panel, no a la derecha */
    .hdr-menu__submenu {
        position: static;
        box-shadow: none;
        border-radius: 0;
        border-top: 1px solid rgba(107, 147, 199, 0.12);
        min-width: 100%;
        padding: 0.25rem 0 0.25rem 1rem;
        display: none;
    }

    .hdr-menu__item--cursos:hover .hdr-menu__submenu {
        display: none; /* deshabilitar hover en touch */
    }

    .hdr-menu__item--abierto .hdr-menu__submenu {
        display: block;
    }

    .hdr-menu__flecha {
        transition: transform 0.2s;
    }

    .hdr-menu__item--abierto .hdr-menu__flecha {
        transform: rotate(90deg);
    }
}

@media (max-width: 480px) {
    .header {
        padding: 0.9rem 1rem;
    }

    .header__inicio {
        font-size: 0.9rem;
    }

    .header__boton {
        font-size: 0.82rem;
        padding: 0.5rem 0.9rem;
    }

    .header__volver {
        font-size: 0.82rem;
        padding: 0.5rem 0.75rem;
    }

    /* Dropdown de perfil alineado a la derecha en pantallas pequeñas */
    .perfil-dropdown__menu {
        right: 0;
        left: auto;
        min-width: 200px;
    }
}
