/* =====================================================================
   base.css — the single, tokenized definition of shared base components.

   Reset, links, form controls, buttons, badges, role badge, modal, toast
   and the custom scrollbar — reconciled from the previously divergent
   copies in app.css / styles.css into one definition each.

   Loaded AFTER tokens.css (which supplies every var(--…)) so both light and
   dark themes flow automatically — there are no per-component theme
   overrides here. Product- and admin-specific components (cards, tables,
   call UI, …) stay in their own page stylesheets.
   ===================================================================== */

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

/* Form elements don't inherit typography by default. */
button, input, select, textarea { font: inherit; }

/* ── Icon font (self-hosted Material Icons) ────────────────────
   Served locally from /fonts so icons render in environments that can't
   reach Google's font CDN (fonts.gstatic.com would otherwise time out).
   Supplies both the @font-face and the .material-icons ligature base rule
   that the Google-hosted stylesheet previously provided. */
@font-face {
  font-family: 'Material Icons';
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url('/fonts/material-icons.ttf') format('truetype');
}
.material-icons {
  font-family: 'Material Icons';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  font-feature-settings: 'liga';
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Links ─────────────────────────────────────────────────── */
a { color: var(--primary); }

/* ── Form controls ─────────────────────────────────────────────
   Mobile 16px (iOS anti-zoom) is handled once in theme.css — not duplicated. */
input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}
textarea {
  padding: 10px 12px;
  line-height: 1.5;
  resize: vertical;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
select option { background: var(--surface); }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:disabled, button:disabled { opacity: 0.4; cursor: not-allowed; }

/* File-input triggers are <label class="btn">: strip the form-label styling
   (uppercase, letter-spacing, bottom margin) they'd otherwise inherit, so they
   render identically to sibling <button class="btn"> elements. */
label.btn {
  text-transform: none;
  letter-spacing: normal;
  margin-bottom: 0;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-muted); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.btn-success { background: var(--ok-bg); color: var(--ok-fg); border: 1px solid var(--ok-bd); }
.btn-success:hover { filter: brightness(1.08); }

.btn-danger { background: transparent; border: 1px solid var(--err-bd); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

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

.btn-xs { padding: 2px 10px; font-size: 11px; }
.btn-xs:disabled { opacity: 0.35; cursor: default; }

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.badge-admin      { background: var(--warn-bg); border: 1px solid var(--warn-bd); color: var(--warn-fg); }
.badge-user       { background: var(--neutral-bg); border: 1px solid var(--neutral-bd); color: var(--neutral-fg); }
.badge-active     { background: var(--ok-bg); border: 1px solid var(--ok-bd); color: var(--ok-fg); }
.badge-inactive   { background: var(--err-bg); border: 1px solid var(--err-bd); color: var(--err-fg); }
.badge-soon       { background: var(--neutral-bg); border: 1px solid var(--neutral-bd); color: var(--neutral-fg); }
.badge-pending    { background: var(--neutral-bg); border: 1px solid var(--neutral-bd); color: var(--neutral-fg); }
.badge-queued     { background: var(--tintaccent-bg); border: 1px solid var(--tintaccent-bd); color: var(--tintaccent-fg); }
.badge-processing { background: var(--info-bg); border: 1px solid var(--info-bd); color: var(--info-fg); }
.badge-completed  { background: var(--ok-bg); border: 1px solid var(--ok-bd); color: var(--ok-fg); }
.badge-failed     { background: var(--err-bg); border: 1px solid var(--err-bd); color: var(--err-fg); }

/* ── Role badge ────────────────────────────────────────────── */
.role-badge {
  display: inline-block;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--primary);
  white-space: nowrap;   /* keep "Speaker 1" / "Operator" on one line */
}
.role-badge.admin { background: var(--warn-bg); border-color: var(--warn-bd); color: var(--warn-fg); }

/* ── Modal ─────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); }
.modal-box {
  position: relative;
  width: 100%;
  max-width: 440px;
  /* Never exceed the viewport: scroll the box so the action buttons stay
     reachable on short / landscape-phone screens. */
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.modal-title { font-size: 17px; font-weight: 700; color: var(--text); margin-bottom: 24px; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 18px; cursor: pointer; }
.modal-close:hover { color: var(--text); }

/* ── Toast ─────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  animation: slide-in 0.2s ease;
}
.toast.success { background: var(--ok-bg); border: 1px solid var(--ok-bd); color: var(--ok-fg); }
.toast.error   { background: var(--err-bg); border: 1px solid var(--err-bd); color: var(--err-fg); }
.toast.info    { background: var(--info-bg); border: 1px solid var(--info-bd); color: var(--info-fg); }
.toast.warning { background: var(--warn-bg); border: 1px solid var(--warn-bd); color: var(--warn-fg); }
@keyframes slide-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border); }
