/* Voice Ops Dashboard — CSS genérico (sin framework). Responsive + temas. */
:root {
  --bg: #F5F7F9; --surface: #FFFFFF; --surface-2: #EEF2F5; --border: #DCE2E7;
  --text: #263746; --muted: #64727D; --accent: #526D82; --accent-2: #40576A;
  --accent-3: #334A5E; --accent-soft: #E8EFF4; --accent-border: #C9D6DF;
  --ok: #4F7A63; --warn: #9A7440; --bad: #A65353; --muted-c: #64727D;
  --focus: #7895AA; --input-bg: #FAFBFC;
  --radius: 10px; --font-size: 16px; --density: 8px;
}
[data-theme="dark"] {
  --bg: #21272D; --surface: #2A323A; --surface-2: #323C46; --border: #3D4853;
  --text: #E4E9ED; --muted: #9AA7B1; --accent: #8FA6B8; --accent-2: #A3B6C4;
  --accent-3: #C3D2DC; --accent-soft: #33404B; --accent-border: #465563;
  --ok: #7BA98D; --warn: #C4A66E; --bad: #CF9696; --muted-c: #9AA7B1;
  --focus: #8FA6B8; --input-bg: #242C34;
}
[data-theme="light"] { color-scheme: light; }
[data-theme="dark"] { color-scheme: dark; }
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: var(--font-size); }
a { color: var(--accent); text-decoration: none; }
.muted { color: var(--muted); }
/* v0.7.7 — lista de motivos (bloqueo/fallo) del detalle de call. */
.reason-list { margin: 0; padding-left: 18px; }
.reason-list li { margin: 4px 0; }
.reason-list .badge { margin-right: 6px; }
/* v0.7.8 — barra de progreso del lanzamiento (procesados / total). */
.progress-block .dc-num { font-variant-numeric: tabular-nums; font-weight: 600; }
.progress { height: 10px; border-radius: 6px; overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--border);
  margin: 10px 0 4px; }
.progress-fill { display: block; height: 100%; background: var(--accent);
  transition: width .3s ease; }
.progress-block p { margin-top: 4px; }

/* layout */
.sidebar { position: fixed; inset: 0 auto 0 0; width: 230px; background: var(--surface);
  border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 8px; padding: 18px 16px;
  font-weight: 700; border-bottom: 1px solid var(--border); }
.brand-dot { width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); }
.nav { display: flex; flex-direction: column; padding: 10px; gap: 2px; flex: 1; }
.nav-item { padding: 9px 12px; border-radius: 8px; color: var(--text); }
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-3);
  border: 1px solid var(--accent-border); font-weight: 600; }
.sidebar-foot { padding: 12px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 6px; }
.logout-form { margin: 0; }
.linklike { background: none; border: none; color: var(--accent); cursor: pointer;
  padding: 4px 0; font-size: .9em; text-align: left; }
