/**
 * ============================================================
 * themes.css - PREVAED LMS
 * ============================================================
 * Paletas de color del Theme Manager.
 *
 * Cada paleta es un selector [data-palette="..."] que redefine
 * SOLO las variables --primary* de modern.css. El resto del
 * sistema (fondos, textos, dark mode) no se toca: las paletas
 * funcionan igual en modo claro y oscuro.
 *
 * El atributo data-palette se pone en <html>, junto a data-theme.
 * Ej: <html data-theme="dark" data-palette="musgo">
 *
 * Cargar despues de modern.css y antes de dashboards.css.
 * ============================================================ */

/* ---- TEAL (por defecto) ---------------------------------- */
/* Es la paleta original. Se deja explicita para que el Theme
   Manager pueda "volver al tema por defecto". */
[data-palette="teal"] {
    --primary:       #0d9488;
    --primary-light: #14b8a6;
    --primary-dark:  #0f766e;
    --primary-50:    #f0fdfa;
    --primary-100:   #ccfbf1;
    --primary-200:   #99f6e4;
    --primary-rgb:   13, 148, 136;
}
[data-theme="dark"][data-palette="teal"] {
    --primary-50:  rgba(13, 148, 136, 0.15);
    --primary-100: rgba(13, 148, 136, 0.25);
}

/* ---- ARENA (suave) -------------------------------------- */
[data-palette="arena"] {
    --primary:       #b08968;
    --primary-light: #c9a487;
    --primary-dark:  #8f6e52;
    --primary-50:    #f7f1ea;
    --primary-100:   #ece0d3;
    --primary-200:   #e0c9b3;
    --primary-rgb:   176, 137, 104;
}
[data-theme="dark"][data-palette="arena"] {
    --primary-50:  rgba(201, 164, 135, 0.15);
    --primary-100: rgba(201, 164, 135, 0.25);
}

/* ---- OCEANO (azul claro) --------------------------------- */
[data-palette="ocean"] {
    --primary:       #0284c7;
    --primary-light: #0ea5e9;
    --primary-dark:  #0369a1;
    --primary-50:    #f0f9ff;
    --primary-100:   #e0f2fe;
    --primary-200:   #bae6fd;
    --primary-rgb:   2, 132, 199;
}
[data-theme="dark"][data-palette="ocean"] {
    --primary-50:  rgba(14, 165, 233, 0.15);
    --primary-100: rgba(14, 165, 233, 0.25);
}

/* ---- MUSGO (suave) -------------------------------------- */
[data-palette="musgo"] {
    --primary:       #6e8b6e;
    --primary-light: #92a992;
    --primary-dark:  #587058;
    --primary-50:    #eef2ee;
    --primary-100:   #dce4dc;
    --primary-200:   #bccbbc;
    --primary-rgb:   110, 139, 110;
}
[data-theme="dark"][data-palette="musgo"] {
    --primary-50:  rgba(146, 169, 146, 0.15);
    --primary-100: rgba(146, 169, 146, 0.25);
}

/* ---- MALVA (suave) -------------------------------------- */
[data-palette="malva"] {
    --primary:       #a06f7e;
    --primary-light: #bd95a3;
    --primary-dark:  #835764;
    --primary-50:    #f6eef1;
    --primary-100:   #ebdce1;
    --primary-200:   #d8c0c8;
    --primary-rgb:   160, 111, 126;
}
[data-theme="dark"][data-palette="malva"] {
    --primary-50:  rgba(189, 149, 163, 0.15);
    --primary-100: rgba(189, 149, 163, 0.25);
}

/* ---- ROSA ------------------------------------------------ */
[data-palette="rose"] {
    --primary:       #db2777;
    --primary-light: #ec4899;
    --primary-dark:  #be185d;
    --primary-50:    #fdf2f8;
    --primary-100:   #fce7f3;
    --primary-200:   #fbcfe8;
    --primary-rgb:   219, 39, 119;
}
[data-theme="dark"][data-palette="rose"] {
    --primary-50:  rgba(236, 72, 153, 0.15);
    --primary-100: rgba(236, 72, 153, 0.25);
}

/* ============================================================
   SIDEBAR POR PALETA
   El sidebar usa --sidebar-bg (un degradado fijo en modern.css).
   Aqui se redefine para que combine con la paleta activa.
   ============================================================ */
