/* Estilos base que comparten el editor (index.html) y el portal (portal.html): colores, tipografía, botones,
   menús, modales, listas, campos de formulario y etiquetas de estado. Lo propio de cada página va en
   styles.css (editor) y portal.css (portal). */
:root {
  --bg: #0e1217;
  --panel: #151a21;
  --panel-2: #1b222b;
  --panel-3: #222b36;
  --line: #29333f;
  --line-2: #344050;
  --text: #e6ebf1;
  --muted: #95a2b3;
  --faint: #6b7889;
  --accent: #22b8c8;
  --accent-2: #0b7d8e;
  --accent-soft: rgba(34, 184, 200, 0.14);
  --run: #2ea043;
  --run-2: #238636;
  --stop: #da3633;
  --warn: #e3b341;
  --danger: #f85149;
  --ok: #56d364;
  --radius: 8px;
  --code-w: 36%;
  --bottom-h: 210px;
  --topbar-h: 52px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
}
button, input, select, textarea { font: inherit; color: inherit; }
svg { fill: currentColor; }
a { color: var(--accent); }
kbd {
  font: 11px var(--mono);
  padding: 1px 5px;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--muted);
  background: var(--panel-2);
}
code { font-family: var(--mono); font-size: 0.92em; background: var(--panel-3); padding: 1px 5px; border-radius: 4px; }

/* Foco visible con teclado en todo lo que se puede usar (el ratón no lo muestra). */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 7px;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  color: var(--text);
  transition: background 0.12s, border-color 0.12s, opacity 0.12s;
}
.btn:hover:not(:disabled) { background: var(--panel-3); border-color: #45526a; }
.btn:disabled, .btn[aria-disabled=true] { opacity: 0.4; cursor: default; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn.small { height: 26px; padding: 0 9px; font-size: 13px; }
.btn.icon { width: 32px; padding: 0; justify-content: center; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--panel-2); border-color: var(--line); }
.btn.primary { background: var(--accent-2); border-color: #13a0b2; color: #fff; }
.btn.primary:hover:not(:disabled) { background: #0e90a3; }
.btn.danger { color: #ffb3ad; border-color: #6e2b2b; }
.btn.danger:hover:not(:disabled) { background: #3a1d1f; border-color: var(--danger); }
.btn.danger.solid { background: #8e2b28; border-color: var(--danger); color: #fff; }
.btn.active { background: var(--accent-soft); border-color: var(--accent); }
.select {
  height: 32px;
  padding: 0 8px;
  border-radius: 7px;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
}
.select.small { height: 28px; font-size: 13px; }

/* Menús desplegables (Archivo, cuenta) */
.menu { position: relative; }
.menu-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 50;
  min-width: 220px;
  padding: 6px;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  display: none;
}
.menu-list.right { left: auto; right: 0; }
.menu.open .menu-list { display: block; }
.menu-list button, .menu-list a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  text-align: left;
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
}
.menu-list button:hover, .menu-list a:hover { background: var(--panel-3); }
.menu-list button:disabled { opacity: 0.4; cursor: default; background: none; }
.menu-list hr { border: 0; border-top: 1px solid var(--line); margin: 5px 2px; }
.menu-head { padding: 6px 10px 8px; border-bottom: 1px solid var(--line); margin-bottom: 5px; }
.menu-head b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-head small { color: var(--muted); }

/* Círculo con las iniciales de la cuenta */
.avatar {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-2);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  flex: none;
}

/* Modales (el editor usa .modal; el portal, <dialog class="modal-card">) */
.modal { position: fixed; inset: 0; z-index: 100; background: rgba(5, 8, 11, 0.6); display: grid; place-items: center; padding: 16px; backdrop-filter: blur(3px); }
.modal[hidden] { display: none; }
.modal-card {
  width: min(980px, 100%);
  max-height: min(86vh, 900px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
.modal-card.narrow { width: min(560px, 100%); }
.modal-card header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.modal-card h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 14px 16px 16px; overflow-y: auto; }
.modal-tools { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.modal-tools input[type=search] { flex: 1; min-width: 200px; height: 36px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--panel-2); }
.modal-tools input[type=search]:focus { outline: none; border-color: var(--accent); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }
dialog.modal-card { padding: 0; color: var(--text); overflow: hidden; }
dialog.modal-card[open] { display: flex; }
dialog.modal-card::backdrop { background: rgba(5, 8, 11, 0.6); backdrop-filter: blur(3px); }
.cat-title { margin: 16px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--faint); font-weight: 700; }

/* Listas */
.list { display: flex; flex-direction: column; gap: 6px; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel-2); }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .t { font-weight: 600; overflow-wrap: anywhere; }
.list-item .s { color: var(--muted); font-size: 12.5px; }
.empty { color: var(--muted); padding: 24px; text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.form-error:empty { display: none; }

.badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; display: inline-flex; align-items: center; justify-content: center; }
.badge.warn { background: #9e6a03; }
.check { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 12.5px; cursor: pointer; }

/* Campos de formulario */
.field { display: flex; flex-direction: column; gap: 5px; margin: 0 0 14px; min-width: 0; }
.field > label, .field > .label { font-size: 13px; font-weight: 600; color: var(--text); }
.field .help { font-size: 12.5px; color: var(--muted); }
.field .error-text { font-size: 12.5px; color: #ffb3ad; }
fieldset.plain, .ro-field { border: 0; margin: 0; padding: 0; min-width: 0; }
.input {
  width: 100%;
  min-height: 38px;
  padding: 7px 11px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text);
}
textarea.input { min-height: 90px; resize: vertical; line-height: 1.45; }
.input:hover { border-color: #45526a; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input[aria-invalid=true] { border-color: var(--danger); }
.input:is(input, textarea):read-only { color: var(--muted); }
.input.mono { font-family: var(--mono); }

/* Avisos dentro de la página */
.notice { padding: 10px 12px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); font-size: 13.5px; }
.notice.info { border-color: #1d6f7a; background: rgba(34, 184, 200, 0.08); }
.notice.warn { border-color: #8a6d1f; background: rgba(58, 48, 20, 0.6); color: #ffe8a8; }
.notice.error { border-color: #8e3a36; background: rgba(58, 29, 31, 0.7); color: #ffd2cd; }
.notice.ok { border-color: #2a6b37; background: rgba(46, 160, 67, 0.12); }

/* Estado de una entrega o de una tarea */
.state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: var(--panel-3);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}
.state::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.state.working { color: #79c0ff; border-color: #2a4d73; background: rgba(56, 139, 253, 0.1); }
.state.submitted { color: var(--accent); border-color: #1d6f7a; background: var(--accent-soft); }
.state.late { color: var(--warn); border-color: #8a6d1f; background: rgba(227, 179, 65, 0.1); }
.state.graded { color: var(--ok); border-color: #2a6b37; background: rgba(46, 160, 67, 0.12); }
.state.returned { color: #f0883e; border-color: #7a4520; background: rgba(240, 136, 62, 0.1); }
.state.draft { color: var(--muted); }
.state.published { color: var(--ok); border-color: #2a6b37; background: rgba(46, 160, 67, 0.12); }
.state.archived { color: var(--faint); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 120;
  max-width: calc(100% - 32px);
  padding: 9px 16px;
  border-radius: 9px;
  background: var(--panel-3);
  border: 1px solid var(--line-2);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
.toast.error { border-color: var(--danger); }
