/* 1. VARIABLES (Paleta de Colores) */
:root {
    --primary-color: #0f172a;   /* Azul oscuro profundo (Navy) */
    --secondary-color: #1e293b; /* Azul grisáceo */
    --accent-color: #f59e0b;    /* Dorado/Amarillo (Highlight) */
    --text-color: #334155;      /* Gris oscuro para texto */
    --bg-light: #f8fafc;        /* Blanco humo para fondos */
    --white: #ffffff;
    --paper-color: #fffbeb;     /* Color papel para fuentes */
    --max-width: 1200px;
    --border-radius: 12px;
}

/* 2. RESET BÁSICO */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-light);
    color: var(--text-color);
    line-height: 1.6;
}

a { text-decoration: none; color: inherit; transition: 0.3s; }
ul, ol { list-style: none; }

/* 3. COMPONENTES GLOBALES */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
}

.btn {
    display: inline-block;
    padding: 12px 25px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.3s;
    text-align: center;
    border: none; /* Asegura que no tenga borde por defecto */
}

.btn-primary {
    background-color: var(--accent-color);
    color: var(--primary-color);
    box-shadow: 0 4px 6px rgba(245, 158, 11, 0.2);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(245, 158, 11, 0.3);
    background-color: #d97706;
}

.hidden { display: none !important; } /* Utilidad para ocultar elementos */

/* 4. NAVBAR */
header {
    background-color: var(--primary-color);
    color: var(--white);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 3px solid var(--accent-color);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--white);
    letter-spacing: -0.5px;
}

.nav-links {
    display: flex;
    gap: 25px;
    align-items: center;
}

.nav-links a:hover {
    color: var(--accent-color);
}

/* 5. HERO & TEMAS (HOME) */
.hero {
    background: linear-gradient(rgba(15, 23, 42, 0.9), rgba(15, 23, 42, 0.85)), url('https://images.unsplash.com/photo-1461360370896-922624d12aa1?auto=format&fit=crop&w=1920&q=80');
    background-size: cover;
    background-position: center;
    color: var(--white);
    text-align: center;
    padding: 120px 20px;
}

.hero h1 {
    font-size: 3.5rem;
    margin-bottom: 1.5rem;
    line-height: 1.1;
    font-weight: 800;
}

.hero p {
    font-size: 1.25rem;
    margin-bottom: 2.5rem;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
    color: #cbd5e1;
}

#temas {
    padding: 5rem 20px;
}

.section-header {
    text-align: center;
    margin-bottom: 3rem;
}

.section-header h2 {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.temas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.card {
    background: var(--white);
    padding: 2.5rem;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
    border: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
}

.card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border-color: var(--accent-color);
}

.card-icon {
    font-size: 3rem;
    margin-bottom: 1.5rem;
}

