/* IA Voice Agent — dashboard styles
 * Admin chrome (light sidebar + topbar + content): one blue accent on neutral greys
 * (2026-11-03, research docs/research/2026-11-03-barra-lateral-clara.md).
 */

:root {
  --brand-900: #0a2a58;
  --brand-800: #0d3978;
  --brand-700: #114b9e;
  --brand-600: #155cc1;
  --brand-500: #1868db;
  --brand-100: #dce8fa;
  --brand-50:  #eff4fc;

  --ink-900: #111827;
  --ink-700: #374151;
  --ink-500: #6b7280;
  --ink-300: #d1d5db;
  --ink-200: #e5e7eb;
  --ink-100: #f3f4f6;

  --bg:        #f6f7f9;
  --surface:   #ffffff;
  --border:    #e5e7eb;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, .06);
  --shadow-md: 0 4px 12px rgba(17, 24, 39, .08);

  --success: #15803d;
  --success-bg: #dcfce7;
  --danger:  #b91c1c;
  --danger-bg: #fee2e2;
  --warning: #a16207;
  --warning-bg: #fef3c7;
  --info:    #1d4ed8;
  --info-bg: #dbeafe;

  --sidebar-w: 232px;
  --topbar-h: 52px;

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

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font: 14px/1.5 var(--font-ui);
  color: var(--ink-900);
  background: var(--bg);
}

a { color: var(--brand-700); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─────────────────────────────────────────────────────────
 * App layout: sidebar + topbar + main
 * ───────────────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* Sidebar — light (2026-11-03): white bar with a border, dark grey items,
 * the current one marked by a tint, a 3 px bar, weight and aria-current
 * (not colour alone, WCAG 1.4.1); every text pair ≥ 4.5:1 (1.4.3). */
.sidebar {
  background: var(--surface);
  color: var(--ink-700);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
}
.sidebar .brand {
  padding: 16px 20px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .3px;
  color: var(--ink-900);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar .brand::before {
  content: "";
  display: inline-block;
  width: 22px; height: 22px;
  background: var(--brand-500);
  border-radius: 6px;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.15);
  flex-shrink: 0;
}
.sidebar nav { padding: 10px 0; flex: 1; }
/* Section titles vs items (2026-11-03, user feedback): the title is darker,
 * bolder and set off by a divider and more space above; the items are
 * indented under it. */
.sidebar .nav-section {
  margin-top: 10px;
  padding: 14px 20px 6px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--ink-900);
  font-weight: 700;
}
.sidebar nav > .nav-section:first-child { margin-top: 0; border-top: 0; }
.sidebar a {
  display: block;
  padding: 7px 20px 7px 30px;
  color: var(--ink-700);
  text-decoration: none;
  font-size: 13.5px;
  border-left: 3px solid transparent;
  transition: background .12s, border-color .12s;
}
.sidebar a:hover {
  background: var(--ink-100);
  color: var(--ink-900);
  text-decoration: none;
}
.sidebar a.active, .sidebar a[aria-current="page"] {
  background: var(--brand-50);
  border-left-color: var(--brand-600);
  color: var(--brand-800);
  font-weight: 600;
}

/* Keyboard focus (WCAG 2.4.7): a 2 px ring in the accent, outside the element. */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, summary:focus-visible, label.menu-toggle:focus-visible {
  outline: 2px solid var(--brand-600);
  outline-offset: 2px;
}

/* Topbar */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 10;
  gap: 16px;
}
.topbar .breadcrumb {
  flex: 1;
  font-size: 13px;
  color: var(--ink-500);
}
.topbar .breadcrumb b { color: var(--ink-900); font-weight: 600; }
.topbar .user-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12.5px;
  color: var(--ink-700);
}
.topbar .user-chip .role {
  display: inline-block;
  padding: 1px 7px;
  background: var(--brand-100);
  color: var(--brand-800);
  border-radius: 10px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .3px;
  text-transform: uppercase;
  margin-left: 6px;
}
.topbar .user-chip .account-link { color: var(--ink-700); white-space: nowrap; }
.topbar form.tenant-switch {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 12px 0 0;
}
.topbar form.tenant-switch select {
  max-width: 220px;
  padding: 4px 6px;
  font-size: 13px;
}
.topbar form.tenant-switch button {
  background: transparent;
  border: 1px solid var(--ink-300);
  color: var(--ink-700);
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
}
.topbar form.tenant-switch .tenant-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-900);
}
.topbar form.logout { margin: 0; }
.topbar form.logout button {
  background: transparent;
  border: 1px solid var(--ink-300);
  color: var(--ink-700);
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
}
.topbar form.logout button:hover {
  border-color: var(--brand-500);
  color: var(--brand-700);
}

