/* =============================================================
   Malina — Settings
   All variables use Malina design tokens from tokens.css.
   ============================================================= */

/* ============================================================
   SETTINGS SCREEN — outer section
   ============================================================ */
.settings-screen {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}
.settings-screen.active { display: flex; }

/* ============================================================
   SETTINGS HEAD
   ============================================================ */
.settings-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px;
  padding: 22px 28px 16px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.settings-head-text { min-width: 0; flex: 1; }
.settings-crumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--fg-dim);
  margin-bottom: 6px;
}
.settings-crumb svg { flex-shrink: 0; }
.crumb-link {
  cursor: pointer; color: var(--fg-muted);
  transition: color var(--dur-fast) var(--ease-out);
}
.crumb-link:hover { color: var(--accent); }
.crumb-current { color: var(--fg); font-weight: 500; }
.settings-head h1 {
  font-family: var(--font-display);
  font-size: 28px; font-weight: 500;
  letter-spacing: -0.01em; color: var(--fg); line-height: 1.1; margin: 0;
}
.settings-sub { font-size: 13px; color: var(--fg-muted); margin-top: 4px; }
.settings-head-actions {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}

/* ============================================================
   SETTINGS BODY — flex row: optional rail + content
   ============================================================ */
.settings-body {
  flex: 1; min-height: 0;
  display: flex;
  overflow: hidden;
}

/* ============================================================
   SETTINGS HUB — landing grid of cards
   ============================================================ */
.settings-hub {
  display: flex; flex-direction: column; gap: 26px;
  padding: 24px 28px;
  overflow-y: auto;
  flex: 1;
}
.hub-group-title {
  font-size: 11px; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--fg-dim);
  margin-bottom: 12px;
}
.hub-group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.hub-card {
  background: var(--bg-elev-2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px 22px;
  display: flex; flex-direction: column; gap: 6px;
  cursor: pointer;
  transition: border-color var(--dur-base) var(--ease-out),
              transform var(--dur-base) var(--ease-out),
              box-shadow var(--dur-base) var(--ease-out);
}
.hub-card:hover {
  border-color: var(--accent-border);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.hub-icon {
  width: 40px; height: 40px; border-radius: var(--radius-md);
  background: var(--accent-tint); border: 1px solid var(--accent-border);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent); margin-bottom: 6px; flex-shrink: 0;
}
.hub-label { font-size: 14px; font-weight: 600; color: var(--fg); }
.hub-hint { font-size: 12px; color: var(--fg-muted); line-height: 1.4; }
.hub-cta {
  display: flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; color: var(--accent);
  margin-top: 8px;
}
.hub-cta svg { flex-shrink: 0; }

/* ============================================================
   SETTINGS RAIL — left navigation
   ============================================================ */
/* ============================================================
   SETTINGS CONTENT — full-width pane area (hub-first; no rail)
   ============================================================ */
.settings-content {
  flex: 1; min-width: 0; min-height: 0;
  width: 100%;
  overflow-y: auto; overflow-x: hidden;
  padding: 24px 28px;
}

/* ============================================================
   SETTINGS PANE
   ============================================================ */
.settings-pane { display: block; }
.settings-pane[style*="display:none"] { display: none !important; }

/* ============================================================
   SETTINGS FORM GRID — 2-column card layout
   ============================================================ */
.settings-screen .form-grid,
.settings-pane.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 16px;
  align-content: start;
}
.settings-screen .form-grid .span-2,
.settings-pane.form-grid .span-2 { grid-column: 1 / -1; }

/* ============================================================
   FORM CARD — the white/elevated cards inside settings
   ============================================================ */
.form-card {
  background: var(--bg-elev-2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  display: flex; flex-direction: column;
  transition: border-color var(--dur-fast) var(--ease-out);
}
.form-card:hover { border-color: var(--border-strong); }
.form-card.span-2 { grid-column: 1 / -1; }
.form-card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px;
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.form-card-title {
  font-family: var(--font-display);
  font-size: 16px; font-weight: 500; color: var(--fg);
  letter-spacing: -0.005em; margin: 0;
}
.form-card-sub { font-size: 12px; color: var(--fg-muted); margin-top: 3px; }
.card-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.form-card-body {
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 14px;
}

/* ============================================================
   TEXT INPUT — Settings-style input (wraps native input/select)
   ============================================================ */
.text-input {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-elev-3); border: 1px solid var(--border-strong);
  border-radius: var(--radius-md); padding: 0 12px;
  height: 38px; min-height: 38px;
  transition: border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}