[data-palette="arena"]  { --sidebar-bg: linear-gradient(180deg, #8f6e52 0%, #b08968 100%); }
[data-palette="ocean"]  { --sidebar-bg: linear-gradient(180deg, #0369a1 0%, #0284c7 100%); }
[data-palette="musgo"]  { --sidebar-bg: linear-gradient(180deg, #587058 0%, #6e8b6e 100%); }
[data-palette="malva"]  { --sidebar-bg: linear-gradient(180deg, #835764 0%, #a06f7e 100%); }
[data-palette="rose"]   { --sidebar-bg: linear-gradient(180deg, #be185d 0%, #db2777 100%); }

[data-theme="dark"][data-palette="arena"]  { --sidebar-bg: linear-gradient(180deg, #4a3a2c 0%, #5e4936 100%); }
[data-theme="dark"][data-palette="ocean"]  { --sidebar-bg: linear-gradient(180deg, #0c4a6e 0%, #075985 100%); }
[data-theme="dark"][data-palette="musgo"]  { --sidebar-bg: linear-gradient(180deg, #2f3d2f 0%, #3e503e 100%); }
[data-theme="dark"][data-palette="malva"]  { --sidebar-bg: linear-gradient(180deg, #4a3038 0%, #5e3c47 100%); }
[data-theme="dark"][data-palette="rose"]   { --sidebar-bg: linear-gradient(180deg, #831843 0%, #9d174d 100%); }

/* ============================================================
   GRADIENTE DE BANNERS POR PALETA
   dashboards.css define --gradient-primary-banner con teal fijo.
   Aqui se sobrescribe para que siga a la paleta.
   ============================================================ */
[data-palette="arena"]  { --gradient-primary-banner: linear-gradient(135deg, #b08968 0%, #8f6e52 50%, #6f5640 100%); }
[data-palette="ocean"]  { --gradient-primary-banner: linear-gradient(135deg, #0284c7 0%, #0369a1 50%, #075985 100%); }
[data-palette="musgo"]  { --gradient-primary-banner: linear-gradient(135deg, #6e8b6e 0%, #587058 50%, #455845 100%); }
[data-palette="malva"]  { --gradient-primary-banner: linear-gradient(135deg, #a06f7e 0%, #835764 50%, #66434e 100%); }
[data-palette="rose"]   { --gradient-primary-banner: linear-gradient(135deg, #db2777 0%, #be185d 50%, #9d174d 100%); }

/* ============================================================
   PANEL DEL THEME MANAGER
   ============================================================ */
.theme-manager-dropdown {
    width: 280px;
    padding: 16px;
}

.theme-manager-dropdown .tm-section-title {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.theme-manager-dropdown .tm-section + .tm-section {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

/* --- Selector de modo claro/oscuro --- */
.tm-mode-row {
    display: flex;
    gap: 8px;
}

.tm-mode-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.tm-mode-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.tm-mode-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

/* --- Cuadricula de paletas --- */
.tm-palette-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.tm-palette-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 4px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-card);
    cursor: pointer;
    transition: var(--transition);
}

.tm-palette-btn:hover {
    border-color: var(--text-muted);
}

.tm-palette-btn.active {
    border-color: var(--primary);
    background: var(--primary-50);
}

.tm-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.tm-swatch.teal   { background: #0d9488; }
.tm-swatch.ocean  { background: #0284c7; }
.tm-swatch.rose   { background: #db2777; }
.tm-swatch.arena  { background: #b08968; }
.tm-swatch.musgo  { background: #6e8b6e; }
.tm-swatch.malva  { background: #a06f7e; }

.tm-palette-name {
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.tm-palette-btn.active .tm-palette-name {
    color: var(--primary);
}

/* ============================================================
   ===  NAVBAR / HEADER  ===
   CSS del navbar, migrado desde el <style> inline de navbar.php.
   Todo con variables: el header toma el color de la paleta.
   ============================================================ */
.navbar-top {
    background: var(--sidebar-bg);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: none;
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: 60px;
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mobile-toggle {
    display: none;
    width: 44px;
    height: 44px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    font-size: 1.5rem;
    color: #ffffff;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.mobile-toggle:active {
    background: rgba(255, 255, 255, 0.28);
    transform: scale(0.95);
}

.navbar-title {
    font-size: 1rem;
    font-weight: 500;
    color: #ffffff;
    white-space: nowrap;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* --- Theme toggle / boton de paleta --- */
.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.28);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.4);
}

.theme-toggle:active {
    transform: scale(0.95);
}

.theme-icon-dark { display: none; }
.theme-icon-light { display: block; }

[data-theme="dark"] .theme-icon-dark { display: block; }
[data-theme="dark"] .theme-icon-light { display: none; }

/* --- Iconos de notificacion / mensajes --- */
.nav-icon-btn {
    position: relative;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    flex-shrink: 0;
}

.nav-icon-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

.nav-icon-btn i {
    font-size: 1.2rem;
}

/* Boton de cerrar sesion: se distingue con un toque rojo al pasar */
.nav-logout-btn:hover {
    background: rgba(239, 68, 68, 0.9);
    color: #ffffff;
}

.badge-count {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 18px;
    height: 18px;
    background: var(--danger);
    border-radius: 9px;
    font-size: 0.65rem;
    font-weight: 600;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid transparent;
}

/* --- Dropdown de notificaciones --- */
.notifications-dropdown {
    width: 320px;
    max-height: 400px;
    overflow-y: auto;
}

.notifications-dropdown .dropdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
}

.notification-item {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    text-decoration: none;
    color: inherit;
}

.notification-item:hover {
    background: var(--bg-card-hover);
}

.notification-item.unread {
    background: var(--primary-50);
}

.notification-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.notification-icon.evento  { background: var(--accent-blue-bg);   color: var(--accent-blue); }
.notification-icon.curso   { background: var(--accent-green-bg);  color: var(--accent-green); }
.notification-icon.mensaje { background: var(--accent-orange-bg); color: var(--accent-orange); }
.notification-icon.sistema { background: var(--border-color);     color: var(--text-muted); }

.notification-content { flex: 1; min-width: 0; }
.notification-title { font-size: 0.85rem; font-weight: 500; color: var(--text-primary); margin-bottom: 2px; }
.notification-text { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notification-time { font-size: 0.7rem; color: var(--text-light); margin-top: 4px; }

/* --- Menu de usuario --- */
.user-dropdown {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
}

.user-dropdown:hover {
    background: rgba(255, 255, 255, 0.15);
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-weight: 600;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.user-info { text-align: left; min-width: 0; }
.user-name {
    font-weight: 500;
    font-size: 0.85rem;
    color: #ffffff;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}
.user-role { font-size: 0.7rem; color: rgba(255, 255, 255, 0.7); }
.user-dropdown .bi-chevron-down { color: rgba(255, 255, 255, 0.7); font-size: 0.8rem; }

/* --- Responsive del navbar --- */
@media (max-width: 992px) {
    .mobile-toggle {
        display: flex !important;
    }
}

@media (max-width: 768px) {
    .navbar-top { padding: 10px 12px; }
    .navbar-right { gap: 8px; }
    .user-info, .user-dropdown .bi-chevron-down { display: none; }
    .navbar-title { font-size: 0.85rem; max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
    .theme-toggle { width: 36px; height: 36px; }
}

@media (max-width: 480px) {
    .navbar-title { display: none; }
}

/* ============================================================
   ===  SIDEBAR: LOGO SVG  ===
   El contenedor del logo deja de usar un icono de fuente.
   El SVG se tiñe de blanco (va sobre el sidebar de color).
   ============================================================ */
.sidebar-logo svg {
    width: 26px;
    height: 26px;
    display: block;
}

.sidebar-logo svg path,
.sidebar-logo svg circle {
    fill: #ffffff;
}

/* ============================================================
   ===  SIDEBAR: BOTON DE COLAPSAR (en el header)  ===
   El boton vive junto a la marca PREVAED, arriba.
   El icono comunica el estado: panel abierto vs cerrado.
   ============================================================ */
.sidebar-collapse-btn {
    margin-left: auto;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.12);
    border: none;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    font-size: 1.1rem;
    transition: background 0.2s, color 0.2s;
}

.sidebar-collapse-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

/* Cuando el sidebar esta colapsado, el icono se voltea para
   indicar "expandir" en vez de "contraer" */
.sidebar.collapsed .sidebar-collapse-btn i {
    transform: scaleX(-1);
}

/* En sidebar colapsado el header se centra y el boton se
   reubica debajo del logo para que siga siendo accesible */
.sidebar.collapsed .sidebar-header {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.sidebar.collapsed .sidebar-collapse-btn {
    margin-left: 0;
}

/* En movil el boton de colapsar no aplica (el sidebar se
   oculta del todo, no se contrae a iconos) */
@media (max-width: 992px) {
    .sidebar-collapse-btn {
        display: none;
    }
}

/* ============================================================
   ===  SIDEBAR: GRUPOS COLAPSABLES (submenus)  ===
   Los .menu-header pasan a ser botones que abren/cierran su
   grupo de enlaces.
   ============================================================ */
.menu-group {
    margin-bottom: 2px;
}

/* El header del grupo, ahora clicable */
.menu-group-toggle {
    display: flex;
    align-items: center;
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 14px 12px 8px;
    transition: color 0.2s;
}

.menu-group-toggle:hover {
    color: rgba(255, 255, 255, 0.85);
}

.menu-group-toggle .group-label {
    flex: 1;
    text-align: left;
    white-space: nowrap;
}

.menu-group-toggle .group-chevron {
    font-size: 0.9rem;
    transition: transform 0.25s ease;
}

/* Grupo cerrado: rota el chevron y oculta los enlaces */
.menu-group.collapsed .group-chevron {
    transform: rotate(-90deg);
}

.menu-group-items {
    overflow: hidden;
    max-height: 1000px;
    transition: max-height 0.3s ease;
}

.menu-group.collapsed .menu-group-items {
    max-height: 0;
}

/* En sidebar colapsado (modo iconos) los headers se ocultan
   y los grupos se muestran siempre abiertos */
.sidebar.collapsed .menu-group-toggle {
    display: none;
}

.sidebar.collapsed .menu-group-items {
    max-height: none !important;
}

/* ============================================================
   ===  SIDEBAR: ICONOS CON COLOR POR SECCION  ===
   Cada grupo tiene un color de acento. El icono lleva un
   fondo redondeado tenue con ese color.
   ============================================================ */
.sidebar-menu a i {
    border-radius: 8px;
    padding: 5px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

/* Colores de acento por seccion (data-accent en el grupo) */
.menu-group[data-accent="principal"]   .sidebar-menu a i,
.menu-group[data-accent="principal"]   > .menu-group-items a i { background: rgba(255,255,255,0.12); color: #ffffff; }
.menu-group[data-accent="gestion"]     a i { background: rgba(96, 165, 250, 0.22);  color: #bfdbfe; }
.menu-group[data-accent="contenido"]   a i { background: rgba(52, 211, 153, 0.22);  color: #a7f3d0; }
.menu-group[data-accent="seguimiento"] a i { background: rgba(167, 139, 250, 0.22); color: #ddd6fe; }
.menu-group[data-accent="comunicacion"] a i { background: rgba(251, 191, 36, 0.22); color: #fde68a; }
.menu-group[data-accent="certificacion"] a i { background: rgba(251, 146, 60, 0.22); color: #fed7aa; }
.menu-group[data-accent="reportes"]    a i { background: rgba(244, 114, 182, 0.22); color: #fbcfe8; }
.menu-group[data-accent="sistema"]     a i { background: rgba(148, 163, 184, 0.25); color: #e2e8f0; }
.menu-group[data-accent="cuenta"]      a i { background: rgba(148, 163, 184, 0.25); color: #e2e8f0; }
.menu-group[data-accent="aprendizaje"] a i { background: rgba(52, 211, 153, 0.22);  color: #a7f3d0; }

/* El enlace activo: icono en blanco solido + indicador */
.sidebar-menu a.active i {
    background: rgba(255, 255, 255, 0.9) !important;
    color: var(--primary) !important;
}

/* Indicador de seccion activa: barra a la izquierda */
.sidebar-menu a.active {
    position: relative;
}

.sidebar-menu a.active::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 70%;
    background: #ffffff;
    border-radius: 0 4px 4px 0;
}

/* ============================================================
   ===  SIDEBAR: MEJORAS RESPONSIVE (movil / tablet)  ===
   ============================================================ */
@media (max-width: 992px) {
    /* Sidebar mas ancho y comodo al tacto en movil */
    .sidebar {
        width: 280px;
    }

    /* Items mas altos: objetivos tactiles >= 44px */
    .sidebar-menu a {
        padding: 14px 14px;
        font-size: 0.95rem;
    }

    .menu-group-toggle {
        padding: 16px 12px 10px;
        font-size: 0.78rem;
    }

    /* En movil el boton de colapsar no aplica: se oculta */
    .sidebar-footer .btn-collapse {
        display: none;
    }

    /* Transicion de entrada mas suave */
    .sidebar {
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    }
}

@media (max-width: 576px) {
    /* En pantallas muy chicas el sidebar ocupa casi todo */
    .sidebar {
        width: 86vw;
        max-width: 320px;
    }
}
