/* ─── CallTranscribe Super-Admin — CallTech design system · RTL Hebrew ───
 *
 * House style: VolcAIno purple brand (#6346ff — identical to the customer
 * UI), system font stack (100% offline —
 * no remote/CDN fonts), white surfaces on a cool page background, soft
 * shadows, 6px controls / 12–16px cards. All legacy class names and custom
 * property names are preserved (templates reference them via inline
 * style="var(--…)"); legacy tokens are aliased to the CallTech scale below.
 * ─────────────────────────────────────────────────────────────────────── */

:root {
  /* ── CallTech tokens ────────────────────────────────────────────── */
  /* Brand — teal */
  /* Brand — the VolcAIno purple scale, IDENTICAL to the customer UI
   * (styles.css purple theme). The admin must feel like the same product. */
  --brand-500: #6346ff;   /* primary */
  --brand-600: #5530f5;   /* hover */
  --brand-700: #4421d4;   /* active */
  --brand-400: #8b73ff;
  --brand-200: #cdc1ff;   /* accent border */
  --brand-100: #e6e0ff;   /* soft accent */
  --brand-50:  #f3f0ff;   /* surface tint / hover bg */

  /* Ink — text scale */
  --ink-900: #0f172a;
  --ink-700: #334155;
  --ink-500: #64748b;
  --ink-400: #94a3b8;

  /* Lines */
  --line-200: #e2e8f0;
  --line-100: #eef2f7;

  /* Surfaces */
  --bg-page: #f6f8fb;
  --surface: #ffffff;

  /* Status */
  --danger: #dc2626;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Shadows */
  --shadow-1: 0 1px 2px rgba(15,23,42,.04), 0 1px 3px rgba(15,23,42,.06);
  --shadow-2: 0 4px 16px rgba(15,23,42,.06), 0 2px 4px rgba(15,23,42,.04);
  --shadow-brand: 0 2px 6px rgba(99,70,255,.25);

  /* Type */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI",
          system-ui, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Consolas,
               "Courier New", monospace;

  /* ── Legacy aliases (consumed by inline style="" in templates) ──── */
  /* Primary — remapped from the old purple to the CallTech teal scale */
  --primary-50:  var(--brand-50);
  --primary-100: var(--brand-100);
  --primary-200: var(--brand-200);
  --primary-400: var(--brand-400);
  --primary-500: var(--brand-500);
  --primary-600: var(--brand-600);
  --primary-700: var(--brand-700);
  /* Exact gradient from the customer UI. */
  --primary-grad: linear-gradient(135deg, #6346ff 0%, #8b6dff 100%);

  /* Surfaces */
  --bg:          var(--bg-page);
  --bg-deep:     var(--line-100);
  --surface-2:   #f8fafc;
  --stroke:      var(--line-200);
  --stroke-strong: #cbd5e1;

  /* Text */
  --text:     var(--ink-900);
  --text-2:   var(--ink-700);
  --text-3:   var(--ink-500);
  --text-4:   var(--ink-400);
  --text-inv: #ffffff;

  /* Semantic */
  --success:    #16a34a;
  --success-bg: #ecfdf5;
  --danger-bg:  #fef2f2;
  --warn:       #d97706;
  --warn-bg:    #fffbeb;
  --info:       var(--brand-700);
  --info-bg:    var(--brand-50);

  /* Radius aliases */
  --r-sm:   var(--radius-sm);
  --r-md:   10px;
  --r-lg:   var(--radius-lg);
  --r-xl:   var(--radius-xl);
  --r-pill: 999px;

  /* Shadow aliases */
  --shadow-sm: var(--shadow-1);
  --shadow-md: var(--shadow-2);
  --shadow-lg: 0 12px 36px rgba(15,23,42,.10);
}

/* ── Reset & base ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { background: var(--bg-page); }
body {
  font-family: var(--font);
  font-size: 13px;
  color: var(--ink-900);
  background: var(--bg-page);
  direction: rtl;
  text-align: right;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 2px;
}

/* English / numbers / code in Hebrew context — LTR isolated */
.num, .en {
  direction: ltr;
  unicode-bidi: isolate;
  font-variant-numeric: tabular-nums;
}
code, pre, .mono {
  font-family: var(--font-mono);
  direction: ltr;
  unicode-bidi: isolate;
  font-size: 0.92em;
}
code {
  background: var(--line-100);
  border: 1px solid var(--line-200);
  padding: 0.05em 0.4em;
  border-radius: 4px;
  color: var(--ink-700);
}
pre.codeblock {
  background: var(--ink-900);
  color: #e2e8f0;
  border-radius: var(--r-md);
  padding: 14px 18px;
  overflow-x: auto;
  white-space: pre;
  margin: 14px 0;
  direction: ltr;
  unicode-bidi: isolate;
  box-shadow: var(--shadow-1);
}
pre.codeblock.token {
  background: linear-gradient(180deg, #063749 0%, #04222e 100%);
  border: 1px solid var(--brand-500);
  color: #ffffff;
  font-size: 1.05rem;
  user-select: all;
  word-break: break-all;
  white-space: pre-wrap;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow-brand);
}

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

button, input, textarea, select { font-family: inherit; }

/* ── Topbar ─────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  /* Hebrew layout: everything anchors to the RIGHT (dir=rtl flows the
   * brand first, nav right beside it). No space-between — that pushed
   * the menu to the far left, which reads wrong on an RTL site. */
  justify-content: flex-start;
  gap: 24px;
  height: 80px;
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line-200);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  font-size: 17px;
  color: var(--ink-900);
  letter-spacing: -0.2px;
}
.topbar .brand:hover { text-decoration: none; }
.topbar .brand .dot {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--primary-grad);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  box-shadow: var(--shadow-brand);
}
.topbar .brand .dot::after {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 3px solid #ffffff;
}
/* The real product logo (volcaino-logo.png) replaces the abstract dot. */
.topbar .brand .brand-logo {
  height: 36px;
  width: auto;
  display: block;
}
.topbar .brand .tag {
  font-size: 11px;
  font-weight: 500;
  color: var(--brand-600);
  background: var(--brand-50);
  border: 1px solid var(--brand-100);
  padding: 3px 10px;
  border-radius: var(--r-pill);
}
.topbar nav {
  display: flex;
  gap: 6px;
}
/* Logged-in chip + logout — anchored to the far (left) end of the RTL row. */
.topbar .logout-form {
  margin-inline-start: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.topbar .whoami {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-500);
  background: var(--line-100);
  border: 1px solid var(--line-200);
  padding: 4px 12px;
  border-radius: var(--r-pill);
}
.topbar .logout-btn {
  height: 34px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: var(--ink-700);
  background: var(--surface);
  border: 1px solid var(--line-200);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.topbar .logout-btn:hover {
  background: var(--brand-50);
  border-color: var(--brand-200);
  color: var(--brand-600);
}
.topbar nav a {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  color: var(--ink-700);
  font-size: 13px;
  font-weight: 500;
  transition: background 120ms, color 120ms, border-color 120ms;
}
.topbar nav a:hover {
  background: var(--brand-50);
  border-color: var(--brand-200);
  color: var(--brand-600);
  text-decoration: none;
}
.topbar nav a.active {
  background: var(--brand-50);
  border-color: var(--brand-200);
  color: var(--brand-600);
  font-weight: 600;
}

/* ── Layout ─────────────────────────────────────────────────────────── */
.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 32px 56px;
}
.footer {
  text-align: center;
  color: var(--ink-400);
  padding: 24px 16px 36px;
  font-size: 12px;
}

