/* ============================================================
   Reuniones — sistema visual
   Referencia: puente de mando de noche. Fondos de casco azulados,
   datos en tipografía de instrumento, naranja NAVALCA sólo para
   acciones. Los colores de estado son aparte del acento.
   ============================================================ */

:root {
  color-scheme: light dark;

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --step--2: 0.6875rem;
  --step--1: 0.8125rem;
  --step-0: 0.9375rem;
  --step-1: 1.0625rem;
  --step-2: 1.3125rem;

  --r-sm: 7px;
  --r: 11px;
  --r-lg: 15px;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  /* ── Tema claro (por defecto) ── */
  --bg: #f2f5f8;
  --surface: #ffffff;
  --surface-2: #eaeef4;
  --rule: #d7dee8;
  --rule-strong: #bfcad9;
  --text: #0e1720;
  --text-2: #3d4c5e;
  --muted: #64748b;

  --signal: #cf4d0c;
  --signal-ink: #ffffff;
  --signal-wash: rgba(207, 77, 12, 0.09);

  --run: #0369a1;
  --run-wash: rgba(3, 105, 161, 0.09);
  --wait: #a16207;
  --wait-wash: rgba(161, 98, 7, 0.1);
  --good: #047857;
  --good-wash: rgba(4, 120, 87, 0.09);
  --bad: #b3261e;
  --bad-wash: rgba(179, 38, 30, 0.07);

  --shadow: 0 1px 2px rgba(14, 23, 32, 0.05), 0 4px 12px rgba(14, 23, 32, 0.05);
  --shadow-lg: 0 2px 6px rgba(14, 23, 32, 0.07), 0 12px 32px rgba(14, 23, 32, 0.1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #090d13;
    --surface: #111821;
    --surface-2: #19222e;
    --rule: #24303f;
    --rule-strong: #35455a;
    --text: #e4eaf1;
    --text-2: #b3c0d0;
    --muted: #7d8fa6;

    --signal: #ff7a29;
    --signal-ink: #1a0c02;
    --signal-wash: rgba(255, 122, 41, 0.13);

    --run: #38bdf8;
    --run-wash: rgba(56, 189, 248, 0.12);
    --wait: #fbbf24;
    --wait-wash: rgba(251, 191, 36, 0.12);
    --good: #34d399;
    --good-wash: rgba(52, 211, 153, 0.12);
    --bad: #fb7185;
    --bad-wash: rgba(251, 113, 133, 0.11);

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 14px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 2px 8px rgba(0, 0, 0, 0.5), 0 16px 40px rgba(0, 0, 0, 0.45);
  }
}

/* El botón de tema tiene que ganarle al media query en ambas direcciones. */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f2f5f8;
  --surface: #ffffff;
  --surface-2: #eaeef4;
  --rule: #d7dee8;
  --rule-strong: #bfcad9;
  --text: #0e1720;
  --text-2: #3d4c5e;
  --muted: #64748b;
  --signal: #cf4d0c;
  --signal-ink: #ffffff;
  --signal-wash: rgba(207, 77, 12, 0.09);
  --run: #0369a1;
  --run-wash: rgba(3, 105, 161, 0.09);
  --wait: #a16207;
  --wait-wash: rgba(161, 98, 7, 0.1);
  --good: #047857;
  --good-wash: rgba(4, 120, 87, 0.09);
  --bad: #b3261e;
  --bad-wash: rgba(179, 38, 30, 0.07);
  --shadow: 0 1px 2px rgba(14, 23, 32, 0.05), 0 4px 12px rgba(14, 23, 32, 0.05);
  --shadow-lg: 0 2px 6px rgba(14, 23, 32, 0.07), 0 12px 32px rgba(14, 23, 32, 0.1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #090d13;
  --surface: #111821;
  --surface-2: #19222e;
  --rule: #24303f;
  --rule-strong: #35455a;
  --text: #e4eaf1;
  --text-2: #b3c0d0;
  --muted: #7d8fa6;
  --signal: #ff7a29;
  --signal-ink: #1a0c02;
  --signal-wash: rgba(255, 122, 41, 0.13);
  --run: #38bdf8;
  --run-wash: rgba(56, 189, 248, 0.12);
  --wait: #fbbf24;
  --wait-wash: rgba(251, 191, 36, 0.12);
  --good: #34d399;
  --good-wash: rgba(52, 211, 153, 0.12);
  --bad: #fb7185;
  --bad-wash: rgba(251, 113, 133, 0.11);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 14px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 2px 8px rgba(0, 0, 0, 0.5), 0 16px 40px rgba(0, 0, 0, 0.45);
}

