/* Portal Contact Center N2A
   Identidad: la sala de operación. Superficies frías y silenciosas; el color está
   reservado para el estado del agente, que es lo único que debe gritar. */
:root {
  --bg: #e9edf1;
  --surface: #ffffff;
  --surface-2: #f4f6f8;
  --ink: #15202b;
  --muted: #586473;
  --line: #d2d9e0;
  --brand: #0d5a86;
  --focus: #0d5a86;

  --ok: #17734a;     --ok-bg: #e3f3ea;
  --call: #1d5ba3;   --call-bg: #e2ecf8;
  --brk: #9a6110;    --brk-bg: #f7eedd;
  --bad: #b3261e;    --bad-bg: #fbe6e4;
  --sys: #6a3aa8;    --sys-bg: #eee6f8;
  --warn: #8a6a00;   --warn-bg: #f7f0d4;
  --pause: #45525f;  --pause-bg: #e8ecf0;
  --off: #737d88;    --off-bg: #edf0f2;

  --r-s: 4px; --r-m: 8px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-num: "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f151b; --surface: #17202a; --surface-2: #1d2833; --ink: #e6ebf0; --muted: #9aa6b2; --line: #2b3845;
    --brand: #5fb0e0; --focus: #7cc4ee;
    --ok: #4cc58a; --ok-bg: #12301f; --call: #6aa7ef; --call-bg: #142a44; --brk: #e0a54a; --brk-bg: #3a2a10;
    --bad: #f07167; --bad-bg: #3d1614; --sys: #b48cf0; --sys-bg: #2a1d40; --warn: #e5c24a; --warn-bg: #362d0b;
    --pause: #a9b5c1; --pause-bg: #24303b; --off: #8c97a2; --off-bg: #1f2932;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.15rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; }
a { color: var(--brand); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Barra superior ---------- */
.top { display: flex; align-items: center; gap: 1rem; padding: .6rem 1.1rem; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top .brand { display: flex; align-items: center; gap: .55rem; font-weight: 600; }
.mark { width: 22px; height: 22px; border-radius: 50%; background: conic-gradient(var(--ok) 0 25%, var(--call) 0 50%, var(--brk) 0 75%, var(--bad) 0); }
.top nav { display: flex; gap: .25rem; margin-left: .5rem; }
.top nav a, .top nav button.tab { color: var(--muted); text-decoration: none; padding: .35rem .7rem; border-radius: var(--r-s); border: 0; background: none; font: inherit; cursor: pointer; }
.top nav a[aria-current="page"], .top nav button.tab[aria-selected="true"] { color: var(--ink); background: var(--surface-2); }
.top .spacer { flex: 1; }
.top .who { color: var(--muted); font-size: .9rem; }

/* ---------- Botones y formularios ---------- */
.btn { font: inherit; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: .5rem .9rem; border-radius: var(--r-s); cursor: pointer; min-height: 38px; }
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); border-color: currentColor; background: transparent; }
.btn.big { font-size: 1.1rem; padding: .85rem 1.2rem; min-height: 54px; font-weight: 600; }
.btn.sm { padding: .25rem .55rem; min-height: 30px; font-size: .85rem; }
label { display: block; font-size: .85rem; color: var(--muted); margin: .6rem 0 .25rem; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-s); padding: .5rem .6rem; width: 100%; }
textarea { min-height: 120px; font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }
.row { display: flex; gap: .6rem; align-items: end; flex-wrap: wrap; }
.row > * { flex: 1 1 140px; }
.row-end { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; }
.err { color: var(--bad); min-height: 1.3em; margin: .5rem 0 0; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: 1.6rem; }
.login .brand { display: flex; gap: .6rem; align-items: center; margin-bottom: 1.2rem; }
.login .btn { width: 100%; margin-top: 1rem; }