h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.4px; margin: 0 0 6px; }
h2 { font-size: 17px; font-weight: 600; letter-spacing: -0.2px; margin: 22px 0 12px; }
h3 { font-size: 14px; font-weight: 600; color: var(--ink-700); margin: 16px 0 8px; }
p.muted, .muted { color: var(--ink-500); }
.warn-text { color: var(--warn); }

/* ── Hero ───────────────────────────────────────────────────────────── */
.hero {
  background:
    radial-gradient(900px 180px at 100% 0%, rgba(0, 174, 239, 0.08), transparent 65%),
    var(--surface);
  border: 1px solid var(--line-200);
  border-radius: var(--radius-xl);
  padding: 24px 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-2);
}
.hero h1 { margin-bottom: 8px; }
.hero p { margin: 0; }

/* ── Cards ──────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line-200);
  border-radius: var(--radius-lg);
  padding: 22px 26px;
  margin: 18px 0;
  box-shadow: var(--shadow-2);
}
.card.emphasized {
  border-color: var(--brand-200);
  border-radius: var(--radius-xl);
  box-shadow: 0 0 0 1px var(--brand-100), var(--shadow-2);
}
.card .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  /* RTL: 3px teal section stripe on the RIGHT */
  border-right: 3px solid var(--brand-500);
  padding-right: 12px;
}
.card .card-header h2 { margin: 0; }