.text-input:focus-within {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px rgba(217,179,108,0.10);
}
.text-input svg { flex-shrink: 0; color: var(--fg-dim); width: 14px; height: 14px; }
.text-input input,
.text-input select,
.text-input textarea {
  flex: 1; min-width: 0;
  background: transparent; border: none; outline: none;
  color: var(--fg); font: inherit; font-size: 13.5px; padding: 0;
}
.text-input input::placeholder { color: var(--fg-dim); }
.text-input select { appearance: none; -webkit-appearance: none; cursor: pointer; }
.text-input.is-mono input,
.text-input.is-mono select { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.caret-icon { pointer-events: none; flex-shrink: 0; color: var(--fg-muted); }
.affix {
  font-size: 11px; font-weight: 600; color: var(--fg-muted);
  cursor: pointer; padding: 4px 8px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); white-space: nowrap;
  transition: all var(--dur-fast) var(--ease-out);
}
.affix:hover { color: var(--accent); border-color: var(--accent-border); background: var(--accent-tint); }

/* ============================================================
   PASSWORD FIELDS — show/hide toggle + live confirm validation
   (Security card `.text-input` fields and form-modal `.form-input`)
   ============================================================ */
.pw-toggle {
  background: none; border: none; cursor: pointer;
  color: var(--fg-dim);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; padding: 8px; margin-right: -8px;
  border-radius: var(--radius-sm);
  transition: color var(--dur-fast) var(--ease-out);
}
.pw-toggle:hover { color: var(--accent); }
.pw-toggle:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(217,179,108,0.18); }
/* beats the generic `.text-input svg` sizing/color at equal specificity */
.pw-toggle svg { width: 15px; height: 15px; display: block; color: inherit; }

/* Form-modal variant: the input keeps its own border, toggle overlays inside */
.fm-pass-wrap { position: relative; display: flex; align-items: center; }
.fm-pass-wrap .form-input { flex: 1; padding-right: 40px; }
.fm-pass-wrap .pw-toggle { position: absolute; right: 8px; margin: 0; }

/* Inline "Passwords do not match" message under a confirm field */
.fm-field-error {
  color: var(--danger); font-size: 12px; line-height: 1.35; margin-top: 4px;
}
.fm-field-error:empty { display: none; }

/* ============================================================
   FILTER ROW — inside form-card-body
   ============================================================ */
.filter-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}

/* ============================================================
   SVC TABLE — Services & Pricing pane
   ============================================================ */
.svc-table { display: flex; flex-direction: column; }
.svc-row.svc-head {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto auto 72px;
  padding: 8px 12px;
  font-size: 10px; font-weight: 700; color: var(--fg-dim);
  text-transform: uppercase; letter-spacing: 0.07em;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev-3);
}
.svc-row:not(.svc-head) {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto auto 72px;
  padding: 10px 12px;
  align-items: center;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px; color: var(--fg-muted);
  transition: background 0.12s;
}
.svc-row:not(.svc-head):hover { background: var(--bg-elev-3); }
.svc-row:not(.svc-head):last-child { border-bottom: none; }
.ta-right { text-align: right; }
.ta-center { text-align: center; }

/* ============================================================
   NOTIF TABLE — Notifications pane
   ============================================================ */
.notif-table { display: flex; flex-direction: column; }
.notif-row {
  display: grid;
  grid-template-columns: 1fr 80px 80px 80px;
  padding: 10px 0;
  align-items: center;
  border-bottom: 1px solid var(--border-soft);
  gap: 8px;
}
.notif-row:last-child { border-bottom: none; }
.notif-row.notif-head {
  font-size: 10px; font-weight: 700; color: var(--fg-dim);
  text-transform: uppercase; letter-spacing: 0.07em;
  padding: 6px 0 10px;
}
.notif-label { font-size: 13px; font-weight: 500; color: var(--fg); }
.notif-hint { font-size: 11px; color: var(--fg-dim); margin-top: 2px; }

/* ============================================================
   INTEG GRID — Integrations pane
   ============================================================ */
.integ-grid {
  display: flex; flex-direction: column; gap: 10px;
}
.integ-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: var(--radius-md);
  border: 1px solid var(--border); background: var(--bg-elev-3);
  transition: border-color 0.15s;
}
.integ-card:hover { border-color: var(--accent-border); }
.integ-card.connected { border-color: rgba(95,181,138,0.28); }
.integ-mark {
  width: 36px; height: 36px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.integ-body { flex: 1; min-width: 0; }
.integ-name { font-size: 13px; font-weight: 600; color: var(--fg); }
.integ-desc { font-size: 11px; color: var(--fg-dim); margin-top: 2px; }
.status-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 600;
  background: var(--bg-elev-2); border: 1px solid var(--border);
  color: var(--fg-muted); white-space: nowrap; flex-shrink: 0;
}
.status-chip.is-on { background: var(--success-tint); border-color: rgba(95,181,138,0.28); color: var(--success); }
.status-chip .dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }

/* ============================================================
   CHIP ROW & EVENT CHIPS — API section
   ============================================================ */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.event-chip {
  font-size: 11px; font-weight: 600;
  background: var(--bg-elev-3); border: 1px solid var(--border);
  color: var(--fg-dim); padding: 4px 10px; border-radius: var(--radius-pill);
  font-family: var(--font-mono);
}

/* ============================================================
   BRANDING ROW — Business Profile pane
   ============================================================ */
.branding-row {
  display: flex; align-items: flex-start; gap: 28px; flex-wrap: wrap;
}
.logo-slot {
  display: flex; align-items: center; gap: 16px;
  flex: 1; min-width: 200px;
}
.logo-disc {
  width: 56px; height: 56px; border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--gold-200), var(--gold-400));
  color: var(--accent-ink); display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 600; font-size: 24px;
  flex-shrink: 0;
}
.logo-info { min-width: 0; flex: 1; }
.logo-name { font-size: 13px; font-weight: 600; color: var(--fg); }
.logo-sub { font-size: 11px; color: var(--fg-dim); margin-top: 3px; }
.swatches { flex: 1; min-width: 160px; }
.swatch.is-on { border-color: var(--fg); }

/* ============================================================
   TOGGLE LABEL / HINT inside settings (quiet hours)
   ============================================================ */
.toggle-label { font-size: 14px; font-weight: 600; color: var(--fg); }
.toggle-hint { font-size: 12px; color: var(--fg-muted); margin-top: 2px; }
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 12px 0; cursor: pointer;
}
.toggle-row + .toggle-row { border-top: 1px solid var(--border-soft); }
.toggle-row:hover .toggle-label { color: var(--accent); }

/* ============================================================
   SETTINGS SECTION TITLE (used by old legacy settings grid)
   ============================================================ */
.settings-section-title {
  font-family: var(--font-display); font-weight: 500;
  font-size: var(--fs-2xl); letter-spacing: -0.005em;
  color: var(--fg); margin: 0 0 18px 0; line-height: var(--lh-snug);
}
.settings-section-sub {
  font-size: var(--fs-sm); color: var(--fg-muted);
  margin-top: 4px; margin-bottom: 18px;
}

/* ============================================================
   SETTINGS GROUP (legacy card-style containers)
   ============================================================ */
.settings-group {
  background: var(--bg-elev-1); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 18px;
}
.settings-group-head {
  padding: 14px 18px 10px; border-bottom: 1px solid var(--border-soft);
}
.settings-group-head .label {
  font-size: 10.5px; font-weight: 600; letter-spacing: var(--tracking-caps);
  text-transform: uppercase; color: var(--fg-muted);
}
.settings-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 14px 18px;
  transition: background var(--dur-fast) var(--ease-out);
}
.settings-row + .settings-row { border-top: 1px solid var(--border-soft); }
.settings-row:hover { background: var(--bg-elev-2); }
.settings-row-label { font-size: 14px; font-weight: 500; color: var(--fg); }
.settings-row-desc { font-size: 12px; color: var(--fg-muted); margin-top: 2px; }

/* ============================================================
   SETTINGS CARD (supplement override-friendly)
   ============================================================ */
.settings-card {
  background: var(--bg-elev-2); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 20px; display: flex;
  flex-direction: column; gap: 14px;
  transition: border-color var(--dur-base) ease, box-shadow var(--dur-base) ease;
}
.settings-card:hover {
  border-color: var(--accent-border);
  box-shadow: 0 4px 20px rgba(0,0,0,0.24);
}
.settings-card-title { font-size: 14px; font-weight: 600; color: var(--fg); padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.settings-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px; padding: 16px 20px;
}

/* ============================================================
   DANGER ZONE
   ============================================================ */