/* ---------- Agente: el estado es lo único que grita ---------- */
.agent { max-width: 640px; margin: 0 auto; padding: 1rem; }
.band { border-radius: var(--r-m); padding: 1.2rem 1.3rem 1.1rem; color: #fff; background: var(--off); transition: background-color .25s; }
.band .state { font-size: 1.7rem; font-weight: 650; letter-spacing: -0.02em; }
.band .why { opacity: .92; min-height: 1.4em; margin-top: .15rem; }
.band .clock { font-size: 3.4rem; line-height: 1; margin-top: .6rem; font-weight: 300; }
.band.s-ok { background: var(--ok); } .band.s-call { background: var(--call); } .band.s-break { background: var(--brk); }
.band.s-bad { background: var(--bad); } .band.s-sys { background: var(--sys); } .band.s-warn { background: var(--warn); }
.band.s-pause { background: var(--pause); } .band.s-off { background: var(--off); }
@media (prefers-color-scheme: dark) { .band { color: #0b1117; } }
.indicators { display: flex; gap: 1rem; flex-wrap: wrap; margin: .8rem 0; font-size: .9rem; }
.ind { display: inline-flex; align-items: center; gap: .4rem; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--off); display: inline-block; flex: none; }
.dot.on { background: var(--ok); } .dot.offline { background: var(--bad); }
.actions { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: 1rem; margin-top: .8rem; }
.actions h2 { margin-bottom: .6rem; }
.break-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .5rem; }
.break-grid .btn { text-align: left; min-height: 60px; }
.break-grid .btn small { display: block; color: var(--muted); font-size: .78rem; }
.callcard { margin-top: .8rem; padding: .8rem 1rem; border-left: 4px solid var(--call); background: var(--surface); border-radius: var(--r-s); }
.notice { margin-top: .8rem; padding: .7rem .9rem; background: var(--warn-bg); color: var(--ink); border-radius: var(--r-s); border-left: 4px solid var(--warn); }
.kbd { font-size: .8rem; color: var(--muted); margin-top: .6rem; }
kbd { font: .8rem ui-monospace, Consolas, monospace; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 3px; padding: 0 .3rem; }

/* ---------- Supervisor ---------- */
.page { padding: 1rem 1.1rem 2rem; }
.banner { padding: .6rem .9rem; border-radius: var(--r-s); margin-bottom: .8rem; background: var(--bad-bg); color: var(--ink); border-left: 4px solid var(--bad); }
.banner.warn { background: var(--warn-bg); border-left-color: var(--warn); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: .7rem .9rem; border-top: 4px solid var(--off); }
.tile .n { font-size: 2.1rem; line-height: 1.1; font-weight: 600; }
.tile .l { color: var(--muted); font-size: .85rem; }
.tile.ok { border-top-color: var(--ok); } .tile.call { border-top-color: var(--call); } .tile.break { border-top-color: var(--brk); }
.tile.bad { border-top-color: var(--bad); } .tile.off { border-top-color: var(--off); } .tile.queue { border-top-color: var(--brand); }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1rem; align-items: start; }
@media (max-width: 1100px) { .layout { grid-template-columns: 1fr; } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); overflow: hidden; }
.panel > header { display: flex; align-items: center; gap: .6rem; padding: .7rem .9rem; border-bottom: 1px solid var(--line); }
.panel > header .spacer { flex: 1; }
.panel .body { padding: .8rem .9rem; }
.scroll-x { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .5rem .7rem; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
th { font-weight: 600; color: var(--muted); font-size: .8rem; background: var(--surface-2); position: sticky; top: 0; }
td.r, th.r { text-align: right; }
tbody tr:hover { background: var(--surface-2); }
tr.agent-row td:first-child { border-left: 4px solid var(--off); }
tr.agent-row.s-ok td:first-child { border-left-color: var(--ok); } tr.agent-row.s-call td:first-child { border-left-color: var(--call); }
tr.agent-row.s-break td:first-child { border-left-color: var(--brk); } tr.agent-row.s-bad td:first-child { border-left-color: var(--bad); }
tr.agent-row.s-sys td:first-child { border-left-color: var(--sys); } tr.agent-row.s-warn td:first-child { border-left-color: var(--warn); }
tr.agent-row.s-pause td:first-child { border-left-color: var(--pause); }
tr.agent-row.over td.t { color: var(--bad); font-weight: 600; }
.chip { display: inline-block; padding: .12rem .5rem; border-radius: 999px; font-size: .82rem; font-weight: 600; background: var(--off-bg); color: var(--off); }
.chip.s-ok { background: var(--ok-bg); color: var(--ok); } .chip.s-call { background: var(--call-bg); color: var(--call); }
.chip.s-break { background: var(--brk-bg); color: var(--brk); } .chip.s-bad { background: var(--bad-bg); color: var(--bad); }
.chip.s-sys { background: var(--sys-bg); color: var(--sys); } .chip.s-warn { background: var(--warn-bg); color: var(--warn); }
.chip.s-pause { background: var(--pause-bg); color: var(--pause); }
.alerts { list-style: none; margin: 0; padding: 0; max-height: 520px; overflow-y: auto; }
.alerts li { padding: .6rem .9rem; border-bottom: 1px solid var(--line); font-size: .9rem; }
.alerts li time { display: block; color: var(--muted); font-size: .78rem; }
.alerts li.new { background: var(--warn-bg); }
.empty { padding: 1.2rem; color: var(--muted); text-align: center; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: end; padding: .8rem .9rem; border-bottom: 1px solid var(--line); }
.filters > div { min-width: 120px; }
.filters label { margin-top: 0; }
.quick { display: flex; gap: .3rem; flex-wrap: wrap; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .6rem; padding: .9rem; }
.kpi .n { font-size: 1.6rem; font-weight: 600; }
.kpi .l { color: var(--muted); font-size: .82rem; }
.kpi abbr { text-decoration: none; border-bottom: 1px dotted var(--muted); cursor: help; }
.bars { display: grid; grid-template-columns: repeat(24, 1fr); gap: 3px; align-items: end; height: 110px; padding: .9rem; }
.bars div { background: var(--call); border-radius: 2px 2px 0 0; min-height: 1px; position: relative; }
.bars div span { position: absolute; bottom: -1.3rem; left: 50%; transform: translateX(-50%); font-size: .68rem; color: var(--muted); }
.pager { display: flex; gap: .5rem; align-items: center; justify-content: flex-end; padding: .6rem .9rem; }

/* Modo pantalla de pared */
body.tv .top nav, body.tv .act, body.tv .filters, body.tv #alerts-panel { display: none; }
body.tv { font-size: 19px; }
body.tv .layout { grid-template-columns: 1fr; }

/* Diálogos y avisos */
.dlg { border: 1px solid var(--line); border-radius: var(--r-m); background: var(--surface); color: var(--ink); width: min(460px, 94vw); padding: 1.2rem; }
.dlg::backdrop { background: rgba(10, 18, 26, .45); }
.dlg h2 { margin-bottom: .4rem; }
#toasts { position: fixed; right: 1rem; bottom: 1rem; display: grid; gap: .5rem; z-index: 50; max-width: min(420px, 92vw); }
.toast { background: var(--ink); color: var(--surface); padding: .7rem .9rem; border-radius: var(--r-s); box-shadow: 0 6px 24px rgba(0,0,0,.18); }
.toast-error { background: var(--bad); color: #fff; }
.toast-ok { background: var(--ok); color: #fff; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media (max-width: 640px) { .band .clock { font-size: 2.6rem; } .top { flex-wrap: wrap; } }

.btn.full { width: 100%; margin-bottom: 1rem; }
.panel + .panel { margin-top: 1rem; }
audio { width: 100%; margin-top: .6rem; }
.dlg-wide { width: min(900px, 96vw); }
.sec-title { padding: .9rem .9rem 0; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; }
.kpi-link { font: inherit; color: inherit; text-align: left; background: none; border: 1px solid transparent; border-radius: var(--r-s); padding: .3rem .4rem; cursor: pointer; }
.kpi-link:hover { border-color: var(--line); background: var(--surface-2); }
