/* La fuente Poppins se carga vía <link> en el <head> de cada página (más
   rápido que @import, que bloquea el resto del CSS hasta resolverse). */

:root {
    --primary: #ff751f;       /* Naranja Leevo */
    --primary-hover: #f55e00;
    --primary-soft: #ffede1;        /* Tinte pálido del naranja: hovers, badges, iconos */
    --primary-soft-strong: #ffcaaa;
    --secondary: #64748b;     /* Gris Azulado */
    --text-dark: #1f2937;
    --text-muted: #64748b;
    --bg-color: #f8fafc;      /* Fondo Gris Claro de Alta Fidelidad */
    --white: #ffffff;         /* Superficie de tarjetas/paneles (no literalmente "blanco" en modo noche) */
    --input-bg: #f8fafc;
    --border-color: #e2e8f0;
    --danger: #ef4444;        /* Rojo */
    --danger-hover: #dc2626;
    --danger-soft: #fee2e2;
    --success: #10b981;       /* Verde */
    --success-soft: #f0fdf4;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 16px;
    --reading-paper: #fdfbf7;  /* Fondo cálido del lector de teoría/e-reader */
    --glass-bg: rgba(255, 255, 255, 0.78);     /* Tarjetas "cristal esmerilado" (dashboards) */
    --glass-bg-strong: rgba(255, 255, 255, 0.9);
    --glass-border: rgba(255, 255, 255, 0.85);

    /* Paleta de acento extendida: para tarjetas, chips, iconos y estadísticas
       que necesitan distinguirse entre sí (varias tarjetas de acción, varias
       clases, varios stat-cards uno junto al otro). El naranja (--primary)
       sigue siendo el único color de IDENTIDAD de marca — se reserva para
       botones principales, enlaces, foco, progreso y el logo. Estos acentos
       son para todo lo demás, así no todo el sitio se ve del mismo tono. */
    --accent-blue: #0ea5e9;
    --accent-blue-soft: rgba(14, 165, 233, 0.14);
    --accent-green: #16a34a;
    --accent-green-soft: rgba(22, 163, 74, 0.14);
    --accent-purple: #7c3aed;
    --accent-purple-soft: rgba(124, 58, 237, 0.14);
    --accent-pink: #db2777;
    --accent-pink-soft: rgba(219, 39, 119, 0.14);
    --accent-teal: #0d9488;
    --accent-teal-soft: rgba(13, 148, 136, 0.14);
    --accent-gold: #ca8a04;
    --accent-gold-soft: rgba(202, 138, 4, 0.14);
}

/* ==========================================
   MODO NOCHE
   Redefine únicamente las variables de arriba — cualquier regla del sitio
   que ya use var(--primary), var(--white), var(--border-color), etc. se
   adapta sola. Se activa poniendo data-theme="dark" en <html> (lo hace
   js/theme.js, leyendo la preferencia guardada en localStorage antes del
   primer pintado para evitar parpadeos).
========================================== */
:root[data-theme="dark"] {
    --primary: #ffa56d;
    --primary-hover: #ffbe95;
    --primary-soft: rgba(255, 165, 109, 0.16);
    --primary-soft-strong: rgba(255, 165, 109, 0.26);
    --secondary: #94a3b8;
    --text-dark: #f1f5f9;
    --text-muted: #94a3b8;
    --bg-color: #0f172a;
    --white: #1e293b;
    --input-bg: #0f172a;
    --border-color: #334155;
    --danger: #f87171;
    --danger-hover: #ef4444;
    --danger-soft: rgba(248, 113, 113, 0.16);
    --success: #34d399;
    --success-soft: rgba(52, 211, 153, 0.16);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.25);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.35), 0 2px 4px -1px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
    --reading-paper: #1e2333;
    --glass-bg: rgba(30, 41, 59, 0.72);
    --glass-bg-strong: rgba(30, 41, 59, 0.88);
    --glass-border: rgba(51, 65, 85, 0.6);

    /* Misma paleta de acento, en tonos más claros/vívidos para leerse bien
       sobre fondos oscuros (igual criterio que --primary arriba). */
    --accent-blue: #38bdf8;
    --accent-blue-soft: rgba(56, 189, 248, 0.18);
    --accent-green: #34d399;
    --accent-green-soft: rgba(52, 211, 153, 0.18);
    --accent-purple: #a78bfa;
    --accent-purple-soft: rgba(167, 139, 250, 0.18);
    --accent-pink: #f472b6;
    --accent-pink-soft: rgba(244, 114, 182, 0.18);
    --accent-teal: #2dd4bf;
    --accent-teal-soft: rgba(45, 212, 191, 0.18);
    --accent-gold: #facc15;
    --accent-gold-soft: rgba(250, 204, 21, 0.18);
}

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

html { background-color: var(--bg-color); }

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-dark);
    line-height: 1.6;
    transition: background-color 0.25s ease, color 0.25s ease;
}

/* ==========================================
   LAYOUT, CONTENEDORES Y ESTRUCTURA GLOBAL
========================================== */
.container-md { max-width: 900px; margin: 2rem auto; padding: 0 20px; }
.container-lg { max-width: 1100px; margin: 0 auto; padding: 0 20px 40px; }
.dashboard-content { max-width: 1200px; margin: 40px auto; padding: 0 20px; }

