/* =========================================================================
   Atheer · SaaS-Polish Layer (J.3)
   -------------------------------------------------------------------------
   Modern, compact, professional form + settings layout. Loaded LAST so it
   refines without touching existing components. Fixes:
     • Settings forms taking full page width with massive inputs
     • Single-column field cards that look "1990s admin panel"
     • Inconsistent spacing across pages
     • Heavy borders / oversized typography
   ========================================================================= */


/* ──────────────────────────────────────────────────────────────────────────
   §1 · Page rhythm — constrain readable width on dense settings pages
   ──────────────────────────────────────────────────────────────────────────
   Yeastar P-Series uses a max-width for dense forms; we mirror that. Pure
   list/table pages stay full-width for data density.
   ────────────────────────────────────────────────────────────────────────── */
.page,
.page-wrap,
.page-content {
  max-width: 1600px;
  margin-inline: auto;
}

/* GLOBAL SAFETY NET: any legacy `material-symbols-outlined` span renders with the
   LOADED "Material Symbols Rounded" font so its ligature (e.g. a chevron) shows as
   a real glyph — never raw text like "expand_more". Applies across every section. */
.material-symbols-outlined {
  font-family: "Material Symbols Rounded", "Material Symbols Outlined";
  font-weight: normal; font-style: normal; line-height: 1;
  letter-spacing: normal; text-transform: none; white-space: nowrap;
  word-wrap: normal; direction: ltr; -webkit-font-smoothing: antialiased;
  font-feature-settings: "liga"; -webkit-font-feature-settings: "liga";
}

/* Settings/Form pages → narrower & centered for readability */
.page--settings,
.page[data-template="settings"],
.page-content--settings,
section.page:has(.settings-group),
section.page:has(.form-section) {
  max-width: 900px;
}


/* ──────────────────────────────────────────────────────────────────────────
   §2 · Cards — refined elevation + spacing
   ────────────────────────────────────────────────────────────────────────── */
.card,
.settings-card,
.settings-group,
.form-section {
  background: var(--surface-1, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  padding: 20px 22px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.card + .card,
.settings-card + .settings-card,
.settings-group + .settings-group,
.form-section + .form-section {
  margin-top: 16px;
}

/* Section title within a card */
.card-title,
.section-title,
.form-section__title,
.settings-group__title,
.settings-card__title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border, #e5e7eb);
}


/* ──────────────────────────────────────────────────────────────────────────
   §3 · Settings rows — TWO-COLUMN layout (label | control)
   ──────────────────────────────────────────────────────────────────────────
   This is THE key fix for the "auto-defense" screenshot: rows now display
   as label on one side, compact control on the other — instead of a single
   full-width "label + input stacked" pattern.
   ────────────────────────────────────────────────────────────────────────── */
.settings-row,
.settings-card .field,
.settings-group .field,
.form-section .field,
.settings-group__row,
.kvrow,
.form-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(180px, 320px);
  gap: 14px 20px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border, #f1f5f9);
}

.settings-row:last-child,
.settings-card .field:last-child,
.settings-group .field:last-child,
.form-section .field:last-child,
.kvrow:last-child,
.form-row:last-child {
  border-bottom: none;
}

/* The label side */
.settings-row > label,
.settings-row__label,
.settings-card .field > span:first-child,
.settings-group .field > span:first-child,
.form-section .field > span:first-child,
.kvrow > label,
.form-row > label,
.form-row > .field__label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.5;
}

