/*
 * Josoor design system — legacy bridge.
 * Re-skins the existing dashboard markup (style.css / dashboard.css classes and the
 * var(--…) references in ~1,300 inline styles) with ds tokens, so every screen adopts
 * the new look before its markup is rebuilt. Scoped to body.ds-legacy: a dashboard opts
 * in when it moves to ds, and screens rebuilt on ds components don't need this file.
 * Delete rules here as the screens they serve are rebuilt.
 */

/* ── Legacy variables → ds tokens (body-level, so they win over :root and the
      !important brand vars inc/branding.php prints on :root) ───────────────────── */
body.ds-legacy {
  --classera-primary: var(--brand);
  --classera-primary-light: var(--brand);
  --classera-primary-dark: var(--brand-hover);
  --classera-primary-color: var(--brand);
  --classera-secondary: var(--brand);
  --classera-secondary-light: var(--brand);
  --classera-accent: var(--brand);
  --classera-accent-warm: var(--warn);
  --classera-success: var(--ok);
  --classera-warning: var(--warn);
  --classera-danger: var(--bad);
  --classera-info: var(--info);

  --bg-primary: var(--bg);
  --bg-secondary: var(--surface);
  --bg-card: var(--surface);
  --bg-card-hover: var(--surface-2);
  --bg-glass: var(--surface);
  --bg-glass-light: var(--surface-2);
  --surface-color: var(--surface);
  --bg-color: var(--bg);

  --text-primary: var(--text);
  --text-secondary: var(--text-2);
  --text-muted: var(--text-3);
  --text-accent: var(--brand);
  --border-color: var(--border);
  --border-glow: var(--border-strong);

  /* --shadow-sm, --radius-sm and --radius-lg share their names with ds tokens; tokens.css
     loads after style.css so the ds values already win. Re-declaring them here as
     var(--same-name) would be a cycle and zero them. */
  --shadow-md: var(--shadow);
  --shadow-lg: var(--shadow);
  --shadow-glow: none;
  --shadow-glow-success: none;

  --radius-md: var(--radius);
  --radius-xl: var(--radius-lg);
  --font-primary: var(--font);
  --font-arabic: var(--font);
  --sidebar-width: var(--sidebar-w);

  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

/* ── Shell ──────────────────────────────────────────────────────────────────── */
.ds-legacy .classera-header {
  background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none;
  border-bottom: 1px solid var(--border);
}
.ds-legacy .classera-sidebar { background: var(--surface); border-inline-end: 1px solid var(--border); box-shadow: none; }
.ds-legacy .sidebar-brand { border-bottom: 1px solid var(--border); }
.ds-legacy .sidebar-brand-logo { background: var(--brand); color: var(--brand-ink); border-radius: var(--radius); }
.ds-legacy .sidebar-nav-section {
  text-transform: none; letter-spacing: 0; font-weight: var(--fw-semibold); color: var(--text-3);
}
.ds-legacy .sidebar-nav-item { color: var(--text-2); border-radius: var(--radius); font-weight: var(--fw-medium); }
.ds-legacy .sidebar-nav-item:hover { background: var(--surface-2); color: var(--text); }
.ds-legacy .sidebar-nav-item.active { background: var(--brand); color: var(--brand-ink); box-shadow: none; }
.ds-legacy .sidebar-nav-item.active::before { display: none; }
.ds-legacy .sidebar-nav-badge { background: var(--warn-soft); color: var(--warn); }

/* Gradient text → plain text */
.ds-legacy .sidebar-brand-name,
.ds-legacy .welcome-title,
.ds-legacy .kpi-value-large {
  background: none; -webkit-background-clip: initial; background-clip: initial;
  -webkit-text-fill-color: currentColor; color: var(--text);
}
.ds-legacy .welcome-title { font-size: var(--fs-2xl); font-weight: var(--fw-bold); }
.ds-legacy .welcome-subtitle { font-size: var(--fs-md); color: var(--text-2); }

/* ── Surfaces ───────────────────────────────────────────────────────────────── */
.ds-legacy .card,
.ds-legacy .card-glass,
.ds-legacy .stat-card,
.ds-legacy .classera-modal-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
.ds-legacy .card:hover, .ds-legacy .stat-card:hover { transform: none; box-shadow: var(--shadow-sm); border-color: var(--border); }
.ds-legacy .classera-modal-card { box-shadow: var(--shadow); }
.ds-legacy .card-title { font-weight: var(--fw-semibold); color: var(--text); }
.ds-legacy .card-subtitle { color: var(--text-3); }
.ds-legacy .stat-value { color: var(--text); font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; }
.ds-legacy .stat-label { color: var(--text-2); }
.ds-legacy .card-icon { background: var(--brand-soft); color: var(--brand); box-shadow: none; }
.ds-legacy .card-icon-green  { background: var(--ok-soft); color: var(--ok); }
.ds-legacy .card-icon-pink,
.ds-legacy .card-icon-yellow { background: var(--warn-soft); color: var(--warn); }
.ds-legacy .card-icon-blue,
.ds-legacy .card-icon-teal,
.ds-legacy .card-icon-purple { background: var(--info-soft); color: var(--info); }
.ds-legacy .progress-bar { background: var(--muted-soft); }
.ds-legacy .progress-bar-fill { background: var(--brand); }
.ds-legacy .progress-bar-fill::after { display: none; }
.ds-legacy .child-avatar { background: var(--brand-soft); color: var(--brand); }

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.ds-legacy .btn { border-radius: var(--radius); font-family: var(--font); font-weight: var(--fw-semibold); }
.ds-legacy .btn-primary { background: var(--brand); color: var(--brand-ink); box-shadow: none; }
.ds-legacy .btn-primary:hover { background: var(--brand-hover); transform: none; box-shadow: none; }
.ds-legacy .btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); }
.ds-legacy .btn-secondary:hover { background: var(--surface-2); border-color: var(--border-strong); }
.ds-legacy .btn-success { background: var(--ok); color: #fff; }
.ds-legacy .btn-danger  { background: var(--bad); color: #fff; }
.ds-legacy .btn-success:hover, .ds-legacy .btn-danger:hover { filter: brightness(.95); transform: none; }

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.ds-legacy .classera-content input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
.ds-legacy .classera-content select,
.ds-legacy .classera-content textarea,
.ds-legacy .classera-modal-card input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
.ds-legacy .classera-modal-card select,
.ds-legacy .classera-modal-card textarea {
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: var(--radius); font-family: var(--font);
}
.ds-legacy .classera-content input:focus,
.ds-legacy .classera-content select:focus,
.ds-legacy .classera-content textarea:focus,
.ds-legacy .classera-modal-card input:focus,
.ds-legacy .classera-modal-card select:focus,
.ds-legacy .classera-modal-card textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
.ds-legacy input[type="checkbox"], .ds-legacy input[type="radio"] { accent-color: var(--brand); }

/* ── Tables ─────────────────────────────────────────────────────────────────── */
.ds-legacy .classera-content table th {
  background: var(--surface-2); color: var(--text-2); font-weight: var(--fw-semibold);
}
.ds-legacy .classera-content table td { border-color: var(--border); }
.ds-legacy .classera-content table tbody tr:hover td { background: var(--surface-2); }

/* ── Misc ───────────────────────────────────────────────────────────────────── */
.ds-legacy .toast { background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); color: var(--text); }
.ds-legacy .skeleton { background: var(--muted-soft); }
.ds-legacy ::selection { background: var(--brand-soft); color: var(--text); }