/* ── Base ─────────────────────────────────────────────────── */

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: var(--step-0);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
  border-radius: 4px;
}

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

/* Todo dato numérico va en la cara de instrumento, alineado en columnas. */
.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.shell {
  max-width: 880px;
  margin: 0 auto;
  padding: 28px 20px 96px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

/* ── Cabecera ─────────────────────────────────────────────── */

.masthead {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--rule);
}

.mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--signal);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: var(--shadow);
}
.mark svg { width: 19px; height: 19px; stroke: var(--signal-ink); }

.masthead-text { flex: 1; min-width: 0; }
.masthead h1 {
  margin: 0;
  font-size: var(--step-1);
  font-weight: 600;
  letter-spacing: -0.015em;
}
.masthead p {
  margin: 1px 0 0;
  font-size: var(--step--1);
  color: var(--muted);
}

.masthead-tools { display: flex; gap: 6px; flex-shrink: 0; }

/* ── Controles ────────────────────────────────────────────── */

button {
  font: inherit;
  font-size: var(--step--1);
  cursor: pointer;
  border-radius: var(--r-sm);
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--text-2);
  padding: 7px 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease),
              color 0.15s var(--ease), transform 0.08s var(--ease);
}
button:hover:not(:disabled) { background: var(--surface-2); border-color: var(--rule-strong); color: var(--text); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button svg { width: 15px; height: 15px; flex-shrink: 0; }

.btn-primary {
  background: var(--signal);
  border-color: var(--signal);
  color: var(--signal-ink);
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) {
  background: var(--signal);
  border-color: var(--signal);
  color: var(--signal-ink);
  filter: brightness(1.08);
}

.btn-quiet { background: transparent; border-color: transparent; color: var(--muted); }
.btn-quiet:hover:not(:disabled) { background: var(--surface-2); border-color: transparent; }

.btn-icon { padding: 7px; border-color: transparent; background: transparent; color: var(--muted); }
.btn-icon:hover:not(:disabled) { background: var(--surface-2); }

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

input, select {
  font: inherit;
  font-size: var(--step-0);
  background: var(--bg);
  border: 1px solid var(--rule);
  color: var(--text);
  border-radius: var(--r-sm);
  padding: 9px 11px;
  width: 100%;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
input:focus, select:focus {
  outline: none;
  border-color: var(--signal);
  box-shadow: 0 0 0 3px var(--signal-wash);
}

label {
  display: block;
  font-size: var(--step--2);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

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

/* ── Zona de subida ───────────────────────────────────────── */

.dropzone {
  border: 1.5px dashed var(--rule-strong);
  border-radius: var(--r-lg);
  background: var(--surface);
  padding: 34px 22px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 11px;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--signal); background: var(--signal-wash); }
.dropzone.is-over { border-style: solid; }
.dropzone svg { width: 26px; height: 26px; stroke: var(--muted); transition: stroke 0.18s var(--ease); }
.dropzone:hover svg, .dropzone.is-over svg { stroke: var(--signal); }
.dz-title { font-weight: 600; font-size: var(--step-0); }
.dz-sub { font-size: var(--step--1); color: var(--muted); }

.staged { padding: 20px; display: flex; flex-direction: column; gap: 16px; }

.staged-file {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 13px;
  background: var(--surface-2);
  border-radius: var(--r);
  border: 1px solid var(--rule);
}
.staged-file svg { width: 17px; height: 17px; stroke: var(--signal); flex-shrink: 0; }
.staged-name { font-weight: 500; font-size: var(--step--1); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.staged-size { font-size: var(--step--1); color: var(--muted); flex-shrink: 0; }

.field-row { display: grid; grid-template-columns: 1fr 200px; gap: 14px; }
@media (max-width: 640px) { .field-row { grid-template-columns: 1fr; } }

.staged-actions { display: flex; gap: 9px; }

/* ── Aviso por correo ─────────────────────────────────────── */

.notify {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 13px 14px;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: var(--r);
}

.check {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  margin: 0;
  font-size: var(--step-0);
  font-weight: 500;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
}
.check input {
  width: 16px;
  height: 16px;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--signal);
  cursor: pointer;
}

.notify-row { display: flex; gap: 8px; }
.notify-row input { flex: 1; background: var(--surface); }
.notify-row button { flex-shrink: 0; border-color: var(--rule); }

.hint { margin: 0; font-size: var(--step--1); color: var(--muted); }
.hint.is-off { color: var(--wait); }

.notice.is-ok {
  background: var(--good-wash);
  border-color: var(--good-wash);
  color: var(--good);
}

/* ── Diálogo ──────────────────────────────────────────────── */

.sheet {
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text);
  padding: 0;
  width: min(400px, calc(100vw - 32px));
  box-shadow: var(--shadow-lg);
}
.sheet::backdrop {
  background: rgba(5, 8, 12, 0.55);
  backdrop-filter: blur(2px);
}
.sheet form { display: flex; flex-direction: column; }

.sheet-title {
  margin: 0;
  padding: 18px 20px;
  font-size: var(--step-1);
  font-weight: 600;
  letter-spacing: -0.015em;
  border-bottom: 1px solid var(--rule);
}
.sheet-body { padding: 20px; display: flex; flex-direction: column; gap: 15px; }
.sheet-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 14px 20px;
  background: var(--surface-2);
  border-top: 1px solid var(--rule);
}