/* Cabeceras de Páginas */
.page-header-premium {
    background: #1e293b;
    color: white;
    padding: 3rem 2rem;
    text-align: center;
    border-radius: 0 0 30px 30px;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-md);
}
.page-header-premium h1 { font-size: 2.5rem; margin-bottom: 0.5rem; font-weight: 700; }
.page-header-premium p { color: #cbd5e1; font-size: 1.1rem; margin: 0; }

/* Tarjetas Informativas de Encabezado */
.header-card {
    display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 15px;
    padding: 2rem; border-left: 6px solid var(--primary); margin-bottom: 2rem;
    background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.header-card h1 { margin: 0; font-size: 2rem; color: var(--text-dark); }

.section-header-bar {
    display: flex; align-items: center; justify-content: space-between; margin-bottom: 2rem;
    background: var(--white); padding: 1.5rem; border-radius: 16px; box-shadow: var(--shadow-sm);
}
.card-header-title { background: var(--input-bg); padding: 1.5rem; border-bottom: 1px solid var(--border-color); }
.card-header-title h3 { margin: 0; color: var(--text-dark); font-size: 1.2rem; }

/* ==========================================
   LOGO ADAPTABLE A MODO DÍA/NOCHE
   Dos <img> superpuestas (versión día/noche del logo) que se funden entre sí
   por opacidad cuando cambia data-theme en <html>. Sin parpadeo al cargar
   la página (data-theme ya queda fijado antes del primer pintado, ver
   js/theme.js) y con transición suave cuando el usuario alterna el tema a
   mano desde el botón flotante.
========================================== */
.brand-logo { position: relative; display: inline-flex; align-items: center; }
.brand-logo img { display: block; transition: opacity 0.35s ease; }
.brand-logo .brand-logo-dark { position: absolute; left: 0; top: 0; opacity: 0; }
.brand-logo .brand-logo-light { opacity: 1; }
:root[data-theme="dark"] .brand-logo .brand-logo-light { opacity: 0; }
:root[data-theme="dark"] .brand-logo .brand-logo-dark { opacity: 1; }

/* ==========================================
   COMPONENTES DE NAVEGACIÓN Y NAVBAR
========================================== */
.navbar {
    background: var(--white); min-height: 70px; display: flex; align-items: center;
    justify-content: center; box-shadow: var(--shadow-sm); position: sticky; top: 0; z-index: 100;
}
.nav-container {
    width: 100%; max-width: 1200px; padding: 10px 20px; display: flex; justify-content: space-between;
    align-items: center; flex-wrap: wrap; row-gap: 10px;
}
.logo { font-size: 1.5rem; font-weight: 700; color: var(--text-dark); text-decoration: none; }
.logo span { color: var(--primary); }
/* Antes solo envolvía en varias líneas por debajo de 640px (pensado para
   celulares) — pero el zoom del navegador reduce el ancho EFECTIVO de la
   página igual que una pantalla angosta, y a niveles de zoom intermedios
   este grupo (idioma + notificaciones + usuario + botones) no entraba en
   una sola línea ni tampoco activaba ese breakpoint: el contenido se salía
   del navbar (con height fijo, no podía crecer) en vez de acomodarse. Ahora
   envuelve siempre que hace falta, a cualquier ancho o nivel de zoom. */
.nav-right { display: flex; align-items: center; gap: 15px; flex-wrap: wrap; justify-content: flex-end; row-gap: 8px; }

/* Logo clicable en la barra superior: vuelve al dashboard principal del rol */
.navbar-logo-btn {
    cursor: pointer; border: none; background: none; padding: 0; font: inherit;
    display: inline-flex; align-items: center; transition: opacity 0.2s ease, transform 0.2s ease;
}
.navbar-logo-btn:hover { opacity: 0.75; transform: translateY(-1px); }

.user-badge {
    font-size: 0.9rem; font-weight: 500; padding: 6px 12px; background: var(--input-bg); color: var(--text-dark); border-radius: 50px;
}

/* Nombre de la institución en la barra superior (estudiante y profesor) */
.navbar-divider { width: 1px; height: 22px; background: var(--border-color); flex-shrink: 0; }
.institution-badge {
    display: inline-flex; align-items: center; gap: 7px;
    background: var(--input-bg); border: 1px solid var(--border-color); color: var(--text-muted);
    padding: 6px 14px; border-radius: 50px; font-size: 0.85rem; font-weight: 600;
    max-width: 220px; cursor: default;
    transition: background 0.25s ease, border-color 0.25s ease, color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}
.institution-badge [data-lucide] { flex-shrink: 0; width: 15px; height: 15px; }
.institution-badge span.institution-badge-nombre { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.institution-badge:hover {
    background: var(--primary-soft); border-color: var(--primary-soft-strong); color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 6px 14px -4px rgba(255, 117, 31, 0.35);
}
@media (max-width: 640px) {
    .navbar-divider { display: none; }
    .institution-badge { max-width: 160px; }

    /* El grupo de la derecha ya no se desborda (ver .nav-right arriba), pero
       en un celular real sigue siendo mucho: idioma + notificaciones +
       nombre de usuario + "My Account" + "Log Out" con texto completo se ve
       apretado aunque quepa envuelto en varias líneas. En pantallas chicas
       se deja solo lo esencial: el nombre de usuario en texto plano es
       redundante con el botón "My Account" (que además ya muestra el
       nombre real dentro del modal), y los dos botones quedan solo con su
       ícono en vez de ícono + texto. */
    #user-name-display { display: none; }
    #btn-mi-cuenta span:last-child,
    #btn-logout span:last-child { display: none; }
    #btn-mi-cuenta, #btn-logout { padding: 8px; }
}
.lang-selector {
    border: 1px solid var(--border-color); border-radius: 20px; padding: 5px 10px; cursor: pointer; background: var(--white);
}

/* El envolvido en varias líneas de .navbar/.nav-container/.nav-right ahora
   es el comportamiento base (ver arriba) — antes solo pasaba por debajo de
   los 640px, pensado para celulares, pero el zoom del navegador angosta el
   ancho EFECTIVO de la página igual que una pantalla pequeña, así que a
   niveles de zoom intermedios el contenido se salía sin activar ese
   breakpoint. Ya no hace falta repetirlo aquí para ningún ancho.
*/

/* ==========================================
   SISTEMA DE CUADRÍCULAS Y TARJETAS PREMIUM
========================================== */
.premium-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 25px; margin-top: 1rem; width: 100%; }

.premium-card {
    background: var(--white); border: 1px solid var(--border-color); border-radius: 20px; padding: 1.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); cursor: pointer; display: flex; flex-direction: column;
    justify-content: space-between; border-top: 6px solid var(--primary); min-height: 200px; position: relative; overflow: hidden;
    box-shadow: var(--shadow-sm); text-align: left;
}
.premium-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); border-color: var(--primary); }

