/* =============================================================
   Sistema visual compartido — Cátedra de Administración
   Lo usan index.html y tutor.html (alumnos) y panel.html y
   admin.html (gestión). Todo sale de los tokens de :root; para
   recolorear el producto entero alcanza con tocar esa primera
   sección.
   ============================================================= */

:root {
    /* Superficies y texto */
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-muted: #f4f5f7;
    --border: #e4e6ea;
    --border-strong: #d3d7de;
    --text: #14161a;
    --text-muted: #5c626e;
    --text-subtle: #8a909c;

    /* Acento */
    --accent: #4c5bd4;
    --accent-hover: #3f4dbd;
    --accent-soft: #eef0fd;
    --accent-border: #c9cef6;

    /* Semánticos */
    --success: #0e7c5a;
    --success-soft: #ecf7f2;
    --success-border: #bfe3d5;
    --warn: #a15c07;
    --warn-soft: #fdf4e8;
    --warn-border: #f0ddbe;
    --danger: #c33c31;
    --danger-soft: #fdefed;
    --danger-border: #f3cbc6;

    /* Formas */
    --r-sm: 6px;
    --r-md: 8px;
    --r-lg: 12px;
    --r-xl: 16px;

    --shadow-sm: 0 1px 2px rgba(16, 18, 27, .04);
    --shadow-md: 0 1px 3px rgba(16, 18, 27, .06), 0 12px 28px -16px rgba(16, 18, 27, .18);
    --ring: 0 0 0 3px rgba(76, 91, 212, .18);

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ---------- Base ---------- */

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.015em; }
p { margin: 0; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
    outline: none;
    box-shadow: var(--ring);
    border-color: var(--accent) !important;
}

.hidden { display: none !important; }

/* ---------- Layout ---------- */

.page {
    width: 100%;
    max-width: 880px;
    margin: 0 auto;
    padding: 40px 20px 64px;
}

.page--narrow { max-width: 560px; }
.page--wide { max-width: 960px; }

/* Encabezado de marca, común a las dos aplicaciones */
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 28px;
}

/* Enlaces al final de la marca (p. ej. "Autoevaluaciones →"): no se achican */
.brand > a {
    flex-shrink: 0;
    white-space: nowrap;
}

.brand-name {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text);
}

/* Segundo nombre de la cátedra: mismo renglón, menos peso visual */
.brand-alt {
    font-weight: 400;
    color: var(--text-muted);
    white-space: nowrap;
}

.brand-sep {
    color: var(--border-strong);
    font-size: 14px;
}

.brand-context {
    font-size: 14px;
    color: var(--text-muted);
}

/* En pantallas angostas se esconde el "· Panel" del final, que el título de
   cada página ya repite. Los dos nombres de la cátedra se quedan: sin el
   logotipo delante entran en dos renglones. */
@media (max-width: 480px) {
    .brand-sep, .brand-context { display: none; }
    /* El segundo nombre pasa a renglón propio en vez de forzar el ancho */
    .brand-alt { white-space: normal; }
}

/* Texto que se acorta en pantallas muy angostas para que no desborde */
@media (max-width: 400px) {
    .hide-xs { display: none; }
}

/* ---------- Tipografía de contenido ---------- */

.eyebrow {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-subtle);
}

.title {
    font-size: 26px;
    line-height: 1.25;
    font-weight: 600;
}

.title-sm { font-size: 19px; font-weight: 600; }

.subtitle {
    margin-top: 6px;
    font-size: 15px;
    color: var(--text-muted);
}

.meta {
    font-size: 13px;
    color: var(--text-subtle);
    font-variant-numeric: tabular-nums;
}

/* ---------- Card ---------- */

.card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
}

.card-body { padding: 28px; }
.card-body--tight { padding: 20px; }

