/* ==========================================================================
   Raddad - dashboard styles
   Hand-written CSS, no framework, no build step.
   ========================================================================== */

:root {
  --bg: #0f1117;
  --surface: #1b1f2b;
  --surface-2: #222736;
  --border: #2b3143;
  --border-soft: #232838;

  --text: #eef1f7;
  --text-muted: #98a0b5;
  --text-dim: #6b7488;

  --brand: #e1306c;
  --brand-2: #c13584;
  --brand-grad: linear-gradient(135deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);

  --ok: #22c55e;
  --ok-bg: rgba(34, 197, 94, .12);
  --warn: #f59e0b;
  --warn-bg: rgba(245, 158, 11, .12);
  --err: #ef4444;
  --err-bg: rgba(239, 68, 68, .12);
  --info: #3b82f6;
  --info-bg: rgba(59, 130, 246, .12);

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, .35);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans Arabic", "Segoe UI Emoji", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0; }

/* ---------- Layout ----------
   .main and .topbar (plus .topbar h1/.topbar-sub/.topbar-actions): fully
   migrated during the Phase 1 closeout. .main's flex/min-width/display were
   entirely superseded (dashboard.css's .raddad-dashboard .main at equal-or-
   higher specificity, and raddad-shell.css's .rd-app .main for display on
   content pages - live-verified before removal, see closeout report).
   .topbar's one genuinely load-bearing property (justify-content) plus its
   sticky positioning moved into dashboard.css's .raddad-dashboard .topbar,
   the single canonical shell implementation; border/background/backdrop-
   filter here were already dead, shadowed by .glass. .topbar h1/-sub/-actions
   had zero remaining template usage. */

.app-footer {
  width: 100%;
  padding: 18px 24px 22px;
  color: var(--text-dim);
  font-size: 12px;
  letter-spacing: .015em;
  text-align: center;
}

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 20px;
}
.card + .card { margin-top: 18px; }
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.card-title { font-size: 15px; font-weight: 650; }
.card-desc { font-size: 13px; color: var(--text-dim); margin-top: 3px; }

/* .grid / .grid-2 / .grid-3 / .grid-4: fully migrated. Every page that uses
   them now carries .rd-ui, and raddad-components.css's .rd-ui .grid* rules
   (auto-fit/minmax, collapsing by available width rather than a fixed
   breakpoint) are a strict superset of what this base layer provided -
   removed rather than kept as a shadowed duplicate. See raddad-components.css
   "Layout helpers". */

/* ---------- Stat tiles ---------- */

.stat {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat-label {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
}
.stat-value {
  font-size: 28px;
  font-weight: 700;
  margin-top: 6px;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.stat-value.ok { color: var(--ok); }
.stat-value.err { color: var(--err); }
.stat-hint { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

/* ---------- Status pills ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-err { background: var(--err-bg); color: var(--err); }
.pill-info { background: var(--info-bg); color: var(--info); }
.pill-muted { background: var(--surface-2); color: var(--text-muted); }

.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.dot-pulse { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: filter .12s, background .12s, border-color .12s, opacity .12s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--err); border-color: rgba(239, 68, 68, .35); background: var(--err-bg); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */

.field { margin-bottom: 18px; }
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}
.field-hint { font-size: 12.5px; color: var(--text-dim); margin-top: 6px; }
.field-required { color: var(--brand); }
.field-optional { font-size: 12px; font-weight: 400; color: var(--text-dim); }

/* Repeatable button editors (steps 4 and 6). One row per button; the action
   row adds a type and a value beside the title. */
.button-list { display: flex; flex-direction: column; gap: 8px; }
.button-list:not(:empty) { margin-bottom: 10px; }
.button-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}
.button-row-action {
  grid-template-columns: minmax(0, 1fr) minmax(0, 150px) minmax(0, 1.4fr) auto;
}
@media (max-width: 760px) {
  .button-row, .button-row-action { grid-template-columns: minmax(0, 1fr); }
}

input[type="text"], input[type="password"], input[type="search"], input[type="url"], textarea, select {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(225, 48, 108, .14);
}
input::placeholder, textarea::placeholder { color: var(--text-dim); }
textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
input:disabled, textarea:disabled { opacity: .6; cursor: not-allowed; }

.workflow-map {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, rgba(225, 48, 108, .07), transparent);
  color: var(--text-muted);
  font-size: 12.5px;
}
.workflow-map b { color: var(--brand); font-weight: 700; }
.form-errors { margin-bottom: 18px; }
/* `hidden` is a UA rule, so any author `display` beats it. Every element this
   app toggles through the `hidden` property needs its own opt-out. */