.premium-card-dashed {
    border: 2px dashed var(--border-color); background: transparent; border-radius: 20px;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    min-height: 200px; cursor: pointer; transition: all 0.3s ease; text-align: center; padding: 20px;
}
.premium-card-dashed:hover { border-color: var(--primary); background: var(--primary-soft); transform: translateY(-5px); box-shadow: 0 10px 15px -3px rgba(255, 117, 31, 0.1); }
.premium-card-dashed .icon-circle {
    font-size: 2.5rem; color: var(--primary); margin-bottom: 15px; background: var(--white);
    width: 65px; height: 65px; border-radius: 50%; display: flex; justify-content: center; align-items: center; box-shadow: var(--shadow-sm); transition: transform 0.3s ease;
}
.premium-card-dashed:hover .icon-circle { transform: scale(1.1); }

.card { background: var(--white); border-radius: 12px; box-shadow: var(--shadow-md); padding: 2rem; }

/* ==========================================
   FORMULARIOS, BOTONES E INPUTS
========================================== */
.input-group { margin-bottom: 1.2rem; text-align: left; }
.input-group label { display: block; margin-bottom: 0.5rem; font-weight: 500; font-size: 0.9rem; }
input, select, textarea {
    width: 100%; padding: 12px 16px; border: 2px solid var(--border-color); border-radius: 10px;
    font-size: 1rem; font-family: inherit; transition: 0.3s; background: var(--input-bg); color: var(--text-dark);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); background: var(--white); box-shadow: 0 0 0 4px rgba(255, 117, 31, 0.1); }

/* Edge (y navegadores basados en Chromium con la misma función) agregan su
   propio ícono nativo de "mostrar contraseña" DENTRO del campo — se monta
   encima del botón de ojo propio del sitio (login.html, register.html,
   account_modal.js) y se ven dos íconos superpuestos. Se desactiva el nativo
   para que solo quede el del sitio, que sí se puede tocar/traducir/estilizar. */
input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear { display: none; }

.btn-primary {
    background-color: var(--primary); color: white; padding: 12px 24px; border: none; border-radius: 10px;
    font-weight: 600; cursor: pointer; transition: 0.2s; width: 100%;
}
.btn-primary:hover { background-color: var(--primary-hover); transform: translateY(-2px); }

.btn-secondary { background-color: var(--input-bg); color: var(--text-dark); border: 1px solid var(--border-color); padding: 10px; border-radius: 10px; cursor: pointer; }
.btn-logout { background: var(--danger); color: white; border: none; padding: 8px 16px; border-radius: 8px; cursor: pointer; }
.btn-logout:hover { background: var(--danger-hover); }

/* Botón Premium de Retorno / Volver */
.btn-return {
    display: inline-flex; align-items: center; gap: 8px; padding: 10px 22px; background-color: var(--white); color: var(--text-muted);
    border: 1.5px solid var(--border-color); border-radius: 50px; font-size: 0.95rem; font-weight: 600; cursor: pointer; transition: all 0.3s ease;
}
.btn-return:hover { background-color: var(--primary-soft); color: var(--primary); border-color: var(--primary-soft-strong); transform: translateX(-4px); box-shadow: 0 6px 12px rgba(255, 117, 31, 0.1); }
.btn-return .arrow { transition: transform 0.3s ease; }
.btn-return:hover .arrow { transform: translateX(-4px); }

/* Botones Especiales de Acción Pequeños (Editar/Borrar) */
.btn-action-sm { padding: 6px 12px; border-radius: 8px; font-size: 0.85rem; font-weight: 600; cursor: pointer; transition: all 0.2s; border: none; display: flex; align-items: center; gap: 5px; }
.btn-edit { background: var(--primary-soft); color: var(--primary); }
.btn-edit:hover { background: var(--primary); color: white; }
.btn-delete { background: var(--danger-soft); color: var(--danger); }
.btn-delete:hover { background: var(--danger); color: white; }
.btn-secondary-outline { background: var(--white); border: 2px solid var(--primary); color: var(--primary); padding: 10px 20px; border-radius: 12px; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.btn-secondary-outline:hover { background: var(--primary-soft); }

/* Botón Peligro (Cerrar Periodo) */
/* ==========================================
   BOTÓN PELIGRO LIMPIO Y MINIMALISTA
========================================== */
.btn-danger-clean {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--danger-soft);
    color: var(--danger);
    padding: 10px 20px;
    border-radius: 12px; /* Bordes redondeados consistentes con las tarjetas */
    font-size: 0.95rem;
    font-weight: 600;
    border: 1.5px solid var(--danger-soft);
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Poppins', sans-serif;
}

.btn-danger-clean:hover {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

.btn-danger-clean svg {
    transition: transform 0.3s ease;
}

.btn-danger-clean:hover svg {
    transform: scale(1.1);
}

/* ==========================================
   ESTILOS DE VISTAS ESPECÍFICAS (MÓDULOS)
========================================== */
/* Gestión de Estudiantes e Inventario */
.student-item { background: var(--white); padding: 15px 20px; border-bottom: 1px solid var(--border-color); display: flex; align-items: center; gap: 15px; }
.student-item:last-child { border-bottom: none; }
.avatar-circle { width: 40px; height: 40px; background: var(--primary-soft-strong); color: var(--primary); border-radius: 50%; display: flex; justify-content: center; align-items: center; font-weight: bold; }
.dashed-box-container { background: var(--input-bg); padding: 1.5rem; border-radius: 12px; border: 1px dashed var(--border-color); margin-top: 1.5rem; }

/* Actividades Interactiva V/F & Quiz */
.activity-viewport { min-height: calc(100vh - 70px); display: flex; align-items: center; justify-content: center; padding: 20px; }
.option-btn { background: var(--white); color: var(--text-dark); border: 2px solid var(--border-color); padding: 18px; border-radius: 16px; font-size: 1rem; font-weight: 500; cursor: pointer; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); text-align: left; display: flex; align-items: center; gap: 15px; }
.option-btn:hover { border-color: var(--primary); background: var(--primary-soft); transform: translateX(5px); }
.progress-dot-container { height: 8px; background: var(--border-color); border-radius: 10px; flex-grow: 1; overflow: hidden; display: flex; }
.progress-inner-fill { height: 100%; background: var(--primary); width: 0%; transition: width 0.5s ease; }

/* Glosario y Vocabulario */
.vocab-container { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 15px; }
.vocab-tag { background: var(--primary-soft-strong); color: var(--primary); padding: 6px 12px; border-radius: 20px; font-size: 0.9rem; font-weight: 500; display: flex; align-items: center; gap: 8px; border: 1px solid var(--primary-soft-strong); }
.vocab-tag span { cursor: pointer; font-weight: bold; font-size: 1.1rem; line-height: 1; }
.vocab-tag span:hover { color: var(--danger); }