/* Main */
main {
  padding: 24px 28px 48px;
  max-width: 1200px;
}
main h1 {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 18px;
  color: var(--ink-900);
}
main h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 24px 0 10px;
  color: var(--ink-900);
}
main p { color: var(--ink-700); }

/* ─────────────────────────────────────────────────────────
 * Cards (stat + content)
 * ───────────────────────────────────────────────────────── */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 18px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--brand-500);
}
.stat-card b {
  display: block;
  font-size: 26px;
  font-weight: 700;
  color: var(--ink-900);
  line-height: 1.1;
  margin-bottom: 4px;
}
.stat-card .label {
  display: block;
  font-size: 12px;
  color: var(--ink-500);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 20px;
}
.panel-header {
  margin: -20px -20px 16px;
  padding: 12px 20px;
  background: linear-gradient(180deg, var(--brand-50), #fff);
  border-bottom: 1px solid var(--border);
  border-radius: 8px 8px 0 0;
  font-weight: 600;
  font-size: 14px;
  color: var(--brand-800);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ─────────────────────────────────────────────────────────
 * Tables
 * ───────────────────────────────────────────────────────── */
table {
  border-collapse: collapse;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
th, td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
}
th {
  background: var(--brand-50);
  color: var(--brand-800);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .4px;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--brand-50); }
tr.is-current td { background: var(--brand-100) !important; }

/* ─────────────────────────────────────────────────────────
 * Forms
 * ───────────────────────────────────────────────────────── */
label {
  display: block;
  font-size: 13px;
  color: var(--ink-700);
  font-weight: 500;
  margin-top: 12px;
}
label > input, label > select, label > textarea {
  display: block;
  margin-top: 4px;
}

input[type=text], input[type=email], input[type=password],
input[type=number], input[type=url], input[type=date], select, textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--ink-300);
  border-radius: 5px;
  font: inherit;
  background: #fff;
  color: var(--ink-900);
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: 0;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(217, 119, 87, .15);
}
input[type=number] { width: 140px; }
input[type=file] {
  width: auto;
  padding: 6px;
  background: var(--ink-100);
  border: 1px dashed var(--ink-300);
}
textarea { min-height: 80px; font-family: var(--font-ui); }

input.short, input[type=text].short { width: 220px; display: inline-block; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.field-row > label { flex: 1; min-width: 200px; margin-top: 0; }

/* ─────────────────────────────────────────────────────────
 * Buttons
 * ───────────────────────────────────────────────────────── */
button, .btn {
  display: inline-block;
  padding: 7px 16px;
  border: 0;
  border-radius: 5px;
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  background: var(--brand-700);
  color: #fff;
  transition: background .12s, transform .05s;
}
button:hover, .btn:hover { background: var(--brand-800); }
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; }

button.btn-secondary, .btn-secondary {
  background: #fff;
  color: var(--ink-700);
  border: 1px solid var(--ink-300);
}
button.btn-secondary:hover { background: var(--ink-100); border-color: var(--brand-500); color: var(--brand-700); }

button.btn-danger, .btn-danger {
  background: var(--danger);
}
button.btn-danger:hover { background: #991b1b; }

button.btn-success, .btn-success { background: var(--success); }
button.btn-success:hover { background: #166534; }

button.btn-sm, .btn-sm { padding: 4px 10px; font-size: 12px; }

/* Inline form (e.g. "delete this row") */
form.inline { display: inline; margin: 0; }

/* ─────────────────────────────────────────────────────────
 * Tags / badges
 * ───────────────────────────────────────────────────────── */
.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .2px;
  background: var(--ink-100);
  color: var(--ink-700);
}
.tag-sip   { background: var(--info-bg);    color: var(--info); }
.tag-pjsip { background: #ede9fe;           color: #6d28d9; }
.tag-iax2  { background: var(--warning-bg); color: var(--warning); }
.tag-tls   { background: var(--success-bg); color: var(--success); }
.tag-udp   { background: var(--ink-100);    color: var(--ink-500); }

.alert {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 13.5px;
  border: 1px solid transparent;
}
.alert-error { background: var(--danger-bg);  color: #991b1b; border-color: #fecaca; }
.alert-ok    { background: var(--success-bg); color: var(--success); border-color: #bbf7d0; }
.alert-warn  { background: var(--warning-bg); color: var(--warning); border-color: #fde68a; }

.mono { font-family: var(--font-mono); font-size: 12px; }
.muted { color: var(--ink-500); }
.small { font-size: 12px; }

.hint {
  background: var(--brand-50);
  border-left: 3px solid var(--brand-500);
  padding: 10px 14px;
  margin: 0 0 16px;
  border-radius: 0 6px 6px 0;
  color: var(--ink-700);
  font-size: 13px;
}

/* ─────────────────────────────────────────────────────────
 * Call detail
 * ───────────────────────────────────────────────────────── */
.dl-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 6px 16px;
  margin: 0;
}
.dl-grid dt {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--ink-500);
  padding: 4px 0;
}
.dl-grid dd {
  margin: 0;
  padding: 4px 0;
}

.transcript-box {
  max-height: 400px;
  overflow-y: auto;
  padding-top: 12px;
}
.transcript-turn {
  margin: 0 0 8px;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 13px;
  line-height: 1.5;
}
.turn-user { background: var(--surface); }
.turn-agent { background: var(--ink-100); }

/* Clickable table rows */
tr.clickable td:first-child a {
  color: inherit;
  text-decoration: none;
}
tr.clickable:hover td {
  background: var(--brand-50);
  cursor: pointer;
}

@media (max-width: 600px) {
  .transcript-box { max-height: 60vh; }
  .dl-grid { grid-template-columns: 1fr; }
}

/* ─────────────────────────────────────────────────────────
 * Login
 * ───────────────────────────────────────────────────────── */
body.auth {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--brand-900) 0%, var(--brand-700) 100%);
}
.auth-card {
  background: var(--surface);
  padding: 32px 36px;
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,.25);
  width: 360px;
  position: relative;
  overflow: hidden;
}
.auth-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--brand-500);
}
.auth-card .auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}
.auth-card .auth-brand .dot {
  width: 28px; height: 28px;
  background: var(--brand-500);
  border-radius: 7px;
}
.auth-card h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink-900);
}
.auth-card h1 small {
  display: block;
  font-weight: 400;
  font-size: 12px;
  color: var(--ink-500);
  margin-top: 2px;
}
.auth-card button { width: 100%; margin-top: 18px; padding: 10px; }

