/* =============================================================
   Sistema visual compartido — Cátedra de Administración
   Lo usan index.html (cuestionarios) y tutor.html (Mintzbot).
   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-mark {
    width: 28px;
    height: 28px;
    border-radius: var(--r-sm);
    background-color: var(--accent);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.02em;
    flex-shrink: 0;
}

.brand-name {
    /* Comparte renglón con el logotipo y parte adentro suyo cuando no entra,
       en vez de empujarse a una línea propia. */
    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 la marca completa ocuparía tres renglones: dejamos
   solo el nombre principal, que el título de cada página ya ubica. */
@media (max-width: 480px) {
    .brand-sep, .brand-context, .brand-alt { 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;
    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; }
.btn-block { width: 100%; }

/* ---------- 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;
}

.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;
    }
}