.form-errors[hidden], .dependent-panel[hidden],
.callout[hidden], .btn[hidden] { display: none; }
.section-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}
.section-heading-row .step-desc { margin-bottom: 0; }
.section-heading-row .switch, .switch.field {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
}
.dependent-panel {
  padding: 15px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, .08);
}
.dependent-panel > :last-child { margin-bottom: 0; }
.feature-disabled .step-num { opacity: .55; }
.feature-disabled .step-desc { color: var(--text-dim); }
.optional-settings {
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}
.optional-settings summary {
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 650;
}
.optional-settings[open] summary { margin-bottom: 10px; }
.field-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 5px;
  min-height: 18px;
}
.field-error { color: #ffc9c9; font-size: 12px; }
.char-count { margin-left: auto; color: var(--text-dim); font-size: 11.5px; white-space: nowrap; }
.char-count.over-limit { color: var(--err); font-weight: 650; }
.field.has-error input, .field.has-error textarea, .field.has-error select {
  border-color: var(--err);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .12);
}

.input-mono { font-family: var(--mono); font-size: 13px; }

.radio-group { display: flex; gap: 10px; flex-wrap: wrap; }
.radio-card {
  flex: 1;
  min-width: 180px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.radio-card:hover { border-color: var(--text-dim); }
.radio-card input { margin-right: 8px; accent-color: var(--brand); }
.radio-card.selected { border-color: var(--brand); background: rgba(225, 48, 108, .07); }
.radio-card .rc-title { font-weight: 600; font-size: 13.5px; }
.radio-card .rc-desc { font-size: 12px; color: var(--text-dim); margin-top: 3px; }

/* Toggle switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { display: none; }
.switch-track {
  width: 42px; height: 24px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  position: relative;
  transition: background .16s, border-color .16s;
  flex-shrink: 0;
}
.switch-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform .16s, background .16s;
}
.switch input:checked + .switch-track { background: var(--ok); border-color: var(--ok); }
.switch input:checked + .switch-track .switch-thumb {
  transform: translateX(18px);
  background: #fff;
}

/* ---------- Keyword chips ---------- */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 9px;
  min-height: 46px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  align-items: center;
}
.chips:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(225, 48, 108, .14); }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  max-width: 100%;
}
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip button {
  background: none; border: none; color: var(--text-dim);
  cursor: pointer; font-size: 15px; line-height: 1;
  padding: 0 2px; border-radius: 4px;
}
.chip button:hover { color: var(--err); }
.chips input {
  flex: 1; min-width: 130px;
  border: none; background: none; padding: 4px 2px;
  color: var(--text); font-size: 14px;
}
.chips input:focus { outline: none; box-shadow: none; border: none; }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; margin: 0 -20px -20px; padding: 0 20px 4px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-dim);
  font-weight: 650;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 11px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255, 255, 255, .017); }
.td-mono { font-family: var(--mono); font-size: 12.5px; color: var(--text-muted); }
.td-time { color: var(--text-dim); font-size: 12.5px; white-space: nowrap; }

/* .campaign-card and its children (.campaign-body/-title/-meta/-actions):
   fully migrated. Used only on Campaigns, which carries .rd-ui, and
   campaigns.css's .rd-ui .campaign-card* rules are a complete replacement -
   background, border, hover, inactive state, keyword list, actions, and
   responsive collapse all included. Removed rather than kept as a shadowed
   duplicate. */

/* ---------- Media picker ---------- */

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 12px;
  max-height: 430px;
  overflow-y: auto;
  padding: 3px;
}
.media-item {
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  background: var(--surface-2);
  transition: border-color .12s, transform .12s;
}
.media-item:hover { transform: translateY(-2px); }
.media-item.selected { border-color: var(--brand); }
.media-item img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.media-item-body { padding: 8px 9px; }
.media-item-caption {
  font-size: 11.5px; color: var(--text-muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; line-height: 1.35;
}
.media-item-type {
  font-size: 10px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-dim); margin-top: 4px; font-weight: 600;
}

/* ---------- Steps ---------- */

