/* Liga SQL — estilos. Paleta fría de "laboratorio": gris azulado, tinta oscura y un azul de acción. */
:root {
  --bg: #E8EDF1;
  --panel: #FFFFFF;
  --ink: #1C2733;
  --muted: #5D6D7C;
  --line: #D3DBE2;
  --accent: #1D5C8C;
  --accent-ink: #FFFFFF;
  --run: #2D7A4B;
  --ok: #2D7A4B;
  --ok-bg: #E4F2E9;
  --bad: #B42318;
  --bad-bg: #FBEAE8;
  --warn: #9A4A06;
  --warn-bg: #FDF1E3;
  --sans: "IBM Plex Sans", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  --r: 6px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 var(--sans); color: var(--ink); background: var(--bg); }
a { color: var(--accent); }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 .25rem; font-weight: 600; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .5rem; font-weight: 600; }
h3 { font-size: .95rem; margin: 1rem 0 .4rem; font-weight: 600; }
code, pre, kbd { font-family: var(--mono); font-size: .88em; }
kbd { border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 .3em; background: var(--panel); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.ok { color: var(--ok); }
.bad { color: var(--bad); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- barra superior ---------- */
.topbar {
  display: flex; align-items: center; gap: 1rem; padding: .5rem 1rem;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 600; color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: .4rem; }
.brand-mark { display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 4px;
  background: var(--ink); color: var(--panel); font-family: var(--mono); font-size: .95rem; }
.topnav { margin-left: auto; display: flex; align-items: center; gap: 1rem; }
.topnav a, .linklike { color: var(--muted); text-decoration: none; font: inherit; font-size: .9rem; }
.topnav a:hover, .linklike:hover { color: var(--ink); }
.topnav form { margin: 0; }
.linklike { background: none; border: 0; padding: 0; cursor: pointer; }
.toolbar { display: flex; align-items: center; gap: .75rem; }
.dbname { font-family: var(--mono); font-size: .85rem; color: var(--muted); border: 1px solid var(--line); padding: .25rem .6rem; border-radius: var(--r); }

/* ---------- botones ---------- */
.btn { font: inherit; font-weight: 500; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: .5rem 1rem; border-radius: var(--r); cursor: pointer; text-decoration: none; display: inline-block; }
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #164b73; border-color: #164b73; }
.btn-run { color: var(--run); border-color: var(--run); }
.btn-run span { font-size: .8em; }
.btn-run:hover { background: var(--ok-bg); border-color: var(--run); }
.btn-block { width: 100%; }
.is-busy { opacity: .7; }

/* ---------- páginas simples ---------- */
.page { max-width: 820px; margin: 0 auto; padding: 2rem 1.25rem 4rem; }
.page-wide { max-width: 1100px; }
.empty { padding: 2rem; text-align: center; color: var(--muted); background: var(--panel); border: 1px dashed var(--line); border-radius: var(--r); }
.flash { padding: .6rem .8rem; border-radius: var(--r); }
.flash-bad { background: var(--bad-bg); color: var(--bad); }

.notice { margin: 1.25rem 0; padding: .9rem 1rem; background: var(--warn-bg); border-left: 3px solid var(--warn);
  color: #4a2a08; border-radius: 0 var(--r) var(--r) 0; font-size: .92rem; }
.notice strong { display: block; color: var(--warn); margin-bottom: .15rem; }

.announcements { display: grid; gap: .75rem; margin: 1.25rem 0; }
.announcement { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: .9rem 1rem; }
.announcement header { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }
.announcement h2 { margin: 0; font-size: 1rem; }
.announcement time { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.announcement p { margin: .4rem 0 0; }

.week { margin-top: 2rem; }
.week-head { display: flex; align-items: baseline; gap: 1rem; border-bottom: 2px solid var(--ink); padding-bottom: .35rem; }
.week-head h2 { margin: 0; }
.week-when { font-size: .85rem; color: var(--muted); }
.week-when.closed { color: var(--bad); }
.deadline { color: var(--ink); }
.week-score { font-family: var(--mono); font-size: .9rem; margin-left: auto; }
.week-head a { font-size: .85rem; }
.qlist { list-style: none; margin: 0; padding: 0; }
.qrow a { display: grid; grid-template-columns: 1fr auto 7.5rem; gap: 1rem; align-items: center;
  padding: .7rem .25rem; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.qrow a:hover { background: var(--panel); }
.qstate { font-size: .85rem; text-align: right; color: var(--muted); }
.state-correct .qstate { color: var(--ok); font-weight: 500; }
.state-wrong .qstate { color: var(--bad); }
.state-sent .qstate, .state-started .qstate { color: var(--accent); }

/* ---------- dificultad: 5 casillas, se llenan 1, 3 o 5 ---------- */
.pips { display: inline-flex; align-items: center; gap: 3px; }
.pips i { width: 9px; height: 9px; border: 1.5px solid var(--accent); border-radius: 2px; }
.pips-1 i:nth-child(-n+1), .pips-3 i:nth-child(-n+3), .pips-5 i:nth-child(-n+5) { background: var(--accent); }
.pips b { font-weight: 500; font-size: .8rem; color: var(--muted); margin-left: .45rem; white-space: nowrap; }

/* ---------- espacio de trabajo (editor) ---------- */
body.workspace { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.ws { flex: 1; min-height: 0; display: grid; grid-template-columns: 260px minmax(0, 1fr) 360px; }
.ws-left, .ws-right { background: var(--panel); overflow-y: auto; padding: 1rem; }
.ws-left { border-right: 1px solid var(--line); }
.ws-right { border-left: 1px solid var(--line); }
.ws-center { display: grid; grid-template-rows: minmax(180px, 55%) 1fr; min-height: 0; }
.panel-title { font-size: .95rem; margin: 0 0 .5rem; }
.ws-right .panel-title { margin-top: 1.5rem; }

.editor-wrap { position: relative; min-height: 0; border-bottom: 1px solid var(--line); background: var(--panel); }
.editor-wrap .CodeMirror { position: absolute; inset: 0; height: auto; font-family: var(--mono); font-size: 14.5px; line-height: 1.55; }
.CodeMirror-gutters { background: #F3F6F8; border-right: 1px solid var(--line); }
.CodeMirror-linenumber { color: #8C9AA7; }
.cm-s-default .cm-keyword { color: #1D5C8C; font-weight: 500; }
.cm-s-default .cm-string { color: #8A4B08; }
.cm-s-default .cm-number { color: #2D7A4B; }
.cm-s-default .cm-comment { color: #7A8794; font-style: italic; }
.CodeMirror-hints { font-family: var(--mono); font-size: 13px; }

.results { overflow: auto; padding: 1rem; min-height: 0; transition: opacity .15s; }
.results.is-loading { opacity: .5; }
.results-empty { text-align: center; color: var(--muted); margin-top: 2rem; }
.result-head { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-bottom: .5rem; }
.match { font-size: .82rem; padding: .15rem .55rem; border-radius: 999px; }
.match-ok { background: var(--ok-bg); color: var(--ok); }
.match-no { background: #EEF1F4; color: var(--muted); }
.result-error { background: var(--bad-bg); color: var(--bad); padding: .75rem 1rem; border-radius: var(--r); }
.result-error pre { white-space: pre-wrap; margin: .35rem 0 0; color: #7a1a12; }

/* tablas */
.tablebox { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { text-align: left; padding: .4rem .65rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #F3F6F8; font-weight: 600; position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
.results td, .expected td { font-family: var(--mono); font-size: .84rem; white-space: nowrap; }
.null { color: #9AA6B2; font-style: italic; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.expected .tablebox { max-height: 260px; overflow: auto; }

/* panel izquierdo: esquema */
.table { border-bottom: 1px solid var(--line); }
.table summary { cursor: pointer; padding: .45rem 0; font-family: var(--mono); font-weight: 500; font-size: .9rem; }
.cols { list-style: none; margin: 0 0 .5rem; padding: 0; }
.cols li { display: flex; justify-content: space-between; gap: .5rem; padding: .15rem 0 .15rem .9rem; font-size: .82rem; }
.cname { font-family: var(--mono); }
.cname abbr { text-decoration: none; font-size: .7rem; color: var(--accent); font-weight: 600; }
.ctype { color: var(--muted); font-family: var(--mono); font-size: .75rem; text-align: right; }

/* panel derecho: pregunta */
.qweek { display: block; font-size: .85rem; color: var(--muted); text-decoration: none; margin-bottom: .2rem; }
.qweek:hover { color: var(--ink); }
.qnav { display: flex; justify-content: space-between; font-size: .85rem; margin-bottom: 1rem; }
.qnav a { text-decoration: none; }
.qhead { font-size: 1.25rem; margin-bottom: .4rem; }
.statement { margin-top: .75rem; }
.statement p { margin: 0 0 .6rem; }
.submit-box { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.verdict { font-weight: 600; padding: .55rem .8rem; border-radius: var(--r); background: #EEF1F4; margin: 0 0 .4rem; }
.verdict-ok { background: var(--ok-bg); color: var(--ok); }
.verdict-bad { background: var(--bad-bg); color: var(--bad); }

.dialog { border: 0; border-radius: 10px; padding: 1.5rem; max-width: 420px; box-shadow: 0 20px 60px rgba(28, 39, 51, .3); }
.dialog::backdrop { background: rgba(28, 39, 51, .45); }
.dialog h2 { margin-top: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.25rem; }

/* leaderboard */
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; margin: 1rem 0; }
.tabs a { padding: .35rem .8rem; border-radius: 999px; text-decoration: none; color: var(--muted); font-size: .9rem; }
.tabs a[aria-current="page"] { background: var(--ink); color: var(--panel); }
.filters { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
select, input[type=email], input[type=password] { font: inherit; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); color: var(--ink); }
.board tr.me td { background: #E5EEF6; font-weight: 600; }
.board td:first-child { font-family: var(--mono); color: var(--muted); width: 3rem; }

/* login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 2rem; }
.login-card h1 { display: flex; align-items: center; gap: .5rem; }
.login-card label { display: block; font-size: .88rem; font-weight: 500; margin: 1rem 0 .3rem; }
.login-card input { width: 100%; }
.login-card .btn { margin-top: 1.25rem; }

/* profesor */
.profile-head { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.5rem; }
.profile-stats { display: flex; align-items: center; gap: 1.25rem; }
.attempt { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: .5rem; }
.attempt.has-alerts { border-left: 3px solid var(--warn); }
.attempt summary { display: grid; grid-template-columns: 1fr auto 9rem 7rem; gap: 1rem; align-items: center; padding: .7rem 1rem; cursor: pointer; }
.attempt-body { padding: 0 1rem 1rem; }
.alert-tag { font-size: .78rem; background: var(--warn-bg); color: var(--warn); padding: .1rem .5rem; border-radius: 999px; justify-self: end; }
.alerts { background: var(--warn-bg); color: #4a2a08; padding: .6rem 1rem .6rem 2rem; border-radius: var(--r); font-size: .9rem; }
.signals { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .5rem 1.5rem; margin: 1rem 0; }
.signals dt { font-size: .78rem; color: var(--muted); }
.signals dd { margin: 0; font-family: var(--mono); font-size: .9rem; }
pre.code { background: #F3F6F8; border: 1px solid var(--line); border-radius: var(--r); padding: .5rem .7rem; white-space: pre-wrap; margin: .3rem 0 .6rem; }
.runs { padding-left: 1.25rem; }
.dupe { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--warn); border-radius: var(--r); padding: .6rem 1rem; margin-bottom: .6rem; }
.dupe p { margin: 0 0 .3rem; }
.dupe ol { margin: 0 0 .4rem; }
.schema-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .75rem; }
.schema-table { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: .5rem .8rem; }
.schema-table h3 { font-family: var(--mono); margin: .3rem 0 .4rem; }
.schema-table .cols li { padding-left: 0; }

/* ---------- pantallas chicas ---------- */
@media (max-width: 1000px) {
  body.workspace { height: auto; overflow: auto; }
  .ws { grid-template-columns: 1fr; }
  .ws-center { grid-template-rows: 340px auto; order: 2; }
  .ws-right { order: 1; border-left: 0; border-bottom: 1px solid var(--line); }
  .ws-left { order: 3; border-right: 0; }
  .topbar { flex-wrap: wrap; }
  .qrow a { grid-template-columns: 1fr auto; }
  .qstate { grid-column: 1 / -1; text-align: left; }
  .attempt summary { grid-template-columns: 1fr auto; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media (max-width: 1000px) { .editor-wrap { min-height: 340px; } }
.week-head { flex-wrap: wrap; row-gap: .25rem; }
.week-head h2 { flex: 1 1 18rem; }
.week-when, .week-score, .week-head a { white-space: nowrap; }