.card-header {
    padding: 20px 28px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.card-footer {
    padding: 16px 28px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

/* ---------- Botones ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: var(--r-md);
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    /* Los botones que en realidad son <a> traen el subrayado del navegador */
    text-decoration: none;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.btn:disabled { cursor: not-allowed; opacity: .5; }

.btn-primary {
    background-color: var(--accent);
    color: #fff;
}
.btn-primary:hover:not(:disabled) { background-color: var(--accent-hover); }

.btn-secondary {
    background-color: var(--surface);
    border-color: var(--border-strong);
    color: var(--text);
}
.btn-secondary:hover:not(:disabled) { background-color: var(--surface-muted); }

.btn-ghost {
    background-color: transparent;
    color: var(--text-muted);
    padding-left: 8px;
    padding-right: 8px;
}
.btn-ghost:hover:not(:disabled) { color: var(--text); }

.btn-lg { padding: 11px 20px; font-size: 15px; }
/* Los de ancho completo son los de las pantallas que usan los alumnos desde
   el celular: 44px es el mínimo para apretar cómodo con el pulgar. */
.btn-block { width: 100%; min-height: 44px; }

/* Iconito al principio de un botón, para reconocerlo de un vistazo. Va como
   atributo y no como <span> adentro porque varios botones se reescriben el
   texto desde JavaScript ("Guardar" → "Guardar cambios", "Copiar enlace" →
   "Copiado"), y eso se llevaría puesto cualquier elemento que hubiera dentro.
   Son emojis: no hacen falta librerías ni archivos de íconos, y el gap de
   .btn ya los separa del texto. */
.btn[data-ico]::before {
    content: attr(data-ico);
    font-size: 15px;
    line-height: 1;
}

/* ---------- Enlaces ---------- */

.link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}
.link:hover { text-decoration: underline; }

.link-muted {
    color: var(--text-subtle);
    text-decoration: none;
    font-size: 13px;
}
.link-muted:hover { color: var(--text); }

/* ---------- Formularios ---------- */

.field { margin-bottom: 16px; }

.field-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
}

.input, .select {
    width: 100%;
    padding: 10px 12px;
    background-color: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    font-size: 15px;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.input::placeholder { color: var(--text-subtle); }
.input:hover, .select:hover { border-color: #bfc4cd; }

.select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 8l3-3.5' fill='none' stroke='%238a909c' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 34px;
    cursor: pointer;
}

/* ---------- Grilla de unidades ---------- */

.unit-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

@media (min-width: 640px) { .unit-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 860px) { .unit-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.unit-tile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 14px 14px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    text-align: left;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}

.unit-tile:hover {
    border-color: var(--accent-border);
    background-color: var(--accent-soft);
    box-shadow: var(--shadow-sm);
}

.unit-tile .arrow {
    color: var(--text-subtle);
    font-size: 13px;
    transition: transform .15s ease, color .15s ease;
}

.unit-tile:hover .arrow { color: var(--accent); transform: translateX(2px); }

/* ---------- Selección de nivel ---------- */

.level-list {
    display: grid;
    gap: 10px;
}

.level-option {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    text-align: left;
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease;
}

.level-option:hover { border-color: var(--border-strong); background-color: var(--surface-muted); }

.level-option .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.level-option[data-level="facil"] .dot { background-color: var(--success); }
.level-option[data-level="normal"] .dot { background-color: var(--warn); }
.level-option[data-level="dificil"] .dot { background-color: var(--danger); }

.level-option .level-name { font-size: 14px; font-weight: 500; }
.level-option .level-desc { font-size: 13px; color: var(--text-subtle); }
.level-option .level-text { flex: 1; }
.level-option .arrow { color: var(--text-subtle); font-size: 13px; }

/* ---------- Progreso ---------- */

.progress {
    height: 4px;
    background-color: var(--surface-muted);
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0;
    background-color: var(--accent);
    border-radius: 999px;
    transition: width .3s ease;
}

/* ---------- Opciones de respuesta ---------- */

.option-list { display: grid; gap: 8px; }

.option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    padding: 13px 15px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    text-align: left;
    font-size: 15px;
    line-height: 1.5;
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease;
}

.option:hover:not(:disabled) { border-color: var(--border-strong); background-color: var(--surface-muted); }
.option:disabled { cursor: default; }

