/* Citadel — editor LaTeX. Hoja de estilos del prototipo v0.
   Layout: header fijo + dos paneles (editor | visor) a pantalla completa. */

:root {
  --bg:          #0f1115;
  --surface:     #181b22;
  --surface-2:   #1f232c;
  --border:      #2b303b;
  --text:        #e6e8ec;
  --text-dim:    #9aa3b2;
  --accent:      #6ea8fe;
  --accent-2:    #4f8cff;
  --danger:      #ff6b6b;
  --danger-bg:   #2a1a1d;
  --ok:          #51cf66;
  --mono: "JetBrains Mono", "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  overflow: hidden;
}

/* ── Barra superior ─────────────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  padding: 0 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.brand-mark {
  color: var(--accent);
  font-size: 18px;
}

.brand-name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.2px;
}

.brand-sub {
  color: var(--text-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

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

.status {
  font-size: 13px;
  color: var(--text-dim);
  min-width: 90px;
  text-align: right;
}

.status.is-ok    { color: var(--ok); }
.status.is-error { color: var(--danger); }
.status.is-busy  { color: var(--accent); }

.btn-compile {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--accent-2);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, opacity 0.12s ease;
}

.btn-compile:hover:not(:disabled) { background: var(--accent); }
.btn-compile:disabled { opacity: 0.55; cursor: progress; }

kbd {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: var(--mono);
  font-size: 11px;
}

/* ── Área de trabajo ────────────────────────────────────────────────────── */

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 0;
}

.pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.pane-editor { border-right: 1px solid var(--border); }

.pane-head {
  flex-shrink: 0;
  padding: 7px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
}

/* ── Editor ─────────────────────────────────────────────────────────────── */

.editor-host {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* CodeMirror ocupa todo el alto disponible del panel. */
.editor-host .cm-editor {
  height: 100%;
}

.editor-host .cm-scroller {
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.6;
}

/* ── Panel de error ─────────────────────────────────────────────────────── */

.error-panel {
  flex-shrink: 0;
  max-height: 40%;
  display: flex;
  flex-direction: column;
  background: var(--danger-bg);
  border-top: 2px solid var(--danger);
}

/* El atributo `hidden` debe ganarle al `display: flex` de arriba
   (una regla de clase, si no, anula el `display:none` del navegador). */
.error-panel[hidden] { display: none; }

.error-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--danger);
}

.error-close {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 6px;
}

.error-log {
  margin: 0;
  padding: 8px 12px 12px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  color: #ffc9c9;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Visor PDF ──────────────────────────────────────────────────────────── */

.viewer-host {
  flex: 1;
  position: relative;
  min-height: 0;
  background: #5a5f6a;
}

.pdf-frame {
  width: 100%;
  height: 100%;
  border: none;
}

.viewer-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #e6e8ec;
  font-size: 14px;
}

/* Igual que .error-panel: el atributo `hidden` debe ganar al display:flex. */
.viewer-empty[hidden] { display: none; }

.viewer-empty p { opacity: 0.8; }