.step { display: flex; gap: 16px; margin-bottom: 26px; }
.step-num {
  width: 30px; height: 30px; flex-shrink: 0;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: var(--text-muted);
}
.step.done .step-num { background: var(--brand); border-color: var(--brand); color: #fff; }
.step-body { flex: 1; min-width: 0; }
.step-title { font-size: 14.5px; font-weight: 650; margin-bottom: 3px; }
.step-desc { font-size: 12.5px; color: var(--text-dim); margin-bottom: 12px; }

/* ---------- Callouts ---------- */

.callout {
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  font-size: 13px;
  line-height: 1.6;
  border: 1px solid;
  display: flex;
  gap: 11px;
}
.callout + .callout { margin-top: 10px; }
.callout-icon { flex-shrink: 0; font-size: 15px; line-height: 1.4; }
.callout-info { background: var(--info-bg); border-color: rgba(59,130,246,.28); color: #bcd5ff; }
.callout-warn { background: var(--warn-bg); border-color: rgba(245,158,11,.28); color: #fbe0b0; }
.callout-err  { background: var(--err-bg);  border-color: rgba(239,68,68,.28);  color: #ffc9c9; }
.callout-ok   { background: var(--ok-bg);   border-color: rgba(34,197,94,.28);  color: #b9f0cd; }
.callout strong { color: #fff; }
.callout code {
  background: rgba(0,0,0,.3); padding: 1px 5px; border-radius: 4px;
  font-family: var(--mono); font-size: 12px;
}

/* ---------- Copy field ---------- */

.copy-field { display: flex; gap: 8px; align-items: stretch; }
.copy-field input {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--bg);
}
.copy-field .btn { flex-shrink: 0; }

/* ---------- Misc ---------- */

.empty {
  text-align: center;
  padding: 44px 20px;
  color: var(--text-dim);
}
.empty-icon { font-size: 34px; margin-bottom: 10px; opacity: .6; }
.empty-title { font-size: 15px; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; }
.empty p { font-size: 13px; max-width: 380px; margin: 0 auto 16px; }

.kv { display: flex; justify-content: space-between; gap: 14px; padding: 8px 0; font-size: 13.5px; }
.kv + .kv { border-top: 1px solid var(--border-soft); }
.kv-key { color: var(--text-dim); }
.kv-val { font-weight: 550; text-align: right; word-break: break-word; }

.keyword-list { display: flex; flex-wrap: wrap; gap: 5px; }
.keyword-tag {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 7px;
  font-size: 12px;
}

.ol-steps { margin: 0; padding-left: 20px; font-size: 13.5px; line-height: 1.85; color: var(--text-muted); }
.ol-steps li { margin-bottom: 4px; }
.ol-steps strong { color: var(--text); }
.ol-steps code {
  background: var(--bg); padding: 1.5px 6px; border-radius: 4px;
  font-family: var(--mono); font-size: 12px; color: var(--text);
}

/* Login and error pages, plus the bare .brand-name/.brand-tagline that only
   they used: fully migrated. Both templates carry .rd-auth, and auth.css's
   .rd-auth .login-page/.login-shell/.login-card/.error-page/.error-card/
   .error-code/.brand-name/.brand-tagline rules are a complete replacement
   (auth.css's own header comment documents this: "these pages load
   dashboard.css and carry .raddad-dashboard... this file only supplies what
   the shell would otherwise have provided"). The one other .brand-name
   consumer (_app_shell.html's brand card) was already reached by
   dashboard.css's higher-specificity .raddad-dashboard .brand-name, so
   nothing outside auth.css depended on the copy here. */

/* Arabic / RTL content inside otherwise-LTR UI */
[dir="auto"] { unicode-bidi: plaintext; }

/* ---------- Responsive ----------
   The mobile sidebar drawer (.menu-toggle/.sidebar/.scrim), the
   .grid-4/.grid-3/.grid-2/.campaign-card/.campaign-thumb breakpoints, and
   .topbar's own 860px/520px rules are all gone with their base rules -
   .topbar's responsive behavior now lives entirely in dashboard.css's
   .raddad-dashboard .topbar, which already handled every breakpoint here at
   higher specificity (900px, not 860px - confirmed live before removal). */

@media (max-width: 520px) {
  .stat-value { font-size: 24px; }
  .section-heading-row { flex-direction: column; }
  .workflow-map b { transform: rotate(90deg); }
}