/* Field labels marked with required */
.field > span:first-child[data-required]::after,
.required::after {
  content: " *";
  color: var(--status-error, #dc2626);
}

/* Helper/hint text under a label */
.settings-row__hint,
.field__hint,
.field-hint,
.field > .text-muted {
  grid-column: 1;
  font-size: 12px;
  color: var(--text-secondary, #64748b);
  margin-top: 2px;
  line-height: 1.5;
}


/* ──────────────────────────────────────────────────────────────────────────
   §4 · Inputs — compact, modern, properly sized
   ──────────────────────────────────────────────────────────────────────────
   The screenshot's massive inputs were because .input had no max-width and
   the label/input were stacked, so the container stretched. With the
   grid-row above, the input now naturally fills only the control column
   (max 320px). We also tighten height/padding.
   ────────────────────────────────────────────────────────────────────────── */
.input,
.field input[type="text"],
.field input[type="number"],
.field input[type="email"],
.field input[type="tel"],
.field input[type="password"],
.field input[type="url"],
.field input[type="search"],
.field textarea,
.field select,
input.input,
select.input,
textarea.input {
  width: 100%;
  max-width: 320px;
  padding: 8px 12px;
  font-size: 13.5px;
  line-height: 1.5;
  border: 1.5px solid var(--border, #e2e8f0);
  border-radius: 8px;
  background: var(--surface-1, #fff);
  color: var(--text-primary);
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  outline: none;
}

.input:focus,
.input:focus-visible,
input.input:focus,
select.input:focus,
textarea.input:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent, #0f62fe);
  box-shadow: 0 0 0 3px rgba(15, 98, 254, 0.12);
}

/* Number inputs — tighter */
input.input[type="number"],
.field input[type="number"] {
  max-width: 160px;
  text-align: end;
  font-variant-numeric: tabular-nums;
}

/* Textareas — different rhythm */
textarea.input,
.field textarea {
  max-width: 100%;
  min-height: 96px;
  padding: 10px 12px;
  resize: vertical;
}

/* When a row uses a wide input (textarea, JSON override etc.) let it span */
.settings-row--wide,
.form-row--wide,
.field--wide {
  grid-template-columns: 1fr;
}

.settings-row--wide > * + *,
.form-row--wide > * + *,
.field--wide > * + * {
  max-width: 100%;
  width: 100%;
}


/* ──────────────────────────────────────────────────────────────────────────
   §5 · Checkbox / toggle rows — compact single-line
   ────────────────────────────────────────────────────────────────────────── */
.settings-row:has(input[type="checkbox"]),
.field:has(input[type="checkbox"]) {
  grid-template-columns: 1fr auto;
}

.settings-row input[type="checkbox"],
.field input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent, #0f62fe);
  cursor: pointer;
}


/* ──────────────────────────────────────────────────────────────────────────
   §6 · Page header — consistent rhythm
   ────────────────────────────────────────────────────────────────────────── */
.page-header,
.page__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.page-header__title,
.page__title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--text-primary);
}

.page-header__subtitle,
.page__subtitle {
  font-size: 13.5px;
  color: var(--text-secondary, #64748b);
  margin: 0;
  line-height: 1.55;
}

.page-header__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}


/* ──────────────────────────────────────────────────────────────────────────
   §7 · Buttons — slimmer + consistent
   ────────────────────────────────────────────────────────────────────────── */