.option .marker {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    border-radius: 50%;
    border: 1px solid var(--border-strong);
    color: var(--text-subtle);
    font-size: 12px;
    font-weight: 600;
    display: grid;
    place-items: center;
    margin-top: 1px;
    transition: inherit;
}

.option.is-correct {
    border-color: var(--success-border);
    background-color: var(--success-soft);
}
.option.is-correct .marker {
    background-color: var(--success);
    border-color: var(--success);
    color: #fff;
}

.option.is-incorrect {
    border-color: var(--danger-border);
    background-color: var(--danger-soft);
}
.option.is-incorrect .marker {
    background-color: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

/* ---------- Feedback y puntaje ---------- */

.feedback {
    min-height: 22px;
    font-size: 14px;
    font-weight: 500;
}
.feedback.is-correct { color: var(--success); }
.feedback.is-incorrect { color: var(--danger); }

.score {
    font-size: 44px;
    font-weight: 600;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}

.score-caption { font-size: 14px; color: var(--text-muted); }

.answer {
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-left-width: 3px;
    border-radius: var(--r-md);
    background-color: var(--surface);
}

.answer.is-correct { border-left-color: var(--success); }
.answer.is-wrong { border-left-color: var(--danger); }

.answer-question { font-size: 14px; font-weight: 500; }
.answer-line { margin-top: 6px; font-size: 13px; color: var(--text-muted); }
.answer-line .tag { font-weight: 500; }
.answer-line.is-correct .tag { color: var(--success); }
.answer-line.is-wrong .tag { color: var(--danger); }

.scroll-y {
    max-height: 340px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}
.scroll-y::-webkit-scrollbar { width: 6px; }
.scroll-y::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }

/* ---------- Aviso al pie ---------- */

.note {
    margin-top: 20px;
    text-align: center;
    font-size: 13px;
    color: var(--text-subtle);
}

/* =============================================================
   Chat (Mintzbot)
   ============================================================= */

.chat-page {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    max-width: 720px;
    margin: 0 auto;
    padding: 24px 20px;
    gap: 16px;
}

.chat {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--border);
}

.chat-identity { flex: 1; min-width: 0; }

.chat-identity h1 {
    font-size: 15px;
    font-weight: 600;
}

.chat-identity p {
    font-size: 13px;
    color: var(--text-subtle);
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-subtle);
    flex-shrink: 0;
}

.status::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--success);
}

.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 22px 18px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

.chat-body::-webkit-scrollbar { width: 6px; }
.chat-body::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }

.turn { display: flex; flex-direction: column; gap: 6px; }
.turn-user { align-items: flex-end; }

.msg-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-subtle);
}

.msg {
    max-width: 84%;
    padding: 11px 14px;
    border-radius: var(--r-lg);
    font-size: 15px;
    line-height: 1.6;
    animation: msg-in .2s ease;
}

@keyframes msg-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
}

.msg-user {
    background-color: var(--accent);
    color: #fff;
    border-bottom-right-radius: var(--r-sm);
}

.msg-bot {
    background-color: var(--surface-muted);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: var(--r-sm);
}

.msg-bot.is-loading { color: var(--text-subtle); }

.msg-bot.is-error {
    background-color: var(--danger-soft);
    border-color: var(--danger-border);
    color: var(--danger);
}

/* Markdown dentro de las respuestas del bot */
.msg-bot > :first-child { margin-top: 0; }
.msg-bot > :last-child { margin-bottom: 0; }
.msg-bot p { margin: 0 0 10px; }
.msg-bot ul, .msg-bot ol { margin: 0 0 10px; padding-left: 20px; }
.msg-bot li { margin-bottom: 4px; }
.msg-bot strong { font-weight: 600; }
.msg-bot h1, .msg-bot h2, .msg-bot h3 { font-size: 15px; margin: 14px 0 6px; }
.msg-bot code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 13px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 4px;
}

/* Un bloque de código no corta por espacios y en un celular se sale de la
   burbuja. Que scrollee dentro suyo en vez de empujar la página. */
.msg-bot pre {
    margin: 0 0 10px;
    overflow-x: auto;
    max-width: 100%;
}
.msg-bot pre code {
    display: block;
    white-space: pre;
    border: 0;
    padding: 8px 10px;
}