.card h3 {
    color: var(--primary-color);
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.card p {
    color: #64748b;
    margin-bottom: 2rem;
    flex-grow: 1;
}

.card-link {
    color: var(--accent-color);
    font-weight: 700;
    font-size: 1.1rem;
    display: inline-flex;
    align-items: center;
}

.card-link:hover {
    margin-left: 5px;
}

/* Borde superior de colores para diferenciar ejes */
.card-chile { border-top: 5px solid #dc2626; } /* Rojo */
.card-mundo { border-top: 5px solid #2563eb; } /* Azul */
.card-ciudadana { border-top: 5px solid #8b5cf6; } /* Violeta/Morado */
.card-economia { border-top: 5px solid #10b981; } /* Verde Esmeralda */


/* 6. ESTILOS DE HERRAMIENTAS (ADAPTADOS DEL CÓDIGO VIEJO) */
.tools-menu { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-bottom: 30px; }
.tool-btn { padding: 10px 20px; background: #fff; border: 1px solid #e2e8f0; border-radius: 20px; cursor: pointer; font-weight: 600; color: var(--text-color); transition: 0.2s; }
.tool-btn:hover { background: #f1f5f9; }
.tool-btn.active { background: var(--primary-color); color: white; border-color: var(--primary-color); }

.tool-content { background: white; padding: 30px; border-radius: 12px; box-shadow: 0 4px 6px rgba(0,0,0,0.05); border: 1px solid #e2e8f0; max-width: 800px; margin: 0 auto; animation: fadeIn 0.3s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.tool-content h3 { color: var(--primary-color); margin-bottom: 20px; border-bottom: 2px solid var(--accent-color); display: inline-block; padding-bottom: 5px; }

/* Tool Instructions Box */
.tool-instructions {
    background: #f0f9ff; /* Azul muy claro */
    border-left: 4px solid #0ea5e9; /* Azul cian */
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 4px;
    font-size: 0.9rem;
    color: #334155;
}
.tool-instructions strong {
    color: #0369a1;
    display: block;
    margin-bottom: 5px;
}

/* Inputs y Botones de Herramientas */
.input-std, .textarea-std { width: 100%; padding: 10px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 1rem; margin-bottom: 10px; }
.textarea-std { height: 100px; resize: vertical; }
.input-std.small { width: 80px; text-align: center; }
.tool-controls-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 15px; margin-bottom: 20px; }
.tool-controls-grid label { display: block; font-weight: bold; font-size: 0.85rem; color: #64748b; margin-bottom: 5px; }
.btn-tool-action { width: 100%; background: var(--secondary-color); color: white; padding: 12px; border: none; border-radius: 8px; font-weight: bold; cursor: pointer; transition: 0.2s; }
.btn-tool-action:hover { background: var(--primary-color); }
.btn-tool-secondary { background: #e2e8f0; color: #475569; padding: 8px 15px; border: none; border-radius: 6px; font-weight: bold; cursor: pointer; }
.btn-text { background: none; border: none; color: #2563eb; font-weight: bold; cursor: pointer; }
.flex-row { display: flex; gap: 10px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.flex-center { display: flex; justify-content: center; align-items: center; }
.hint { font-size: 0.9rem; color: #94a3b8; margin-bottom: 10px; font-style: italic; }

/* Estilos Específicos por Herramienta */
/* Escala */
.result-box { margin-top: 20px; border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden; }
.info-tag { background: #eff6ff; color: #1e40af; text-align: center; padding: 10px; font-weight: bold; font-size: 0.9rem; }
.table-container { max-height: 300px; overflow-y: auto; }
.tabla-notas { width: 100%; border-collapse: collapse; }
.tabla-notas th { background: #f8fafc; padding: 10px; text-align: center; position: sticky; top: 0; }
.tabla-notas td { padding: 8px; text-align: center; border-bottom: 1px solid #f1f5f9; }
.nota-roja { color: #dc2626; font-weight: bold; }
.nota-azul { color: #2563eb; font-weight: bold; }

/* Sala */
.sala-grid { display: grid; gap: 10px; margin-top: 20px; padding: 10px; background: #f1f5f9; border-radius: 8px; }
.desk-slot { background: white; border: 2px dashed #cbd5e1; border-radius: 6px; min-height: 50px; display: flex; align-items: center; justify-content: center; padding: 5px; }
.student-tag { background: #fff; border-left: 4px solid var(--accent-color); padding: 5px; border-radius: 4px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); cursor: grab; font-size: 0.85rem; font-weight: bold; width: 100%; text-align: center; }

/* Cronómetro */
.crono-tabs { display: flex; border-bottom: 1px solid #e2e8f0; margin-bottom: 20px; }
.tab-btn { flex: 1; padding: 10px; background: none; border: none; cursor: pointer; font-weight: bold; color: #94a3b8; border-bottom: 3px solid transparent; }
.tab-btn.active { color: var(--primary-color); border-bottom-color: var(--accent-color); }
.time-display { font-size: 4rem; font-weight: 900; color: var(--primary-color); margin-bottom: 20px; font-variant-numeric: tabular-nums; }
.controls { display: flex; justify-content: center; gap: 15px; }
.ctrl-btn { width: 60px; height: 60px; border-radius: 50%; border: none; font-size: 1.5rem; color: white; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.ctrl-btn.start { background: #22c55e; }
.ctrl-btn.pause { background: #eab308; }
.ctrl-btn.reset { background: #ef4444; }
.time-input { width: 70px; font-size: 1.5rem; text-align: center; border: 1px solid #cbd5e1; border-radius: 6px; }

/* Grupos & Sorteo */
.groups-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-top: 20px; }
.group-card { border: 1px solid #e2e8f0; border-radius: 6px; padding: 10px; }
.group-title { font-weight: bold; text-align: center; background: #f1f5f9; font-size: 0.8rem; padding: 2px; border-radius: 4px; margin-bottom: 5px; }
.sorteo-result { margin-top: 20px; min-height: 60px; display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: center; background: #fffbeb; border-radius: 8px; padding: 10px; }
.winner-tag { background: var(--accent-color); color: var(--primary-color); padding: 5px 15px; border-radius: 20px; font-weight: bold; box-shadow: 0 2px 4px rgba(0,0,0,0.1); animation: popIn 0.3s; }
@keyframes popIn { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Sopa & Crucigrama */
.print-area { margin-top: 20px; padding: 15px; border: 1px dashed #cbd5e1; background: white; }
.sopa-grid { display: grid; border: 2px solid black; }
.sopa-cell { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; border: 1px solid #eee; font-weight: bold; text-transform: uppercase; cursor: pointer; user-select: none; }
.sopa-cell.found { background-color: #fef08a; }
.word-list { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 15px; font-family: monospace; text-transform: uppercase; justify-content: center; }
.cr-grid { display: inline-grid; border: 1px solid black; background: #000; gap: 1px; }
.cr-cell { width: 30px; height: 30px; background: white; position: relative; display: flex; align-items: center; justify-content: center; font-weight: bold; text-transform: uppercase; }
.cr-cell.empty { background: black; }
.cr-num { position: absolute; top: 1px; left: 1px; font-size: 8px; line-height: 1; font-weight: normal; }
.clues-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; text-align: left; font-size: 0.9rem; margin-top: 15px; }

/* Promedios */
.notes-list { max-height: 200px; overflow-y: auto; margin-bottom: 15px; }
.promedio-final { text-align: center; font-size: 4rem; font-weight: 900; color: #cbd5e1; margin-top: 10px; }
.promedio-final.pass { color: #2563eb; }
.promedio-final.fail { color: #dc2626; }

/* QR */
.qr-output { margin-top: 20px; display: flex; justify-content: center; }
.qr-output img { border: 1px solid #e2e8f0; padding: 10px; border-radius: 8px; }

/* Modal Mensajes */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 2000; }
.modal-content { background: white; padding: 30px; border-radius: 12px; max-width: 400px; text-align: center; box-shadow: 0 10px 25px rgba(0,0,0,0.2); }

/* 7. LAYOUT INTERNO (Sidebar) & LECCIÓN (Para los archivos de temas) */
/* Estos estilos son vitales para las páginas internas de temas/ */
.contenido-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 3rem;
    padding: 3rem 20px;
}

.sidebar {
    background: var(--white);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    border: 1px solid #e2e8f0;
    height: fit-content;
    position: sticky;
    top: 100px;
}

.sidebar h4 {
    margin: 1.5rem 0 0.8rem 0;
    color: var(--primary-color);
    font-size: 1.1rem;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 5px;
}

.sidebar h4:first-child { margin-top: 0; }

.sidebar ul li { margin-bottom: 0.8rem; }
.sidebar a { color: #64748b; font-size: 0.95rem; }
.sidebar a:hover { color: var(--accent-color); font-weight: 600; padding-left: 5px; }

/* Estilos de la Lección */
.leccion h1 { font-size: 2.5rem; color: var(--primary-color); line-height: 1.2; }
.leccion h2 { font-size: 1.8rem; color: var(--secondary-color); margin-top: 2.5rem; margin-bottom: 1rem; border-bottom: 1px solid #e2e8f0; padding-bottom: 10px; }
.leccion h3 { font-size: 1.4rem; color: #334155; margin-top: 1.5rem; margin-bottom: 0.8rem; }
.leccion p { margin-bottom: 1rem; font-size: 1.1rem; color: #475569; text-align: justify; }
.leccion ul, .leccion ol { margin-left: 20px; margin-bottom: 1rem; }
.leccion li { margin-bottom: 0.5rem; color: #475569; font-size: 1.05rem; }

/* Tip PAES */
.tip-paes { background: #fffbeb; border-left: 5px solid var(--accent-color); padding: 20px; margin: 30px 0; border-radius: 0 8px 8px 0; }
.tip-paes strong { color: #b45309; display: block; margin-bottom: 5px; font-size: 1.1rem;}

/* Laboratorio de Fuentes */
.laboratorio-fuentes { background-color: #fdf6e3; border: 1px solid #e8e0c9; padding: 25px; margin: 35px 0; border-radius: 4px; position: relative; box-shadow: 3px 3px 0px rgba(0,0,0,0.05); }
.laboratorio-fuentes::before { content: "❝"; font-size: 4rem; color: #d4c5a3; position: absolute; top: -10px; left: 20px; font-family: serif; }
.fuente-titulo { font-weight: bold; text-transform: uppercase; color: #8c7b50; font-size: 0.9rem; margin-bottom: 15px; display: block; letter-spacing: 1px; }
.fuente-texto { font-family: 'Georgia', serif; font-style: italic; font-size: 1.15rem; color: #2c2c2c; line-height: 1.8; margin-bottom: 15px; }
.fuente-autor { text-align: right; font-size: 0.95rem; color: #555; font-weight: bold; }

/* Caja Interactiva / Mini Ensayo */
.caja-interactiva { background: #f8fafc; padding: 25px; border-radius: var(--border-radius); margin: 40px 0; border: 2px solid #e2e8f0; }
.caja-interactiva h4 { color: var(--primary-color); margin-bottom: 15px; display: flex; align-items: center; gap: 10px; }
.spoiler-btn { background: var(--primary-color); color: white; border: none; padding: 10px 20px; border-radius: 6px; cursor: pointer; font-weight: 600; margin-top: 15px; transition: 0.2s; width: 100%; }
.spoiler-btn:hover { background: var(--secondary-color); }
.respuesta-oculta { display: none; margin-top: 20px; padding: 20px; background: white; border-radius: 8px; border: 1px solid #cbd5e1; color: var(--text-color); font-weight: 500; animation: fadeIn 0.3s ease-in; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }

/* 8. FOOTER & RESPONSIVE */
.features { background: var(--white); padding: 4rem 20px; border-top: 1px solid #e2e8f0; }
.features .container { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 2rem; text-align: center; }
.feature-item h3 { color: var(--primary-color); margin-bottom: 0.5rem; }
footer { background: var(--primary-color); color: #94a3b8; text-align: center; padding: 3rem 0; margin-top: auto; }
.footer-small { font-size: 0.9rem; margin-top: 0.5rem; opacity: 0.7; }

/* RESPONSIVE */
@media (max-width: 768px) {
    .nav-links { display: none; }
    .hero h1 { font-size: 2.5rem; }
    .contenido-layout { grid-template-columns: 1fr; }
    .sidebar { position: relative; top: 0; margin-bottom: 2rem; }
    
    /* Menú Hamburguesa */
    .menu-toggle { display: block; cursor: pointer; }
    .bar { display: block; width: 25px; height: 3px; margin: 5px auto; background-color: white; }
    
    /* Ajustes herramientas móvil */
    .tools-menu { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 10px; justify-content: flex-start; }
    .tool-btn { white-space: nowrap; }
}