/* ==========================================================================
   Magent — shared design system
   Tokens, base, and components used by both the landing page and the portal.
   Logical properties everywhere so RTL mirrors for free.
   ========================================================================== */

:root {
  color-scheme: light dark;

  /* Brand */
  --primary: #5b3df5;
  --primary-600: #4a2fe0;
  --primary-700: #3b23b8;
  --primary-soft: #eeeaff;
  --primary-soft-2: #dcd5ff;
  --accent: #ff6a3d;
  --accent-soft: #ffe9e1;
  --amber: #ffb020;
  --amber-soft: #fff3d6;
  --emerald: #10b981;
  --emerald-soft: #d9f7ea;
  --rose: #ef4463;
  --rose-soft: #ffe1e7;

  /* Surfaces */
  --bg: #f6f6fb;
  --bg-2: #eeedf7;
  --surface: #ffffff;
  --surface-2: #f9f9fd;
  --surface-glass: rgba(255, 255, 255, 0.72);
  --text: #14122b;
  --text-2: #4a4864;
  --muted: #7b7994;
  --border: #e6e5f0;
  --border-strong: #cfcde0;
  --ring: rgba(91, 61, 245, 0.35);

  --shadow-1: 0 1px 2px rgba(20, 18, 43, 0.05), 0 1px 1px rgba(20, 18, 43, 0.03);
  --shadow-2: 0 8px 24px -8px rgba(20, 18, 43, 0.16), 0 2px 6px rgba(20, 18, 43, 0.05);
  --shadow-3: 0 24px 60px -16px rgba(20, 18, 43, 0.28);
  --shadow-primary: 0 10px 28px -8px rgba(91, 61, 245, 0.55);

  --grad-brand: linear-gradient(135deg, #5b3df5 0%, #8b5cf6 55%, #ff6a3d 130%);
  --grad-brand-text: linear-gradient(120deg, #5b3df5 0%, #9b6bff 50%, #ff6a3d 100%);
  --grad-hero: radial-gradient(1200px 600px at 10% -10%, rgba(139, 92, 246, 0.22), transparent 60%),
               radial-gradient(900px 500px at 100% 0%, rgba(255, 106, 61, 0.18), transparent 60%);

  /* Shape & type */
  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius: 18px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --font-latin: "Manrope", "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-arabic: "IBM Plex Sans Arabic", "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font: var(--font-latin);
  --lh: 1.5;

  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur: 220ms;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tap: 48px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #8b7cff;
    --primary-600: #7a68ff;
    --primary-700: #6a56f7;
    --primary-soft: #241f4a;
    --primary-soft-2: #2f2862;
    --accent: #ff7e57;
    --accent-soft: #3a2118;
    --amber: #ffc24d;
    --amber-soft: #3a2f12;
    --emerald: #34d399;
    --emerald-soft: #0f3326;
    --rose: #ff6b85;
    --rose-soft: #3d1a23;

    --bg: #0d0c17;
    --bg-2: #14132200;
    --surface: #17162a;
    --surface-2: #1d1c33;
    --surface-glass: rgba(23, 22, 42, 0.72);
    --text: #f3f2fb;
    --text-2: #c2c0d8;
    --muted: #8f8dab;
    --border: #27263f;
    --border-strong: #3b3959;
    --ring: rgba(139, 124, 255, 0.45);

    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 10px 28px -10px rgba(0, 0, 0, 0.6);
    --shadow-3: 0 30px 70px -20px rgba(0, 0, 0, 0.75);
    --shadow-primary: 0 10px 28px -8px rgba(139, 124, 255, 0.45);
    --grad-hero: radial-gradient(1200px 600px at 10% -10%, rgba(139, 92, 246, 0.28), transparent 60%),
                 radial-gradient(900px 500px at 100% 0%, rgba(255, 106, 61, 0.16), transparent 60%);
  }
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: var(--lh);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
}
html[lang="ar"] body { --font: var(--font-arabic); --lh: 1.7; }
html[lang="ar"] { font-feature-settings: "kern"; }

h1, h2, h3, h4 { margin: 0; line-height: 1.15; letter-spacing: -0.01em; font-weight: 800; }
html[lang="ar"] h1, html[lang="ar"] h2, html[lang="ar"] h3, html[lang="ar"] h4 { letter-spacing: 0; line-height: 1.3; font-weight: 700; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg { display: block; max-width: 100%; }
svg.icon { width: 20px; height: 20px; flex: none; }
.hint svg.icon { display: inline-block; width: 14px; height: 14px; vertical-align: -2px; margin-inline-end: 2px; }
[hidden] { display: none !important; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; border-radius: var(--radius-xs); }
::selection { background: var(--primary-soft-2); }

.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.small { font-size: 0.875rem; }
.tiny { font-size: 0.75rem; }
.strong { font-weight: 700; }
.grad-text {
  background: var(--grad-brand-text);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.stack > * + * { margin-block-start: var(--stack, 12px); }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.center { text-align: center; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-bd: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap);
  padding: 0 20px;
  border-radius: 14px;
  border: 1px solid var(--btn-bd);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 700;
  font-size: 1rem;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 120ms var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease), opacity var(--dur);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.97); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn-primary {
  --btn-bg: var(--primary); --btn-fg: #fff; --btn-bd: transparent;
  background: linear-gradient(180deg, rgba(255,255,255,0.14), rgba(255,255,255,0) 60%), var(--primary);
  box-shadow: var(--shadow-primary);
}
.btn-primary:hover { background: linear-gradient(180deg, rgba(255,255,255,0.2), rgba(255,255,255,0) 60%), var(--primary-600); }
.btn-accent {
  --btn-bg: var(--accent); --btn-fg: #fff; --btn-bd: transparent;
  box-shadow: 0 10px 28px -8px rgba(255, 106, 61, 0.55);
}
.btn-soft { --btn-bg: var(--primary-soft); --btn-fg: var(--primary-700); --btn-bd: transparent; }
@media (prefers-color-scheme: dark) { .btn-soft { --btn-fg: #d9d3ff; } }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--text-2); }
.btn-ghost:hover { background: var(--bg-2); }
.btn-danger { --btn-bg: var(--rose-soft); --btn-fg: var(--rose); --btn-bd: transparent; }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: 0.9rem; border-radius: 11px; }
.btn-sm svg { width: 16px; height: 16px; }
.btn-lg { min-height: 56px; padding: 0 28px; font-size: 1.05rem; border-radius: 16px; }
.btn-block { width: 100%; }
.btn-icon { padding: 0; width: var(--tap); border-radius: 50%; }
.btn-icon.btn-sm { width: 38px; }
.btn .spinner { width: 18px; height: 18px; }

.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid color-mix(in srgb, currentColor 25%, transparent);
  border-top-color: currentColor;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------------------
   Cards, chips, badges
   -------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-1);
}
.card-pad-lg { padding: 28px; }
.card-title { font-size: 1.05rem; font-weight: 800; margin-block-end: 4px; }
.card-sub { color: var(--muted); font-size: 0.9rem; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-block-end: 16px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 700; line-height: 1.4;
  background: var(--bg-2); color: var(--text-2);
  white-space: nowrap;
}
.chip svg { width: 14px; height: 14px; }
.chip-primary { background: var(--primary-soft); color: var(--primary-700); }
.chip-emerald { background: var(--emerald-soft); color: #0b6b4a; }
.chip-amber { background: var(--amber-soft); color: #8a5a00; }
.chip-rose { background: var(--rose-soft); color: #b01d3a; }
.chip-accent { background: var(--accent-soft); color: #b8421f; }
@media (prefers-color-scheme: dark) {
  .chip-primary { color: #d9d3ff; }
  .chip-emerald { color: #6ee7b7; }
  .chip-amber { color: #ffd27a; }
  .chip-rose { color: #ff9db0; }
  .chip-accent { color: #ffb399; }
}
.chip-outline { background: transparent; border: 1px solid var(--border-strong); }

.icon-badge {
  width: 44px; height: 44px; border-radius: 14px; flex: none;
  display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary);
}
.icon-badge svg { width: 22px; height: 22px; }
.icon-badge.accent { background: var(--accent-soft); color: var(--accent); }
.icon-badge.emerald { background: var(--emerald-soft); color: var(--emerald); }
.icon-badge.amber { background: var(--amber-soft); color: #c98200; }
.icon-badge.rose { background: var(--rose-soft); color: var(--rose); }
.icon-badge.lg { width: 56px; height: 56px; border-radius: 18px; }
.icon-badge.lg svg { width: 28px; height: 28px; }

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field + .field { margin-block-start: 16px; }
.label { font-weight: 700; font-size: 0.92rem; }
.hint { color: var(--muted); font-size: 0.82rem; line-height: 1.5; }
.input, .select, .textarea {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--dur), box-shadow var(--dur), background var(--dur);
  appearance: none;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.55; }
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: 0.8; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--rose); box-shadow: 0 0 0 4px rgba(239, 68, 99, 0.18); }
.field-error { color: var(--rose); font-size: 0.82rem; font-weight: 600; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .input { padding-inline-start: 44px; }
.input-wrap > svg { position: absolute; inset-inline-start: 14px; width: 20px; height: 20px; color: var(--muted); pointer-events: none; }
.input-wrap .adorn { position: absolute; inset-inline-end: 10px; }
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237b7994' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-inline-end: 40px;
}
html[dir="rtl"] .select { background-position: left 14px center; }

.check { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 0.95rem; min-height: 32px; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); margin: 0; }

/* Segmented control */
.seg { display: inline-flex; padding: 4px; gap: 2px; background: var(--bg-2); border-radius: 12px; }
.seg > button {
  border: 0; background: transparent; color: var(--text-2);
  min-height: 36px; padding: 0 14px; border-radius: 9px; font-weight: 700; font-size: 0.9rem;
  transition: background var(--dur), color var(--dur), box-shadow var(--dur);
}
.seg > button[aria-pressed="true"], .seg > button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.seg.block { display: flex; width: 100%; }
.seg.block > button { flex: 1; min-height: 44px; }

/* Choice cards (radio-like) */
.choice { display: grid; gap: 10px; }
.choice-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: var(--radius); cursor: pointer;
  border: 1.5px solid var(--border); background: var(--surface);
  transition: border-color var(--dur), background var(--dur), box-shadow var(--dur);
  text-align: start; width: 100%;
}
.choice-item:hover { border-color: var(--border-strong); }
.choice-item[aria-checked="true"], .choice-item.selected { border-color: var(--primary); background: color-mix(in srgb, var(--primary-soft) 55%, var(--surface)); box-shadow: 0 0 0 3px var(--ring); }
.choice-item .radio { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border-strong); flex: none; display: grid; place-items: center; transition: border-color var(--dur); }
.choice-item .radio::after { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--primary); transform: scale(0); transition: transform 180ms var(--ease-spring); }
.choice-item[aria-checked="true"] .radio, .choice-item.selected .radio { border-color: var(--primary); }
.choice-item[aria-checked="true"] .radio::after, .choice-item.selected .radio::after { transform: scale(1); }
.choice-item .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.choice-item .title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.choice-item .title { font-weight: 800; }
.choice-item .desc { color: var(--muted); font-size: 0.85rem; }

/* --------------------------------------------------------------------------
   Skeletons, empty states, toasts
   -------------------------------------------------------------------------- */
.skeleton {
  position: relative; overflow: hidden; border-radius: 10px;
  background: var(--bg-2);
}
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 60%, transparent), transparent);
  animation: shimmer 1.4s infinite;
  transform: translateX(-100%);
}
@keyframes shimmer { to { transform: translateX(100%); } }
.skel-line { height: 14px; }
.skel-line.w-40 { width: 40%; } .skel-line.w-60 { width: 60%; } .skel-line.w-80 { width: 80%; }
.skel-circle { width: 44px; height: 44px; border-radius: 14px; }