/* Las tablas que devuelve el bot tampoco tienen por qué romper el ancho */
.msg-bot table { display: block; overflow-x: auto; max-width: 100%; }

.composer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.composer .input { flex: 1; }

.disclaimer {
    text-align: center;
    font-size: 12px;
    color: var(--text-subtle);
    flex-shrink: 0;
}

/* Puntos animados del "escribiendo" */
.typing::after {
    content: "";
    animation: typing-dots 1.2s steps(4, end) infinite;
}

@keyframes typing-dots {
    0% { content: ""; }
    25% { content: "."; }
    50% { content: ".."; }
    75% { content: "..."; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* =============================================================
   Pantallas de gestión (panel.html y admin.html)
   ============================================================= */

.page--app { max-width: 1180px; }

/* Barra superior: marca a la izquierda, acciones a la derecha */
.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.topbar .brand { margin-bottom: 0; flex: 1; min-width: 240px; }

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* Título de bloque */
.section {
    margin-top: 28px;
}

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.section-title {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.section-desc {
    font-size: 13px;
    color: var(--text-subtle);
}

/* ---------- Fila de filtros ---------- */
/* Una sola fila arriba de todo lo que condiciona, nunca dentro de una tarjeta */

.filters {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
    padding: 14px 16px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
}

/* Se acomodan de a dos en pantallas angostas en vez de apilarse de a uno */
.filter {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1 1 130px;
    max-width: 230px;
}

.filter > label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-subtle);
}

.filter .input, .filter .select { padding: 7px 10px; font-size: 14px; }
.filter .select { padding-right: 30px; }
.filters .spacer { flex: 1; }

/* ---------- Indicadores ---------- */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
}

.kpi {
    padding: 16px 18px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
}

.kpi-label {
    font-size: 13px;
    color: var(--text-muted);
}

.kpi-value {
    margin-top: 6px;
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

.kpi-value.is-small { font-size: 20px; }

.kpi-sub {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-subtle);
}

/* ---------- Tarjetas de gráfico ---------- */

.chart-grid {
    display: grid;
    /* El min() es lo que evita que la columna se plante en 320px cuando la
       pantalla tiene menos: sin él, en un celular angosto la tarjeta se sale
       y deja toda la página corrida para el costado. */
    grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
    gap: 12px;
}

.chart-card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    padding: 18px 20px 20px;
}

.chart-card.is-wide { grid-column: 1 / -1; }

.chart-title { font-size: 15px; font-weight: 600; }

.chart-desc {
    margin-top: 3px;
    margin-bottom: 14px;
    font-size: 12.5px;
    color: var(--text-subtle);
}

/* Alto suficiente para el plot MÁS la banda de ejes, para que la
   tarjeta no genere un scroll interno que corte las etiquetas */
.chart-canvas { position: relative; width: 100%; }
/* Un <canvas> sin dibujar mide 300px por defecto, y eso no entra en un
   celular angosto. Chart.js le pone el tamaño real apenas pinta, así que
   este tope solo actúa mientras todavía no hay gráfico. */
.chart-canvas canvas { display: block; max-width: 100%; }
.chart-canvas.h-sm { height: 240px; }
.chart-canvas.h-md { height: 300px; }
.chart-canvas.h-lg { height: 420px; }

/* ---------- Estado vacío ---------- */

.empty {
    display: grid;
    place-items: center;
    height: 100%;
    min-height: 120px;
    padding: 24px;
    text-align: center;
    font-size: 13px;
    color: var(--text-subtle);
}

/* ---------- Tabla ---------- */

.table-wrap {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.table-scroll {
    max-height: 420px;
    overflow: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

.table-scroll::-webkit-scrollbar { width: 8px; height: 8px; }
.table-scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}

.table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background-color: var(--surface-muted);
    border-bottom: 1px solid var(--border);
    padding: 10px 14px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--text-subtle);
    white-space: nowrap;
}

.table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background-color: var(--surface-muted); }
.table .num { font-variant-numeric: tabular-nums; }
.table .col-check { width: 44px; }