/* E-Reader / Modal de Teoría de Lecciones */
.theory-modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 23, 42, 0.85); justify-content: center; align-items: center; z-index: 1000; backdrop-filter: blur(8px); }
.theory-content { background: var(--reading-paper); color: var(--text-dark); padding: 4rem; border-radius: 24px; width: 95%; max-width: 800px; height: 90vh; overflow-y: auto; position: relative; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5); scrollbar-width: thin; scrollbar-color: var(--border-color) transparent; }
.close-btn { position: sticky; top: 0; right: 0; float: right; font-size: 1.5rem; cursor: pointer; background: var(--white); color: var(--text-dark); width: 45px; height: 45px; border-radius: 50%; display: flex; justify-content: center; align-items: center; box-shadow: 0 4px 6px rgba(0,0,0,0.1); transition: all 0.2s; }
.close-btn:hover { background: var(--danger-soft); color: var(--danger); }

/* ==========================================
   ESTADOS VISUALES DINÁMICOS Y ANIMACIONES
========================================== */
.empty-state-box { grid-column: 1 / -1; text-align: center; padding: 4rem 2rem; background: var(--white); border-radius: 20px; border: 2px dashed var(--border-color); }
.loading-state-box { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--secondary); padding: 4rem; }
.spinner { width: 40px; height: 40px; border: 4px solid var(--border-color); border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
/* Icono Lucide girando, para botones en estado "procesando..." */
.icon-spin { animation: spin 0.9s linear infinite; }

/* Modales e Interfaces de Registro/Login */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); display: flex; justify-content: center; align-items: center; backdrop-filter: blur(5px); z-index: 1000; }
.login-viewport { min-height: calc(100vh - 80px); display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 450px; padding: 3rem 2.5rem; text-align: center; }

/* Giro de Flashcards 3D */
.flashcard-scene { width: 100%; height: 380px; perspective: 1000px; margin-bottom: 2rem; }
.flashcard-inner { position: relative; width: 100%; height: 100%; text-align: center; transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1); transform-style: preserve-3d; cursor: pointer; }
.flashcard-inner.is-flipped { transform: rotateY(180deg); }
.flashcard-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; justify-content: center; align-items: center; border-radius: 24px; padding: 2rem; box-shadow: var(--shadow-md); border: 1px solid var(--border-color); color: var(--text-dark); }
.flashcard-front { background: var(--white); border-top: 8px solid var(--primary); }
.flashcard-back { background: var(--input-bg); border-top: 8px solid #16a34a; transform: rotateY(180deg); }

/* ==========================================
   ESTILOS RECUPERADOS (DASHBOARD Y HOME)
========================================== */

/* Animaciones Globales */
@keyframes fadeIn { 
    from { opacity: 0; transform: translateY(10px); } 
    to { opacity: 1; transform: translateY(0); } 
}

/* Contenedores del Estudiante en Dashboard */
.modulo-contenedor {
    background: var(--white); 
    padding: 2rem; 
    border-radius: var(--radius);
    box-shadow: var(--shadow-md); 
    animation: fadeIn 0.4s ease-out;
}

/* Grilla de la página de inicio (index.html) */
.mosaico-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem; 
    margin-bottom: 3rem;
}
.mosaico-grid.compact { 
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); 
    gap: 1rem; 
}

/* Tarjetas de características (index.html) */
.feature-card {
    background: var(--white); 
    padding: 2rem;
    border-radius: var(--radius); 
    box-shadow: var(--shadow-md);
    cursor: pointer; 
    transition: all 0.3s ease;
    border: 1px solid transparent;
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    text-align: center;
}
.feature-card:hover {
    transform: translateY(-5px); 
    box-shadow: var(--shadow-lg); 
    border-color: var(--primary);
}
.feature-card .icon {
    font-size: 2.5rem; 
    margin-bottom: 1rem;
    width: 70px; 
    height: 70px; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    border-radius: 50%;
}