.empty { text-align: center; padding: 44px 20px; }
.empty .art { width: 132px; height: 132px; margin: 0 auto 18px; }
.empty h3 { font-size: 1.15rem; margin-block-end: 6px; }
.empty p { color: var(--muted); max-width: 32ch; margin: 0 auto 18px; }

.toasts {
  position: fixed; inset-inline: 0; bottom: calc(var(--safe-bottom) + 84px);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; z-index: 1000; padding: 0 16px;
}
@media (min-width: 768px) { .toasts { bottom: 24px; } }
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: 14px;
  background: var(--text); color: var(--bg);
  box-shadow: var(--shadow-3);
  font-weight: 600; font-size: 0.92rem;
  max-width: min(92vw, 420px);
  animation: toast-in 280ms var(--ease-spring);
}
.toast.out { animation: toast-out 200ms var(--ease) forwards; }
.toast.success { background: #0f8f63; color: #fff; }
.toast.error { background: #c9203f; color: #fff; }
.toast .btn { min-height: 32px; padding: 0 10px; font-size: 0.85rem; border-radius: 9px; --btn-bg: rgba(255,255,255,0.16); --btn-fg: inherit; --btn-bd: transparent; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(0.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* --------------------------------------------------------------------------
   Motion helpers
   -------------------------------------------------------------------------- */
.fade-up { animation: fade-up 420ms var(--ease) both; animation-delay: calc(var(--i, 0) * 45ms); }
@keyframes fade-up { from { opacity: 0; transform: translateY(10px); } }
.pop-in { animation: pop-in 320ms var(--ease-spring) both; }
@keyframes pop-in { from { opacity: 0; transform: scale(0.9); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

/* Logo lockup */
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 800; letter-spacing: -0.02em; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand img, .brand svg { width: 32px; height: 32px; }
html[lang="ar"] .brand { letter-spacing: 0; }

/* Language toggle */
.lang-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 38px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface);
  font-weight: 700; font-size: 0.85rem; color: var(--text-2);
}
.lang-toggle:hover { background: var(--bg-2); }
.lang-toggle svg { width: 16px; height: 16px; }