/* ── Barras de progreso ───────────────────────────────────── */

.track {
  height: 5px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid var(--rule);
}
.track > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: var(--run);
  transition: width 0.5s var(--ease);
}
.track.is-signal > span { background: var(--signal); }
.track.is-good > span { background: var(--good); }

/* En cola = rayas de peligro. Lenguaje industrial de NAVALCA, usado con función:
   "detenido, esperando turno" se lee distinto de "corriendo" sin leer una palabra. */
.track.is-waiting > span {
  width: 100% !important;
  background: repeating-linear-gradient(
    45deg,
    var(--wait-wash) 0 7px,
    transparent 7px 14px
  );
  animation: crawl 1.1s linear infinite;
}
@keyframes crawl {
  to { background-position: 19.8px 0; }
}

.meter-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
}
.meter-label { font-size: var(--step--1); font-weight: 600; color: var(--text-2); }
.meter-value { font-size: var(--step--1); color: var(--muted); }

/* Lectura de instrumento: dónde va dentro de la reunión.
   Más honesto que un "51%" abstracto — se puede verificar contra el audio. */
.readout {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: var(--step--1);
}
.readout .pos { color: var(--run); font-weight: 600; font-size: var(--step-0); }
.readout .sep { color: var(--rule-strong); }
.readout .total { color: var(--muted); }

/* ── Sección ──────────────────────────────────────────────── */

/* El espaciado lo pone el layout, no márgenes por elemento: así no colisionan
   ni se colapsan entre sí. */
.shell > section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.section-head h2 {
  margin: 0;
  font-size: var(--step--2);
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}
.section-count { font-size: var(--step--1); color: var(--muted); }

/* ── Tarjeta de trabajo ───────────────────────────────────── */

.jobs { display: flex; flex-direction: column; gap: 11px; }

.job {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 13px;
}

/* Franja de estado: el color codifica el estado en la forma, no sólo en el texto. */
.job::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--rule-strong);
}
.job.is-processing { border-color: var(--run-wash); box-shadow: var(--shadow-lg); }
.job.is-processing::before { background: var(--run); }
.job.is-queued::before { background: var(--wait); }
.job.is-done::before { background: var(--good); }
.job.is-error::before { background: var(--bad); }

.job-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.job-id { min-width: 0; flex: 1; }
.job-name {
  font-weight: 600;
  font-size: var(--step-0);
  letter-spacing: -0.01em;
  word-break: break-word;
  margin-bottom: 3px;
}
.job-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 9px;
  font-size: var(--step--1);
  color: var(--muted);
}
.job-facts .dot { color: var(--rule-strong); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--step--2);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 10px 4px 8px;
  border-radius: 99px;
  white-space: nowrap;
  flex-shrink: 0;
  border: 1px solid transparent;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 99px; background: currentColor; }