/* Específicos para auth si usas auth-body */
.auth-body {
    display: flex; justify-content: center; align-items: center;
    min-height: 100vh; background: linear-gradient(135deg, #ffcaaa 0%, #f3f4f6 100%);
}
:root[data-theme="dark"] .auth-body {
    background: linear-gradient(135deg, #1e1b4b 0%, #0f172a 100%);
}

/* ==========================================
   FORMULARIOS PREMIUM (EDITOR DE LECCIONES)
========================================== */
/* Contenedor central más estrecho para mejor lectura */
.editor-container { max-width: 850px; margin: 0 auto; padding: 0 20px 40px; }

/* Barra superior del editor limpia y sin bordes de caja */
.editor-header-clean {
    display: flex; justify-content: space-between; align-items: center;
    padding: 2rem 0; margin-bottom: 1rem; border-bottom: 2px solid var(--border-color);
}

/* Tarjeta principal del editor flotante */
.editor-card-premium {
    background: var(--white); border-radius: 24px; padding: 3.5rem;
    box-shadow: 0 20px 40px -10px rgba(0,0,0,0.05); border: 1px solid var(--border-color);
    position: relative; overflow: hidden; margin-bottom: 2rem;
}
.editor-card-premium.primary { border-top: 8px solid var(--primary); }
.editor-card-premium.success { border-top: 8px solid var(--success); }

/* Etiquetas de los inputs más estéticas */
.label-premium {
    display: block; font-size: 0.85rem; text-transform: uppercase;
    letter-spacing: 1px; color: var(--text-muted); margin-bottom: 10px; font-weight: 700;
}

/* Inputs suaves y redondeados */
.input-premium-soft {
    width: 100%; padding: 18px 24px; border: 2px solid var(--border-color); border-radius: 16px;
    font-size: 1.05rem; font-family: 'Poppins', sans-serif; transition: all 0.3s ease;
    background: var(--input-bg); color: var(--text-dark); box-sizing: border-box;
}
.input-premium-soft:focus {
    background: var(--white); border-color: var(--primary);
    box-shadow: 0 0 0 5px rgba(255, 117, 31, 0.1); outline: none;
}

/* Contenedor del Glosario más amigable */
.glosario-box {
    background: var(--white); border: 2px dashed var(--border-color); border-radius: 20px;
    padding: 2.5rem; margin-top: 1rem; transition: all 0.3s;
}
.glosario-box:hover { border-color: var(--primary); background: var(--input-bg); }

/* Botón Circular "+" para el vocabulario */
.btn-circle-add {
    width: 60px; height: 60px; border-radius: 50%; background: var(--white);
    border: 2px solid var(--border-color); display: flex; justify-content: center;
    align-items: center; color: var(--secondary); cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); flex-shrink: 0;
}
.btn-circle-add:hover {
    border-color: var(--primary); color: var(--primary);
    transform: scale(1.05) rotate(90deg); box-shadow: 0 10px 15px -3px rgba(255, 117, 31, 0.1);
}

/* Etiquetas de vocabulario (Pills) limpias */
.vocab-pill {
    background: var(--white); color: var(--text-dark); border: 1px solid var(--border-color);
    padding: 10px 20px; border-radius: 50px; box-shadow: 0 2px 5px rgba(0,0,0,0.02);
    font-weight: 500; display: inline-flex; align-items: center; gap: 10px; font-size: 0.95rem;
}
.vocab-pill span { color: var(--danger); cursor: pointer; font-size: 1.2rem; font-weight: bold; }
.vocab-pill span:hover { transform: scale(1.2); }

/* ==========================================
   DASHBOARD HERO & ICONOS PREMIUM
========================================== */
.dashboard-hero {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: white;
    padding: 3rem 4rem;
    border-radius: 24px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
    position: relative;
    overflow: hidden;
}
.dashboard-hero::before {
    content: ''; 
    position: absolute; 
    top: -50%; 
    right: -10%; 
    width: 400px; 
    height: 400px;
    background: radial-gradient(circle, rgba(255, 117, 31,0.2) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none; /* ESTA ES LA LÍNEA MÁGICA */
}
.dashboard-hero-title { font-size: 2.4rem; font-weight: 700; margin-bottom: 10px; letter-spacing: -0.5px; }
.dashboard-hero-subtitle { color: #94a3b8; font-size: 1.15rem; max-width: 600px; line-height: 1.6; }

/* Cajas de Iconos para las Tarjetas */
.icon-box-premium {
    width: 65px; height: 65px; border-radius: 18px;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 20px;
}
.icon-blue { background: #ffede1; color: #ff751f; }
.icon-orange { background: #fffbeb; color: #d97706; }
.icon-sky { background: #f0f9ff; color: #0284c7; }
.icon-green { background: #f0fdf4; color: #16a34a; }
:root[data-theme="dark"] .icon-blue { background: rgba(255, 165, 109, 0.16); color: #ffbe95; }
:root[data-theme="dark"] .icon-orange { background: rgba(217, 119, 6, 0.18); color: #fbbf24; }
:root[data-theme="dark"] .icon-sky { background: rgba(2, 132, 199, 0.2); color: #38bdf8; }
:root[data-theme="dark"] .icon-green { background: rgba(22, 163, 74, 0.18); color: #4ade80; }

/* Botón Logout Estético */
.btn-logout-premium {
    background: var(--danger-soft); color: var(--danger); border: 1.5px solid var(--danger-soft);
    padding: 10px 24px; border-radius: 50px; font-weight: 600;
    cursor: pointer; transition: all 0.3s ease; font-size: 0.95rem;
    font-family: inherit;
}
.btn-logout-premium:hover {
    background: var(--danger); color: white; border-color: var(--danger);
    box-shadow: 0 4px 12px rgba(239,68,68,0.25); transform: translateY(-2px);
}

/* ==========================================
   SELECTOR DE IDIOMA GLOBAL (EN / ES)
   Usado en el navbar de login, registro, reportes, etc.
========================================== */
.lang-control {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 15px;
}
.lang-label {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #cbd5e1;
    transition: color 0.2s ease;
    user-select: none;
}
.lang-label.active { color: var(--primary); }

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #cbd5e1;
    transition: 0.3s;
    border-radius: 999px;
}
.slider::before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.switch input:checked + .slider { background-color: var(--primary); }

/* ==========================================
   SISTEMA DE ICONOS (Lucide) — usar SIEMPRE estas clases en vez de tamaños
   sueltos, para que todos los iconos del sitio compartan grosor, tamaño y
   alineación. Los SVG de Lucide heredan color vía currentColor, así que el
   color se controla desde el elemento contenedor (botón, título, etc.).
========================================== */
[data-lucide] { display: inline-block; flex-shrink: 0; vertical-align: -3px; }
[data-lucide], .icon { width: 20px; height: 20px; stroke-width: 2; }
.icon-xs { width: 14px; height: 14px; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 28px; height: 28px; }
.icon-xl { width: 40px; height: 40px; stroke-width: 1.75; }
.icon-2xl { width: 56px; height: 56px; stroke-width: 1.5; }

/* Iconos dentro de botones/links: alineados con el texto mediante flex,
   nunca por vertical-align a mano. */
.btn-primary, .btn-secondary, .btn-return, .btn-logout, .btn-add-item {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
/* Se excluye el botón con morphing mientras hace su animación de carga/éxito
   (.cargando/.exito): ahí está deshabilitado a propósito, pero no debe verse
   atenuado ni perder el rebote (transform) que le aplica GSAP. */
.btn-primary:disabled:not(.cargando):not(.exito),
.btn-secondary:disabled, .btn-add-item:disabled {
    opacity: 0.55; cursor: not-allowed; transform: none !important;
}
.btn-morph.cargando:disabled, .btn-morph.exito:disabled { cursor: default; }

/* Círculo de icono decorativo grande (cabeceras de tarjeta, estados vacíos) */
.icon-circle-lg {
    width: 72px; height: 72px; border-radius: 50%; background: #ffede1;
    display: flex; align-items: center; justify-content: center; margin: 0 auto;
    color: var(--primary); flex-shrink: 0;
}
.icon-circle-lg [data-lucide] { width: 32px; height: 32px; }
.switch input:checked + .slider::before { transform: translateX(20px); }
.switch input:focus + .slider { box-shadow: 0 0 0 3px rgba(255, 117, 31, 0.25); }

/* ==========================================
   ANIMACIONES ESTRATÉGICAS
   Entradas suaves + microinteracciones en los puntos que más se ven (barra
   superior, cabeceras, cuadrículas de tarjetas, botones). Reglas:
   - solo se anima transform/opacity (compositan en GPU, sin reflow);
   - todas son de UNA sola pasada (nada infinito);
   - animation-fill-mode: backwards → aplican el estado inicial ANTES de
     empezar pero NO se quedan pegadas al final, así los :hover siguen
     funcionando;
   - con prefers-reduced-motion se apagan las entradas automáticas y animate.css
     (no las microinteracciones de hover) — ver el bloque final.
========================================== */
@keyframes ui-fade-up { from { opacity: 0; transform: translateY(14px); } }
@keyframes ui-fade-in { from { opacity: 0; } }
@keyframes ui-drop-in { from { opacity: 0; transform: translateY(-10px); } }
@keyframes ui-pop {
    0%  { opacity: 0; transform: scale(0.92); }
    60% { opacity: 1; transform: scale(1.02); }
    100% { transform: scale(1); }
}

/* Barra superior: baja al cargar */
.navbar { animation: ui-drop-in 0.4s ease-out backwards; }

/* Cabeceras y tarjetas grandes que se pintan una vez */
.header-card, .dashboard-hero, .page-header-premium,
.editor-card-premium, .login-card, .section-header-bar {
    animation: ui-fade-up 0.45s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

/* Cuadrículas: las tarjetas entran escalonadas (retardo tope a partir de la
   8.ª para no encadenar esperas largas en listas grandes) */
.premium-grid > *, .mosaico-grid > * {
    animation: ui-fade-up 0.4s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}
.premium-grid > *:nth-child(1),  .mosaico-grid > *:nth-child(1)  { animation-delay: 0s; }
.premium-grid > *:nth-child(2),  .mosaico-grid > *:nth-child(2)  { animation-delay: 0.04s; }
.premium-grid > *:nth-child(3),  .mosaico-grid > *:nth-child(3)  { animation-delay: 0.08s; }
.premium-grid > *:nth-child(4),  .mosaico-grid > *:nth-child(4)  { animation-delay: 0.12s; }
.premium-grid > *:nth-child(5),  .mosaico-grid > *:nth-child(5)  { animation-delay: 0.16s; }
.premium-grid > *:nth-child(6),  .mosaico-grid > *:nth-child(6)  { animation-delay: 0.20s; }
.premium-grid > *:nth-child(7),  .mosaico-grid > *:nth-child(7)  { animation-delay: 0.24s; }
.premium-grid > *:nth-child(n+8), .mosaico-grid > *:nth-child(n+8) { animation-delay: 0.28s; }

/* Feedback de pulsación en los botones principales */
.btn-primary:active, .btn-secondary:active, .btn-return:active,
.btn-danger-clean:active, .btn-logout-premium:active, .btn-secondary-outline:active,
.btn-action-sm:active, .option-btn:active, .btn-circle-add:active {
    transform: scale(0.96);
}

/* ===================== VISTA PREVIA DE LECTURA (js/preview_lectura.js) =====================
   Modal "como lo ve el estudiante" del profesor, coordinador y coordinador pro. */
.lp-overlay {
    display: none; position: fixed; inset: 0; z-index: 1100;
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    overflow-y: auto; overscroll-behavior: contain;
}
.lp-overlay.lp-abierto { display: block; animation: lp-fade 0.2s ease-out; }
body.lp-sin-scroll { overflow: hidden; }
.lp-shell { max-width: 820px; margin: 0 auto; padding: 24px 20px 56px; box-sizing: border-box; }
.lp-overlay.lp-abierto .lp-card { animation: lp-subir 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); }

.lp-topbar {
    position: sticky; top: 12px; z-index: 2; margin-bottom: 16px;
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 8px 8px 8px 18px; border-radius: 999px;
    background: rgba(15, 23, 42, 0.78); border: 1px solid rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    color: #fff; box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.5);
}
.lp-topbar-label { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 0.9rem; letter-spacing: 0.01em; }
.lp-topbar-label [data-lucide], .lp-topbar-label svg { color: #ffa56d; }
.lp-cerrar {
    display: inline-flex; align-items: center; gap: 6px;
    background: rgba(255, 255, 255, 0.12); color: #fff; border: none;
    padding: 9px 16px; border-radius: 999px; cursor: pointer;
    font-family: inherit; font-weight: 600; font-size: 0.85rem; white-space: nowrap;
    transition: background 0.2s ease;
}
.lp-cerrar:hover { background: rgba(255, 255, 255, 0.22); }
.lp-cerrar:focus-visible { outline: 2px solid #ffa56d; outline-offset: 2px; }

.lp-card {
    background: var(--reading-paper); border-radius: 24px; overflow: hidden;
    box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.6);
}

/* Portada a lo ancho con el título encima, sobre un degradado para que se lea
   con cualquier imagen. */
.lp-hero { position: relative; min-height: 300px; display: flex; align-items: flex-end; background: #0f172a; }
.lp-portada { position: absolute; inset: 0; background-size: cover; background-position: center; }
.lp-hero::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0) 30%, rgba(15, 23, 42, 0.55) 62%, rgba(15, 23, 42, 0.92) 100%);
}
.lp-hero-info { position: relative; z-index: 1; width: 100%; padding: 110px 44px 30px; box-sizing: border-box; }
.lp-titulo {
    margin: 12px 0 0; color: #fff; font-family: 'Poppins', sans-serif;
    font-size: 2.4rem; font-weight: 700; line-height: 1.15; letter-spacing: -0.01em;
    text-shadow: 0 2px 16px rgba(0, 0, 0, 0.35); overflow-wrap: anywhere;
}
.lp-meta { display: flex; flex-wrap: wrap; gap: 8px; }
.lp-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 12px; border-radius: 999px; font-size: 0.8rem; font-weight: 600;
    background: rgba(255, 255, 255, 0.16); color: #fff; border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.lp-chip-nivel { background: var(--primary); border-color: transparent; }
:root[data-theme="dark"] .lp-chip-nivel { background: #f55e00; }

.lp-cuerpo { padding: 40px 56px 48px; }
.lp-texto {
    font-family: 'Lora', Georgia, 'Times New Roman', serif; font-size: 1.18rem; line-height: 1.85;
    color: var(--text-dark); max-width: 64ch; margin: 0 auto;
}
.lp-texto p { margin: 0 0 1.2em; }
.lp-texto p:last-child { margin-bottom: 0; }
.lp-texto p:first-child::first-letter {
    float: left; font-family: 'Poppins', sans-serif; font-weight: 700;
    font-size: 3.4em; line-height: 0.9; margin: 0.06em 0.1em 0 0; color: var(--primary);
}
.lp-vacio { color: var(--text-muted); font-style: italic; margin: 0; }
.lp-texto .lp-vacio::first-letter { float: none; font: inherit; color: inherit; margin: 0; }

.lp-ejercicios {
    margin-top: 40px; padding-top: 32px; border-top: 1px solid var(--border-color);
}
.lp-seccion-cabecera { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.lp-seccion-titulo { margin: 0; font-size: 1.15rem; font-weight: 700; color: var(--text-dark); }
.lp-seccion-sub { font-size: 0.85rem; color: var(--text-muted); }
.lp-ej-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.lp-ej {
    display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center;
    padding: 14px 16px; border-radius: 16px;
    background: var(--white); border: 1px solid var(--border-color);
}
.lp-ej-icono {
    grid-row: 1 / span 2; width: 40px; height: 40px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background: var(--primary-soft); color: var(--primary-hover);
}
.lp-ej-icono svg, .lp-ej-icono [data-lucide] { width: 20px; height: 20px; }
.lp-ej-num { font-size: 1.35rem; font-weight: 700; color: var(--text-dark); line-height: 1.1; }
.lp-ej-nombre { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; line-height: 1.3; }
.lp-ver-form {
    margin-top: 20px; width: 100%;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    padding: 15px 20px; border: none; border-radius: 14px; cursor: pointer;
    background: linear-gradient(135deg, #ff8e48, #f55e00); color: #fff;
    font-family: inherit; font-weight: 600; font-size: 0.98rem;
    box-shadow: 0 10px 22px -10px rgba(245, 94, 0, 0.7);
    transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.lp-ver-form:hover { transform: translateY(-1px); box-shadow: 0 14px 26px -10px rgba(245, 94, 0, 0.75); }
.lp-ver-form:active { transform: translateY(0) scale(0.99); }
.lp-ver-form-flecha { transition: transform 0.2s ease; }
.lp-ver-form:hover .lp-ver-form-flecha { transform: translateX(3px); }

@keyframes lp-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes lp-subir { from { opacity: 0; transform: translateY(18px) scale(0.99); } to { opacity: 1; transform: none; } }

@media (max-width: 640px) {
    .lp-shell { padding: 12px 10px 32px; }
    .lp-topbar { top: 8px; padding-left: 14px; }
    .lp-topbar-label { font-size: 0.82rem; }
    .lp-card { border-radius: 18px; }
    .lp-hero { min-height: 230px; }
    .lp-hero-info { padding: 80px 20px 20px; }
    .lp-titulo { font-size: 1.65rem; }
    .lp-chip { font-size: 0.74rem; padding: 4px 10px; }
    .lp-cuerpo { padding: 26px 20px 30px; }
    .lp-texto { font-size: 1.06rem; line-height: 1.75; }
    .lp-ej-grid { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) {
    .lp-overlay.lp-abierto, .lp-overlay.lp-abierto .lp-card { animation: none; }
}

/* Utilidades para usar desde JS al insertar contenido nuevo (resultados,
   filas de una tabla, avisos...) */
.anim-fade-up { animation: ui-fade-up 0.4s cubic-bezier(0.16, 1, 0.3, 1) backwards; }
.anim-fade-in { animation: ui-fade-in 0.3s ease backwards; }
.anim-pop    { animation: ui-pop 0.35s cubic-bezier(0.16, 1, 0.3, 1) backwards; }
.anim-stagger > * { animation: ui-fade-up 0.35s cubic-bezier(0.16, 1, 0.3, 1) backwards; }
.anim-stagger > *:nth-child(1) { animation-delay: 0.03s; }
.anim-stagger > *:nth-child(2) { animation-delay: 0.06s; }
.anim-stagger > *:nth-child(3) { animation-delay: 0.09s; }
.anim-stagger > *:nth-child(4) { animation-delay: 0.12s; }
.anim-stagger > *:nth-child(5) { animation-delay: 0.15s; }
.anim-stagger > *:nth-child(6) { animation-delay: 0.18s; }
.anim-stagger > *:nth-child(n+7) { animation-delay: 0.21s; }

/* ===================== BOTÓN CON MORPHING A CARGA/ÉXITO (GSAP) =====================
   Pastilla -> círculo de carga -> marca de éxito. El ancho/alto/radio los
   anima JS con GSAP (ver js/motion.js, morphABotonCircular/iniciarCargaBoton);
   estas reglas solo deciden qué se ve dentro según la clase que ese mismo
   JS añade/quita en el botón. Requiere dos hijos:
   <span class="btn-morph-label">…</span><span class="btn-morph-spinner"></span>
   Reusado en el modal de "Unirse a una Clase", login, registro y el código de
   acceso — cualquier pantalla nueva con un botón que espera a un servidor
   debería usar este mismo componente en vez de inventar el suyo. */
.btn-morph {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    position: relative; overflow: hidden; white-space: nowrap; box-sizing: border-box;
    /* Solo color/sombra por CSS: ancho, alto, radio y escala los anima GSAP.
       Con el "transition: 0.2s" (all) de .btn-primary, el navegador iba
       0.2 s por detrás de GSAP y la página navegaba con la animación a medias. */
    transition: background-color 0.25s ease, box-shadow 0.2s ease;
}
/* Mientras es un círculo pequeño, se centra en su eje cruzado en vez de
   quedarse pegado al borde que tenía cuando era una pastilla de 100% de
   ancho — sin esto, un botón dentro de un formulario en columna (login,
   registro, código de acceso) "salta" hacia la izquierda al encogerse. */
.btn-morph.cargando, .btn-morph.exito { align-self: center; }
.btn-morph .btn-morph-spinner {
    width: 19px; height: 19px; border-radius: 50%; flex-shrink: 0; display: none;
    align-items: center; justify-content: center; font-size: 0; color: #fff;
    border: 2.5px solid rgba(255,255,255,0.35); border-top-color: #fff;
    animation: btn-morph-girar 0.7s linear infinite;
}
.btn-morph.cargando .btn-morph-spinner,
.btn-morph.exito .btn-morph-spinner { display: flex; }
.btn-morph.cargando .btn-morph-label,
.btn-morph.exito .btn-morph-label { display: none; }
.btn-morph.exito { background: #16a34a; }
.btn-morph.exito .btn-morph-spinner { border: none; animation: none; font-size: 12px; font-weight: 900; }
.btn-morph.exito .btn-morph-spinner::before { content: '✓'; }
@keyframes btn-morph-girar { to { transform: rotate(360deg); } }

/* ===================== CÓDIGO SEGMENTADO (una casilla por carácter) =====================
   Ver js/motion.js -> crearInputSegmentado()/popCaracter()/sacudirError(). */
.codigo-input-grupo { display: flex; gap: 8px; justify-content: center; flex-wrap: nowrap; }
.codigo-casilla {
    flex: 1 1 0; min-width: 0; max-width: 42px; height: 54px; box-sizing: border-box;
    text-align: center; font-size: 1.3rem; font-weight: 800; font-family: 'Poppins', sans-serif;
    text-transform: uppercase; color: var(--text-dark);
    border: 2px solid var(--border-color); border-radius: 14px;
    background: var(--white); outline: none; padding: 0;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.codigo-casilla:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(255, 117, 31,0.14); }
.codigo-casilla.llena { border-color: #ffd4b9; }
.codigo-casilla.error { border-color: var(--danger); box-shadow: 0 0 0 4px rgba(239,68,68,0.12); }
@media (max-width: 480px) {
    .codigo-casilla { max-width: 32px; height: 46px; font-size: 1.1rem; }
    .codigo-input-grupo { gap: 5px; }
}

/* Menos movimiento: se apagan las ENTRADAS automáticas al cargar la página y
   las de animate.css. NO se tocan las microinteracciones deliberadas (hover de
   botones, brillo del botón de juegos) — son breves y las dispara el usuario. */
@media (prefers-reduced-motion: reduce) {
    .navbar, .header-card, .dashboard-hero, .page-header-premium,
    .editor-card-premium, .login-card, .section-header-bar,
    .premium-grid > *, .mosaico-grid > *, .modulo-contenedor,
    .anim-fade-up, .anim-fade-in, .anim-pop, .anim-stagger > *,
    .btn-morph-spinner,
    [class*="animate__"] {
        animation: none !important;
    }
    html { scroll-behavior: auto !important; }
}

/* ==========================================
   RESPONSIVE GLOBAL — MÓVIL Y TABLET
   Las páginas se diseñaron mirando el escritorio: cabeceras con mucho aire,
   tipografías grandes y tarjetas con padding generoso. En un celular real
   (~360–420px) eso deja el contenido apretado contra los bordes, con títulos
   que se cortan y, cuando hay tablas, scroll horizontal de toda la página.
   Este bloque ajusta SOLO los componentes compartidos; cada página añade sus
   propios retoques en su <style>. Nada de esto afecta al escritorio.
========================================== */
@media (max-width: 768px) {
    /* Contenedores: menos margen y padding lateral para ganar ancho útil */
    .container-md { margin: 1.25rem auto; padding: 0 16px; }
    .container-lg { padding: 0 16px 28px; }
    .dashboard-content { margin: 24px auto; padding: 0 16px; }
    .editor-container { padding: 0 16px 28px; }

    /* Cabecera oscura tipo "hero" de los paneles */
    .dashboard-hero { padding: 2rem 1.5rem; border-radius: 20px; margin-bottom: 2rem; }
    .dashboard-hero-title { font-size: 1.7rem; }
    .dashboard-hero-subtitle { font-size: 1rem; }
    .dashboard-hero::before { width: 220px; height: 220px; }

    /* Cabecera clara con borde izquierdo */
    .header-card { padding: 1.4rem 1.2rem; margin-bottom: 1.5rem; }
    .header-card h1 { font-size: 1.5rem; }

    /* Cabecera con fondo azul marino y esquinas redondeadas abajo */
    .page-header-premium { padding: 2rem 1.25rem; border-radius: 0 0 22px 22px; margin-bottom: 1.5rem; }
    .page-header-premium h1 { font-size: 1.6rem; }
    .page-header-premium p { font-size: 0.98rem; }

    /* Barra de sección: apila título y acción en vez de forzarlos en una línea */
    .section-header-bar { flex-direction: column; align-items: stretch; gap: 12px; padding: 1.2rem; }

    /* Editor de lecciones */
    .editor-card-premium { padding: 1.5rem 1.25rem; border-radius: 18px; }
    .editor-header-clean { padding: 1.25rem 0; flex-wrap: wrap; gap: 12px; }
    .glosario-box { padding: 1.5rem 1.25rem; }

    /* Tarjeta genérica y login */
    .card { padding: 1.5rem 1.25rem; }
    .login-viewport { padding: 16px; }
    .login-card { padding: 2.25rem 1.5rem; }

    /* Cuadrículas de tarjetas: una sola columna, con hueco más discreto */
    .premium-grid { grid-template-columns: 1fr; gap: 18px; }
    .mosaico-grid { grid-template-columns: 1fr; gap: 1.25rem; }
    .premium-card { min-height: 0; }

    /* E-reader / modal de teoría a pantalla casi completa */
    .theory-content { padding: 1.75rem 1.25rem; width: 100%; height: 92vh; border-radius: 18px; }

    /* Botón "volver": que no empuje fuera de pantalla */
    .btn-return { padding: 9px 16px; font-size: 0.9rem; }

    /* Estados vacíos / de carga: menos padding vertical */
    .empty-state-box { padding: 2.5rem 1.25rem; }
    .loading-state-box { padding: 2.5rem 1.25rem; }
}

@media (max-width: 480px) {
    .dashboard-hero-title { font-size: 1.5rem; }
    .page-header-premium h1 { font-size: 1.4rem; }
    .header-card h1 { font-size: 1.35rem; }

    /* Los pares de botones dentro de modales (Cancelar / Guardar) se apilan */
    .modal-overlay .btn-primary { width: 100%; }
}