/* ── Grids ──────────────────────────────────────────────────────────── */
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.two-uneven { grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr); }

/* ── Forms ──────────────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 14px;
}
.form-grid.two { grid-template-columns: 1fr 1fr; }
.form-grid label {
  display: flex;
  flex-direction: column;
  font-size: 13px;
  color: var(--ink-700);
  font-weight: 500;
  gap: 6px;
}
.form-grid label.inline {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}
.form-grid label small {
  color: var(--ink-500);
  font-size: 12px;
  font-weight: 400;
}
.form-grid input,
.form-grid select,
.form-inline input,
.form-inline select,
.form-grid textarea {
  background: var(--surface);
  color: var(--ink-900);
  border: 1px solid var(--line-200);
  border-radius: var(--radius-sm);
  min-height: 34px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
  transition: border-color 120ms, box-shadow 120ms;
}
.form-grid input:focus,
.form-grid select:focus,
.form-inline input:focus,
.form-inline select:focus,
.form-grid textarea:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(0, 174, 239, 0.18);
}
.form-grid input::placeholder,
.form-inline input::placeholder { color: var(--ink-400); }

.form-actions { display: flex; gap: 10px; align-items: center; }
.form-actions.full { grid-column: 1 / -1; }
.form-inline {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 14px 0;
}
.form-inline input { flex: 1; min-width: 240px; }

/* ── Buttons ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  background: var(--surface);
  color: var(--ink-700);
  border: 1px solid var(--line-200);
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  transition: background 120ms, color 120ms, border-color 120ms, box-shadow 120ms;
  white-space: nowrap;
}
.btn:hover {
  background: var(--brand-50);
  border-color: var(--brand-200);
  color: var(--brand-600);
  text-decoration: none;
}
.btn:disabled,
.btn[disabled] {
  background: var(--line-200);
  border-color: var(--line-200);
  color: var(--ink-400);
  cursor: not-allowed;
  box-shadow: none;
}
.btn.primary {
  background: var(--brand-500);
  border-color: var(--brand-500);
  color: #ffffff;
  box-shadow: var(--shadow-brand);
  font-weight: 600;
}
.btn.primary:hover {
  background: var(--brand-600);
  border-color: var(--brand-600);
  color: #ffffff;
}
.btn.primary:active { background: var(--brand-700); border-color: var(--brand-700); }
.btn.small { min-height: 28px; padding: 3px 12px; font-size: 12px; }
.btn.danger {
  background: var(--surface);
  border-color: #fecaca;
  color: var(--danger);
}
.btn.danger:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger);
}
.btn.copy {
  background: var(--brand-50);
  border-color: var(--brand-200);
  color: var(--brand-600);
}
.btn.copy:hover {
  background: var(--brand-500);
  border-color: var(--brand-500);
  color: #ffffff;
}

/* ── Tables ─────────────────────────────────────────────────────────── */
.grid-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--line-200);
  border-radius: 10px;
  overflow: hidden;
  margin: 14px 0;
  box-shadow: var(--shadow-1);
}
.grid-table th,
.grid-table td {
  text-align: right;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line-200);
  font-size: 13px;
  vertical-align: middle;
}
.grid-table th {
  background: #f8fafc;
  color: var(--ink-500);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.grid-table tr:last-child td { border-bottom: none; }
.grid-table tbody tr:hover td { background: var(--brand-50); }
.grid-table td.actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.grid-table td.actions form { margin: 0; }

/* ── Scrollable log container (transcription & cost log) ─────────────
   Keeps long per-call logs inside a fixed-height viewport instead of
   stretching the page. The table header stays pinned while scrolling. */
.log-scroll {
  max-height: 480px;
  overflow-y: auto;
  border: 1px solid var(--line-200);
  border-radius: 10px;
  box-shadow: var(--shadow-1);
  margin: 14px 0;
}
.log-scroll .grid-table {
  margin: 0;
  border: none;
  border-radius: 0;
  box-shadow: none;
}
.log-scroll .grid-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  /* Solid paint — rows must not bleed through while scrolling under it. */
  background: #f1f5f9;
  box-shadow: 0 1px 0 var(--line-200);
}