.pill.is-queued { color: var(--wait); background: var(--wait-wash); border-color: var(--wait-wash); }
.pill.is-processing { color: var(--run); background: var(--run-wash); border-color: var(--run-wash); }
.pill.is-processing::before { animation: beat 1.6s var(--ease) infinite; }
.pill.is-done { color: var(--good); background: var(--good-wash); border-color: var(--good-wash); }
.pill.is-error { color: var(--bad); background: var(--bad-wash); border-color: var(--bad-wash); }

@keyframes beat {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.8); }
}

.job-actions { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.job-actions .spacer { flex: 1; }

.notice {
  border-radius: var(--r);
  padding: 10px 12px;
  font-size: var(--step--1);
  border: 1px solid;
}
.notice.is-error {
  background: var(--bad-wash);
  border-color: var(--bad-wash);
  color: var(--bad);
  word-break: break-word;
}

/* ── Transcripción en vivo ────────────────────────────────── */

.feed {
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 12px 14px;
  max-height: 168px;
  overflow-y: auto;
  font-size: var(--step--1);
  line-height: 1.65;
  color: var(--text-2);
  scroll-behavior: smooth;
  position: relative;
}
.feed-head {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: var(--step--2);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.feed-head .live-dot {
  width: 5px; height: 5px; border-radius: 99px;
  background: var(--run);
  animation: beat 1.6s var(--ease) infinite;
}
.feed-line { display: flex; gap: 10px; padding: 2px 0; }
.feed-time {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--step--2);
  color: var(--muted);
  flex-shrink: 0;
  padding-top: 2px;
}
.feed-line:last-child .feed-text { color: var(--text); }

/* ── Visor de transcripción ───────────────────────────────── */

.transcript {
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 6px 0;
  max-height: 460px;
  overflow-y: auto;
}
.t-row {
  display: flex;
  gap: 14px;
  padding: 9px 14px;
  border-radius: var(--r-sm);
}
.t-row:hover { background: var(--surface-2); }
.t-time {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--step--2);
  color: var(--signal);
  flex-shrink: 0;
  padding-top: 3px;
  font-weight: 600;
}
/* Prosa a ~65 caracteres: es texto para leer, no una tabla de datos. */
.t-text { max-width: 68ch; color: var(--text-2); }

/* ── Vacío ────────────────────────────────────────────────── */

.blank {
  text-align: center;
  padding: 44px 20px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
}
.blank svg { width: 30px; height: 30px; stroke: var(--rule-strong); }
.blank-title { font-weight: 600; color: var(--text-2); font-size: var(--step-0); }
.blank-sub { font-size: var(--step--1); max-width: 42ch; }

/* ── Avisos flotantes ─────────────────────────────────────── */

.toaster {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
  pointer-events: none;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--rule);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--r);
  font-size: var(--step--1);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: rise 0.24s var(--ease);
  display: flex;
  align-items: center;
  gap: 9px;
}
.toast::before { content: ""; width: 6px; height: 6px; border-radius: 99px; background: var(--good); flex-shrink: 0; }
.toast.is-error { border-color: var(--bad); color: var(--bad); }
.toast.is-error::before { background: var(--bad); }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Login ────────────────────────────────────────────────── */

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.gate-card {
  width: 100%;
  max-width: 336px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.gate-brand { display: flex; align-items: center; gap: 11px; }
.gate-brand h1 { margin: 0; font-size: var(--step-1); font-weight: 600; letter-spacing: -0.015em; }
.gate-brand p { margin: 1px 0 0; font-size: var(--step--1); color: var(--muted); }

.gate-foot {
  margin: 0;
  text-align: center;
  font-size: var(--step--2);
  color: var(--muted);
  letter-spacing: 0.02em;
}
.gate-foot strong { color: var(--text-2); font-weight: 600; letter-spacing: 0.06em; }

/* ── Pie ──────────────────────────────────────────────────── */

.colophon {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding-top: 22px;
  border-top: 1px solid var(--rule);
  font-size: var(--step--2);
  color: var(--muted);
  letter-spacing: 0.02em;
}
.colophon svg { width: 13px; height: 13px; stroke: var(--rule-strong); flex-shrink: 0; }
.colophon strong { color: var(--text-2); font-weight: 600; }
.colophon strong:last-of-type { letter-spacing: 0.06em; }

.hidden { display: none !important; }