.danger-zone {
  background: var(--danger-tint); border: 1px solid var(--danger);
  border-radius: var(--radius-lg); padding: 20px 22px; margin-top: 24px;
}
.danger-zone-title {
  font-size: 13px; font-weight: 600; letter-spacing: var(--tracking-caps);
  text-transform: uppercase; color: var(--danger); margin-bottom: 10px;
}
.danger-zone-body {
  font-size: 13px; color: var(--fg-muted); line-height: var(--lh-relaxed); margin-bottom: 16px;
}
.danger-zone-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ============================================================
   RESPONSIVE — collapse the rail + single-column cards on narrow widths.
   In section view the rail is the only in-page nav; on mobile we hide it
   and rely on the always-visible "Settings" breadcrumb to return to the hub,
   giving the content pane the full width instead of crushing it.
   ============================================================ */
@media (max-width: 768px) {
  .settings-content { padding: 16px; }
  .settings-hub { padding: 16px; gap: 20px; }
  .hub-group-grid { grid-template-columns: 1fr; }
  .settings-screen .form-grid,
  .settings-pane.form-grid { grid-template-columns: 1fr; }
  .form-card-head { padding: 14px 16px 12px; }
  .form-card-body { padding: 14px 16px; }
}

/* ── Exchange-rate editor (Business Profile, brief 1.4) ─────────────────────── */
.rates-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
  margin-top: 6px;
}
.rate-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
}
.rate-row .rate-code { font-size: 12px; color: var(--fg-muted); white-space: nowrap; min-width: 64px; }
.rate-row .rate-eq   { font-size: 12px; color: var(--fg-dim); }
.rate-row .rate-input { width: 100%; text-align: right; }
.rate-row .rate-input[readonly] { opacity: 0.6; cursor: not-allowed; }
@media (max-width: 768px) { .rates-grid { grid-template-columns: 1fr; } }

/* ── Taxonomy drill-down: Specialty → Category → Service ──────────────────────
   Three linked columns. Selecting in one loads the next, so the parent chain is
   always visible — the previous UI showed each tier as an isolated table and the
   hierarchy was invisible until you opened an edit modal.
   Columns collapse to a stack on narrow screens (see the media query below).
   ========================================================================== */
.tax-cols {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
}

.tax-col {
  display: flex;
  flex-direction: column;
  min-width: 0;                 /* let long names ellipsize instead of stretching the grid */
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  overflow: hidden;
}

.tax-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-elev-1, var(--surface-2));
}
.tax-col-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-dim);
  white-space: nowrap;
}
.tax-col-count { font-size: 11px; color: var(--fg-dim); }

/* Fixed height keeps the three columns aligned no matter how uneven the
   contents are; each scrolls independently. */
.tax-col-body {
  flex: 1;
  min-height: 220px;
  max-height: 420px;
  overflow-y: auto;
  padding: 6px;
}

.tax-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 10px;
  margin-bottom: 4px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: var(--fg);
  transition: background 0.12s ease, border-color 0.12s ease;
}
.tax-item:hover { background: var(--accent-tint); }
.tax-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tax-item.is-selected {
  background: var(--accent-tint-2);
  border-color: var(--accent-border);
}
/* Leaf rows (services) are not drill targets — no pointer affordance. */
.tax-item.is-leaf { cursor: default; }
.tax-item.is-leaf:hover { background: transparent; }

.tax-item-main { flex: 1; min-width: 0; }
.tax-item-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tax-item-sub { font-size: 11px; color: var(--fg-dim); margin-top: 1px; }
.tax-item-actions { display: flex; gap: 2px; flex-shrink: 0; opacity: 0; transition: opacity 0.12s ease; }
.tax-item:hover .tax-item-actions,
.tax-item.is-selected .tax-item-actions,
.tax-item:focus-within .tax-item-actions { opacity: 1; }
/* Touch has no hover — actions must be permanently visible or unreachable. */
@media (hover: none) { .tax-item-actions { opacity: 1; } }

.tax-empty {
  padding: 24px 14px;
  text-align: center;
  color: var(--fg-dim);
  font-size: 12px;
  line-height: 1.5;
}
.tax-empty-title { font-weight: 600; color: var(--fg-muted); margin-bottom: 4px; }

.tax-col-foot { padding: 8px; border-top: 1px solid var(--border-soft); }
.tax-col-foot .btn { width: 100%; justify-content: center; }

/* Legacy categories with no parent specialty, surfaced for one-click triage
   rather than left invisible. */
.tax-unassigned-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid var(--accent-border);
  background: var(--accent-tint);
  border-radius: 8px;
  font-size: 12px;
  color: var(--fg-muted);
}
.tax-unassigned-banner strong { color: var(--fg); }

@media (max-width: 900px) {
  .tax-cols { grid-template-columns: 1fr; }
  .tax-col-body { max-height: 300px; min-height: 0; }
}