/* ── Pills / badges ─────────────────────────────────────────────────── */
.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-200);
  background: #f8fafc;
  color: var(--ink-500);
  font-size: 11.5px;
  font-weight: 500;
}
.pill.ok     { background: var(--success-bg); border-color: #a7f3d0;      color: #15803d; }
.pill.warn   { background: var(--warn-bg);    border-color: #fde68a;      color: #b45309; }
.pill.role   { background: var(--brand-50);   border-color: var(--brand-200); color: var(--brand-600); }
.pill.hebrew { background: var(--line-100);   border-color: var(--line-200); color: var(--ink-700); }

/* ── Tenant detail header ───────────────────────────────────────────── */
.breadcrumb { color: var(--ink-500); margin-bottom: 12px; font-size: 13px; }
.breadcrumb a { color: var(--ink-500); }
.breadcrumb a:hover { color: var(--brand-600); }
.tenant-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  padding: 22px 26px;
  background: var(--surface);
  border: 1px solid var(--line-200);
  border-radius: var(--radius-xl);
  border-right: 3px solid var(--brand-500);
  box-shadow: var(--shadow-2);
}

/* ── Flashes (dismissable) ──────────────────────────────────────────── */
.flashes {
  list-style: none;
  padding: 0;
  margin: 0 0 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.flash {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line-200);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  animation: flashIn 220ms ease;
}
.flash .flash-msg { flex: 1; }
.flash .flash-dismiss {
  background: transparent;
  border: 0;
  color: inherit;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.55;
  padding: 2px 6px;
  border-radius: 4px;
  transition: opacity 120ms, background 120ms;
}
.flash .flash-dismiss:hover { opacity: 1; background: rgba(15, 23, 42, 0.06); }
.flash.ok {
  background: var(--success-bg);
  border-color: #a7f3d0;
  color: #166534;
}
.flash.error {
  /* white panel + 4px danger stripe on the RIGHT (RTL) */
  background: var(--surface);
  border-color: #fecaca;
  border-right: 4px solid var(--danger);
  color: #7f1d1d;
}
.flash.warning {
  background: var(--warn-bg);
  border-color: #fde68a;
  color: #92400e;
}
.flash.message {
  background: var(--surface);
  border-color: var(--line-200);
  color: var(--ink-900);
}
@keyframes flashIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Section dividers ───────────────────────────────────────────────── */
.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 28px 0 8px;
  /* RTL: 3px teal section stripe on the RIGHT */
  border-right: 3px solid var(--brand-500);
  padding-right: 12px;
}
.section-title .badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  background: var(--brand-500);
  color: #ffffff;
  border-radius: var(--r-pill);
  font-weight: 600;
  font-size: 13px;
  box-shadow: var(--shadow-brand);
}
.section-title h2 { margin: 0; }

/* ── Empty state ────────────────────────────────────────────────────── */
.empty {
  border: 1px dashed var(--stroke-strong);
  border-radius: var(--r-md);
  padding: 24px;
  text-align: center;
  color: var(--ink-500);
  background: var(--surface-2);
}

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 960px) {
  .grid.two,
  .grid.two-uneven { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
    height: auto;
    padding: 12px 16px;
    gap: 10px;
  }
  .topbar nav { flex-wrap: wrap; }
  .container { padding: 18px 16px 56px; }
  .form-grid.two { grid-template-columns: 1fr; }
  .tenant-head { flex-direction: column; }
  .grid-table { display: block; overflow-x: auto; }
}