.table-empty {
    padding: 32px 14px;
    text-align: center;
    color: var(--text-subtle);
    font-size: 14px;
}

/* Checkbox propio, para que no herede el celeste del sistema */
.checkbox {
    appearance: none;
    width: 16px;
    height: 16px;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    background-color: var(--surface);
    cursor: pointer;
    display: grid;
    place-content: center;
    transition: background-color .15s ease, border-color .15s ease;
}

.checkbox::before {
    content: "";
    width: 9px;
    height: 9px;
    transform: scale(0);
    background-color: #fff;
    clip-path: polygon(14% 44%, 0 65%, 43% 100%, 100% 16%, 82% 0%, 39% 62%);
    transition: transform .12s ease;
}

.checkbox:checked {
    background-color: var(--accent);
    border-color: var(--accent);
}

.checkbox:checked::before { transform: scale(1); }

/* ---------- Etiquetas de estado ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background-color: var(--surface-muted);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
}

.badge--facil { background-color: var(--success-soft); border-color: var(--success-border); color: var(--success); }
.badge--normal { background-color: var(--warn-soft); border-color: var(--warn-border); color: var(--warn); }
.badge--dificil { background-color: var(--danger-soft); border-color: var(--danger-border); color: var(--danger); }

/* ---------- Botón destructivo ---------- */

.btn-danger {
    background-color: var(--surface);
    border-color: var(--danger-border);
    color: var(--danger);
}
.btn-danger:hover:not(:disabled) { background-color: var(--danger-soft); }

.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ---------- Avisos ---------- */

.alert {
    display: none;
    padding: 11px 14px;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    background-color: var(--surface-muted);
    font-size: 14px;
}

.alert.is-visible { display: block; }
.alert.is-success { background-color: var(--success-soft); border-color: var(--success-border); color: var(--success); }
.alert.is-error { background-color: var(--danger-soft); border-color: var(--danger-border); color: var(--danger); }

/* ---------- Formularios largos (admin) ---------- */

.textarea {
    width: 100%;
    padding: 10px 12px;
    background-color: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    font-size: 15px;
    font-family: inherit;
    line-height: 1.5;
    resize: vertical;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.textarea::placeholder { color: var(--text-subtle); }
.textarea:hover { border-color: #bfc4cd; }

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

.file-input {
    display: block;
    width: 100%;
    font-size: 13px;
    color: var(--text-muted);
}

.file-input::file-selector-button {
    margin-right: 12px;
    padding: 8px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    background-color: var(--surface);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
}

.file-input::file-selector-button:hover { background-color: var(--surface-muted); }

/* ---------- Lista de preguntas (admin) ---------- */

.q-list {
    display: grid;
    gap: 8px;
    max-height: 560px;
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

.q-list::-webkit-scrollbar { width: 6px; }
.q-list::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }

.q-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
}

.q-item:hover { border-color: var(--border-strong); }

.q-body { flex: 1; min-width: 0; }

.q-text {
    font-size: 14px;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.q-meta {
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.q-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Vista previa de la carga masiva */
.preview-list {
    display: grid;
    gap: 6px;
    max-height: 220px;
    overflow-y: auto;
    font-size: 13px;
}

.preview-row {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background-color: var(--surface);
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.preview-row.is-error {
    background-color: var(--danger-soft);
    border-color: var(--danger-border);
    color: var(--danger);
    white-space: normal;
}

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12.5px;
    background-color: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 5px;
}

/* ---------- Ajustes de pantalla chica ---------- */
/* Va al final del archivo a propósito: los media query no suman especificidad,
   así que esta regla tiene que venir DESPUÉS de .input/.select/.textarea para
   poder pisarles el font-size. */

/* Safari en iPhone hace zoom automático al enfocar un campo con fuente menor a
   16px, y después no vuelve solo: el alumno queda navegando en zoom desde que
   toca "Nombre completo". Solo se sube en pantallas chicas, así el diseño de
   escritorio queda igual que siempre. */
@media (max-width: 768px) {
    .input, .select, .textarea { font-size: 16px; }
}