.main.with-sidebar { margin-left: 230px; padding: 20px 28px 60px; min-height: 100vh; }
.main.full { padding: 20px; }
.topbar { display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.topbar-title h1 { margin: 0 0 4px; font-size: 1.45em; }
.topbar-user { display: flex; align-items: center; gap: 10px; }

/* cards/tables */
.card { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: calc(var(--density) * 2); margin-bottom: 18px; }
.card h2, .card h3 { margin-top: 0; }
table.grid { width: 100%; border-collapse: collapse; font-size: .95em; }
table.grid th { text-align: left; padding: calc(var(--density)) 10px; font-size: .8em;
  text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
  border-bottom: 2px solid var(--border); white-space: nowrap; }
table.grid td { padding: calc(var(--density) + 2px) 10px;
  border-bottom: 1px solid var(--border); vertical-align: top;
  word-break: normal; overflow-wrap: anywhere; }
table.grid tr:hover td { background: var(--surface-2); }
/* v0.7.7 — fila completa clicable (abre el detalle del recurso). */
table.grid tr.row-link { cursor: pointer; }
table.grid tr.row-link:focus-visible { outline: 2px solid var(--accent, #4b6bfb);
  outline-offset: -2px; }
table.grid tr.row-link td:first-child a { font-weight: 600; }
.density-compact { --density: 4px; }
.fs-small { font-size: 14px; } .fs-large { font-size: 18px; }
.table-scroll { overflow-x: auto; }

/* badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: .76em; font-weight: 600; background: var(--surface-2); }
.st-ok { background: #E3EDE7; color: var(--ok); }
.st-warn { background: #F4EDE0; color: var(--warn); }
.st-bad { background: #F6E7E7; color: var(--bad); }
.st-muted { background: var(--surface-2); color: var(--muted-c); }
[data-theme="dark"] .st-ok { background: #24402E; }
[data-theme="dark"] .st-warn { background: #3E321F; }
[data-theme="dark"] .st-bad { background: #432525; }
.role-super_admin { background: var(--accent); color: #fff; }
.role-admin { background: var(--accent-2); color: #fff; }
.env-badge.env-demo, .env-badge.env-live, .env-badge.env-empty { border-radius: 999px; }
.env-badge { font-weight: 800; letter-spacing: .06em; }
.env-badge.env-demo { background: #E2E8F0; color: #475569; }
.env-badge.env-live { background: #E3EDE7; color: #4F7A63; }
.env-badge.env-empty { background: var(--surface-2); color: var(--muted-c); }
[data-theme="dark"] .env-badge.env-demo { background: #334155; color: #CBD5E1; }
[data-theme="dark"] .env-badge.env-live { background: #24402E; color: #7BA98D; }

/* kpi / funnel */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; }
.kpi .num { font-size: 1.7em; font-weight: 800; }
.kpi .label { color: var(--muted); font-size: .82em; }
.funnel { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.funnel .stage { background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 14px; text-align: center; min-width: 90px; }
.funnel .stage .n { font-weight: 800; font-size: 1.25em; }
.funnel .arrow { color: var(--muted); }

/* F6.2 — detail cards (layout por tarjetas, anti-cards-estrechas).
   Prohibido word-break con ruptura letra por letra: aquí se usa
   word-break: normal + overflow-wrap: anywhere (wrap controlado). */
.detail-grid { display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px; margin-bottom: 18px; }
.detail-card { display: block; width: 100%; min-width: 0;
  word-break: normal; overflow-wrap: anywhere; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; }
.detail-card .dc-label { display: block; color: var(--muted);
  font-size: .76em; text-transform: uppercase; letter-spacing: .05em;
  margin-bottom: 3px; }
.detail-card .dc-value { display: block; font-size: 1.02em;
  font-weight: 600; }
.detail-card .dc-value .dc-mono { font-family: ui-monospace, SFMono-Regular,
  Menlo, Consolas, monospace; font-weight: 500; font-size: .9em;
  word-break: normal; overflow-wrap: anywhere; }
.detail-card .dc-value.dc-mono, span.dc-mono { font-family: ui-monospace,
  SFMono-Regular, Menlo, Consolas, monospace; font-weight: 500;
  font-size: .9em; word-break: normal; overflow-wrap: anywhere; }
/* placeholder de audio/transcript (F7D) — accesible por aria-label */
.media-placeholder { display: flex; align-items: center; gap: 10px;
  border: 1px dashed var(--border); background: var(--surface-2);
  border-radius: 8px; padding: 10px 12px; color: var(--muted);
  font-size: .9em; }
.media-placeholder .pulse-dot { width: 9px; height: 9px; border-radius: 50%;
  background: var(--muted-c); flex: none; }
.media-placeholder .ph-title { font-weight: 600; color: var(--text); }
.media-placeholder .ph-note { font-size: .85em; }

/* F7D — reproductor de audio servido por el dashboard (sin URL del provider) */
.card audio { width: 100%; max-width: 680px; display: block; }
audio:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* F6.2 — kpi con números largos no desbordan la tarjeta */
.kpi { min-width: 0; }
.kpi .num { overflow-wrap: anywhere; word-break: normal; }

/* forms */
label { display: block; margin-bottom: 10px; font-size: .92em; color: var(--muted); }
input, select, textarea { width: 100%; padding: 9px 11px; margin-top: 4px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  color: var(--text); font-size: .95em; }
input, select, textarea { background: var(--input-bg); }
input:focus, select:focus { outline: 2px solid var(--focus); outline-offset: 1px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px; }
.btn { display: inline-block; padding: 9px 16px; border-radius: 8px; border: 1px solid
  var(--border); background: var(--surface); color: var(--text); cursor: pointer;
  font-size: .95em; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-secondary { background: var(--surface); border-color: var(--border);
  color: var(--text); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger { background: #F6E7E7; color: var(--bad); border-color: #EBCFCF; }
.btn-block { width: 100%; }
.btn-sm { padding: 4px 10px; font-size: .85em; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form { display: inline; }

/* misc */
.flash-stack { margin-bottom: 16px; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; }
.flash-ok { background: #dcfce7; color: var(--ok); }
.flash-error { background: #fee2e2; color: var(--bad); }
[data-theme="dark"] .flash-ok { background: #14532d; }
[data-theme="dark"] .flash-error { background: #7f1d1d; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end;
  margin-bottom: 14px; }
.filters label { margin: 0; min-width: 140px; }
.pagination { display: flex; gap: 14px; align-items: center; margin-top: 14px; }
.empty-state { text-align: center; padding: 40px 10px; color: var(--muted); }
.kv-label { width: 220px; color: var(--muted); font-weight: 500; }
.demo-note { text-align: center; color: var(--muted); font-size: .85em;
  margin-top: 26px; }
.login-wrap { max-width: 420px; margin: 8vh auto 0; }
.login-card h2 { margin-top: 0; }
.transcript { font-family: ui-monospace, monospace; font-size: .9em; }
.tseg { padding: 10px 12px; margin-bottom: 8px; border-radius: 8px;
  background: var(--surface-2); border-left: 3px solid var(--border); }
.tseg.role-agent { border-left-color: var(--accent); }
.tseg.role-caller { border-left-color: var(--ok); }
.tseg.role-tool { border-left-color: var(--warn); }
.tseg.role-system { border-left-color: var(--muted-c); }
.tseg .who { font-weight: 700; font-size: .82em; color: var(--muted); }
.error-card { max-width: 560px; margin: 10vh auto; text-align: center; }
textarea.mono { font-family: ui-monospace, monospace; font-size: .85em; min-height: 120px; }
.master-prompt-box { white-space: pre-wrap; background: var(--surface-2);
  padding: 12px; border-radius: 8px; max-height: 420px; overflow: auto;
  font-family: ui-monospace, monospace; font-size: .85em; }
@media (max-width: 800px) {
  .sidebar { position: static; width: 100%; flex-direction: row; flex-wrap: wrap;
    align-items: center; }
  .nav { flex-direction: row; overflow-x: auto; padding: 6px; }
  .nav-item { white-space: nowrap; }
  .sidebar-foot { flex-direction: row; align-items: center; border-top: none; }
  .main.with-sidebar { margin-left: 0; padding: 14px; }
  .brand { border-bottom: none; padding: 10px 12px; }
}
/* F6.2 — breakpoints detail-grid: tablet 2 columnas / mobile 1 columna.
   Orden importa: la regla más específica (mobile) va DESPUÉS. */
@media (max-width: 960px) {
  .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
}