/* ─────────────────────────────────────────────────────────
 * Responsive — collapse sidebar under 900px
 * ───────────────────────────────────────────────────────── */
.menu-toggle { display: none; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; left: -100%;
    width: 240px;
    z-index: 100;
    transition: left .2s ease-out;
    box-shadow: 2px 0 12px rgba(0,0,0,.2);
  }
  #nav-toggle:checked ~ .app .sidebar { left: 0; }
  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    background: transparent;
    border: 1px solid var(--ink-300);
    border-radius: 5px;
    cursor: pointer;
    margin-right: 8px;
  }
  .menu-toggle::before {
    content: "";
    width: 16px; height: 12px;
    background:
      linear-gradient(var(--ink-700), var(--ink-700)) 0 0/100% 2px no-repeat,
      linear-gradient(var(--ink-700), var(--ink-700)) 0 50%/100% 2px no-repeat,
      linear-gradient(var(--ink-700), var(--ink-700)) 0 100%/100% 2px no-repeat;
  }
  main { padding: 18px 16px 32px; }
  .topbar { padding: 0 12px; }
  .topbar .user-chip .email { display: none; }
}

@media (max-width: 600px) {
  .topbar .user-chip .role { display: none; }
  table { font-size: 12.5px; }
  th, td { padding: 8px 10px; }
}

/* Create forms folded behind a button (sip_trunks.html) */
details.create-form { margin: 16px 0; }
details.create-form > summary { display: inline-block; list-style: none; cursor: pointer; }
details.create-form > summary::-webkit-details-marker { display: none; }
details.create-form[open] > summary { margin-bottom: 8px; }

/* Read-only forms for users who can view but not edit (V1a.4). */
fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; }

/* V2d.15: opening hours day by day */
.hours-week { border-collapse: collapse; margin: 4px 0; }
.hours-week th { text-align: left; font-weight: 500; padding: 2px 12px 2px 0; width: 110px; }
.hours-week td { padding: 2px 0; }
.hours-week input { margin: 0; }

/* PC F6: «Ayuda» */
.help h3 { margin-top: 1rem; }
.help .ui { font-weight: 600; }
.help-toc ol { columns: 2; padding-left: 1.2rem; }
@media (max-width: 700px) { .help-toc ol { columns: 1; } }
@media print {
  .sidebar, .topbar, .help-toc { display: none !important; }
  .app { display: block !important; }
  .help { break-inside: avoid-page; box-shadow: none !important; border: 0 !important; }
}

/* MB2 (white label): the client's logo in the sidebar (white since 2026-11-03). */
.sidebar .brand.has-logo::before { display: none; }
.sidebar .brand .brand-logo {
  display: block;
  /* MBL: fixed box (32 px high, 160 px wide); any accepted ratio (1:1 to 5:1) fits. */
  max-height: 32px;
  max-width: 160px;
  width: auto;
  height: auto;
  object-fit: contain;
  flex-shrink: 0;
}

/* MBL: previews on «Marca» and «Marcas», in the same boxes as the panel. */
.brand-preview {
  max-height: 64px;
  max-width: 320px;
  width: auto;
  height: auto;
  object-fit: contain;
  background: #fff;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.brand-preview-icon {
  width: 64px;
  height: 64px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
}