.btn,
button.btn {
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid var(--border, #e2e8f0);
  background: var(--surface-1, #fff);
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1.5;
}

.btn:hover,
button.btn:hover {
  background: var(--surface-2, #f8fafc);
  border-color: var(--border-hover, #cbd5e1);
}

.btn:active {
  transform: translateY(1px);
}

.btn--primary,
.btn.btn--primary,
button.btn.btn--primary {
  background: var(--accent, #0f62fe);
  color: #fff;
  border-color: var(--accent, #0f62fe);
}

.btn--primary:hover,
button.btn--primary:hover {
  background: var(--accent-hover, #0a52d5);
  border-color: var(--accent-hover, #0a52d5);
}

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


/* ──────────────────────────────────────────────────────────────────────────
   §8 · Tables — denser, professional
   ────────────────────────────────────────────────────────────────────────── */
.data-table table,
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table th {
  padding: 10px 14px;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-secondary, #64748b);
  background: var(--surface-2, #f8fafc);
  border-bottom: 1.5px solid var(--border, #e2e8f0);
}

.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border, #f1f5f9);
  vertical-align: middle;
}

.data-table tr:hover td {
  background: var(--surface-2, #f8fafc);
}


/* ──────────────────────────────────────────────────────────────────────────
   §9 · Empty-state polish
   ────────────────────────────────────────────────────────────────────────── */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-secondary);
}

.empty-state__icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.55;
}

.empty-state h3 {
  font-size: 16px;
  margin: 0 0 4px;
  color: var(--text-primary);
  font-weight: 700;
}

.empty-state p {
  font-size: 13.5px;
  margin: 0;
}


/* ──────────────────────────────────────────────────────────────────────────
   §10 · Responsive breakpoint — mobile / tablet
   ────────────────────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .settings-row,
  .settings-card .field,
  .settings-group .field,
  .form-section .field,
  .kvrow,
  .form-row {
    grid-template-columns: 1fr;
    gap: 6px 0;
    align-items: stretch;
  }

  .input,
  .field input,
  .field select,
  .field textarea {
    max-width: 100%;
  }

  .page,
  .page-wrap,
  .page-content {
    padding-inline: 12px;
  }
}


/* ──────────────────────────────────────────────────────────────────────────
   §11 · Tab refinement (when present)
   ────────────────────────────────────────────────────────────────────────── */
.tabs__nav {
  display: flex;
  gap: 4px;
  border-bottom: 1.5px solid var(--border, #e2e8f0);
  margin-bottom: 18px;
  padding-bottom: 0;
  overflow-x: auto;
}

.tabs__tab,
.tab {
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
  border: none;
  background: transparent;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.12s ease, border-color 0.12s ease;
}

.tabs__tab:hover,
.tab:hover {
  color: var(--text-primary);
}

.tabs__tab--active,
.tab--active,
.tabs__tab[aria-selected="true"] {
  color: var(--accent, #0f62fe);
  border-bottom-color: var(--accent, #0f62fe);
}

/* ── Premium Help & Notification drawers (2026-06-18) ───────────────────── */
.dw-intro { font-size: 13px; color: var(--text-secondary); margin: 2px 2px 4px; line-height: 1.6; }
.dw-section-label { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-muted); margin: 16px 2px 8px; }
.dw-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: 14px; background: var(--surface-1); text-decoration: none; color: inherit;
  transition: transform .15s var(--ease-out, ease), box-shadow .15s ease, border-color .15s ease, background .15s ease; }
.dw-card + .dw-card { margin-top: 8px; }
.dw-card:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(15,23,42,.10);
  border-color: var(--accent); background: var(--surface-2); }
.dw-card__badge { flex: 0 0 auto; width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); }
.dw-card__body { min-width: 0; flex: 1; }
.dw-card__title { font-weight: 600; font-size: 14px; }
.dw-card__sub { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.dw-card__chev { color: var(--text-muted); flex: 0 0 auto; }
.dw-card:hover .dw-card__chev { color: var(--accent); }
.dw-kbd-row { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 12px; border-radius: 11px; background: var(--surface-2); }
.dw-kbd-row + .dw-kbd-row { margin-top: 6px; }
.dw-kbd-row__label { font-size: 13px; }
.dw-kbd-keys { display: flex; gap: 4px; align-items: center; }
kbd.dw-kbd { font-family: var(--dafa-font-mono, ui-monospace, SFMono-Regular, monospace); font-size: 11px;
  min-width: 22px; text-align: center; padding: 3px 7px; border-radius: 7px; background: var(--surface-1);
  border: 1px solid var(--border-strong); box-shadow: 0 1px 0 var(--border-strong); color: inherit; line-height: 1.3; }
.dw-notif { display: flex; gap: 12px; align-items: flex-start; padding: 11px 13px; border: 1px solid var(--border);
  border-radius: 14px; background: var(--surface-1); transition: transform .15s ease, box-shadow .15s ease; }
.dw-notif + .dw-notif { margin-top: 8px; }
.dw-notif:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(15,23,42,.08); }
.dw-notif__badge { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); }
.dw-notif__title { font-weight: 600; font-size: 13.5px; text-transform: capitalize; }
.dw-notif__meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; word-break: break-word; }

/* ── Spec report summary KPI cards (Agent Leaderboard etc.) ─────────────── */
.dw-kpis { display: flex; gap: 12px; flex-wrap: wrap; margin: 0 0 14px; }
.dw-kpi { flex: 1 1 200px; min-width: 190px; display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface-1);
  box-shadow: 0 2px 10px rgba(15,23,42,.05); transition: transform .15s ease, box-shadow .15s ease; }
.dw-kpi:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(15,23,42,.09); }
.dw-kpi__badge { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); flex: 0 0 auto; }
.dw-kpi__label { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); }
.dw-kpi__value { font-size: 15px; font-weight: 700; margin-top: 1px; }
.dw-kpi__metric { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.dw-kpi--good .dw-kpi__badge { background: rgba(22,163,74,.12); color: #16a34a; }
.dw-kpi--warn .dw-kpi__badge { background: rgba(245,158,11,.15); color: #d97706; }

/* ── Strict-compliance: numeric inputs must NOT show browser spinner arrows ──
   Yeastar uses plain numeric fields (no up/down spinners). This hides the
   spinner everywhere while keeping type=number semantics (numeric keypad +
   validation). Applies system-wide per the "no invented spinners" rule. */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

/* ── Fix «box-inside-a-box» for SELECTS (user 2026-07-02 «سيئ جدا») ──────────
   A <select> inside a .field__control / .auth-field__control wrapper double-
   bordered (wrapper border + the .field select border above). Make it flat like
   text inputs = single clean field box. Scoped to wrapped selects only;
   standalone .form-select / .filter-select are untouched. */
.field__control select,
.field__control select.field__input,
.auth-field__control select {
  border: none !important;
  background: transparent !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  max-width: none !important;
  width: 100% !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}
