/* ==========================================================================
   AI Ads Manager — main.css
   Design tokens (CSS variables), reset, typography, public-site layout.
   Themes: [data-theme="light"] (default) and [data-theme="dark"].
   ========================================================================== */

:root {
  /* Brand */
  --color-accent: #f2542d;
  --color-accent-hover: #d9441f;
  --color-accent-soft: #fde9e3;
  --color-accent-contrast: #ffffff;

  /* Semantic */
  --color-success: #12805c;
  --color-success-soft: #e3f4ec;
  --color-warning: #a86300;
  --color-warning-soft: #fdf1dc;
  --color-danger: #c4302b;
  --color-danger-soft: #fbe5e4;
  --color-info: #2759c4;
  --color-info-soft: #e5ecfb;
  --color-sim: #6b3fc4;
  --color-sim-soft: #efe8fb;

  /* Neutrals (light) */
  --color-bg: #f6f5f2;
  --color-surface: #ffffff;
  --color-surface-2: #faf9f7;
  --color-border: #e4e1db;
  --color-border-strong: #cfcac1;
  --color-text: #16181d;
  --color-text-muted: #5d6270;
  --color-text-subtle: #8a8f9c;
  --color-ink: #0f1419;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.75rem;
  --text-3xl: 2.375rem;
  --text-4xl: 3.25rem;
  --leading-tight: 1.2;
  --leading-normal: 1.55;

  /* Spacing (4px scale) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;

  /* Shape & depth */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(15, 20, 25, 0.06);
  --shadow-md: 0 4px 14px rgba(15, 20, 25, 0.08);
  --shadow-lg: 0 18px 48px rgba(15, 20, 25, 0.16);
  --focus-ring: 0 0 0 3px rgba(242, 84, 45, 0.35);

  /* Layout */
  --container: 1160px;
  --sidebar-width: 248px;
  --topbar-height: 64px;
  --transition: 150ms ease;

  color-scheme: light;
}

[data-theme="dark"] {
  --color-accent: #ff6a45;
  --color-accent-hover: #ff8565;
  --color-accent-soft: #3a1f18;
  --color-success: #3fbf8f;
  --color-success-soft: #12291f;
  --color-warning: #e3a43a;
  --color-warning-soft: #2e2311;
  --color-danger: #f0706b;
  --color-danger-soft: #331816;
  --color-info: #7aa2f7;
  --color-info-soft: #172238;
  --color-sim: #b392f0;
  --color-sim-soft: #251b38;

  --color-bg: #0e1116;
  --color-surface: #161a21;
  --color-surface-2: #1b2029;
  --color-border: #262c37;
  --color-border-strong: #353d4b;
  --color-text: #eceef2;
  --color-text-muted: #a3a9b6;
  --color-text-subtle: #737a88;
  --color-ink: #eceef2;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.5);

  color-scheme: dark;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}
img, video, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--color-accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--color-accent-hover); }
h1, h2, h3, h4 { margin: 0 0 var(--space-3); line-height: var(--leading-tight); color: var(--color-ink); letter-spacing: -0.01em; }
h1 { font-size: var(--text-3xl); font-weight: 750; }
h2 { font-size: var(--text-2xl); font-weight: 700; }
h3 { font-size: var(--text-lg); font-weight: 650; }
p { margin: 0 0 var(--space-4); }
code { font-family: var(--font-mono); font-size: 0.9em; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }
[hidden] { display: none !important; }

/* ---------- Language / RTL ---------- */
html.i18n-pending body { visibility: hidden; }
html[lang="ar"] {
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Arabic", "Geeza Pro", "Segoe UI", Tahoma, "Noto Sans Arabic", Arial, sans-serif;
}
/* Arabic script must not be letter-spaced or upper-cased */
html[lang="ar"] h1, html[lang="ar"] h2, html[lang="ar"] h3, html[lang="ar"] h4,
html[lang="ar"] .brand, html[lang="ar"] .eyebrow, html[lang="ar"] .hero h1,
html[lang="ar"] .stat-label, html[lang="ar"] .nav-group-title, html[lang="ar"] .table th,
html[lang="ar"] .badge-sim, html[lang="ar"] .stat-value { letter-spacing: 0; text-transform: none; }
html[lang="ar"] body { line-height: 1.7; }
/* Keep IDs, codes, emails and URLs left-to-right inside Arabic text */
.ltr, .mono, input[type="email"], input[type="url"], code { direction: ltr; unicode-bidi: isolate; }
html[dir="rtl"] input[type="email"], html[dir="rtl"] input[type="url"] { text-align: right; }
/* LTR values (codes, IDs, numbers) keep LTR order but align with the RTL layout */
html[dir="rtl"] :is(dd, td, div, p, input).ltr, html[dir="rtl"] :is(dd, td, div, p).mono { text-align: right; }
.lang-toggle { font-weight: 650; min-width: 72px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- Utilities ---------- */
.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 var(--space-6); }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; inset-inline-start: -999px; top: var(--space-2); background: var(--color-surface); padding: var(--space-2) var(--space-4); z-index: 1000; }
.skip-link:focus { inset-inline-start: var(--space-2); }
.muted { color: var(--color-text-muted); }
.subtle { color: var(--color-text-subtle); font-size: var(--text-sm); }
.stack > * + * { margin-top: var(--space-4); }
.row { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: var(--space-3); align-items: center; justify-content: space-between; flex-wrap: wrap; }
.mono { font-family: var(--font-mono); font-size: var(--text-sm); }

/* ---------- Public site ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--color-bg); /* fallback for Safari < 16.2 */
  background: color-mix(in srgb, var(--color-bg) 88%, transparent);
  backdrop-filter: saturate(150%) blur(8px);
  -webkit-backdrop-filter: saturate(150%) blur(8px);
  border-bottom: 1px solid var(--color-border);
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; height: 68px; gap: var(--space-4); }
.brand { display: inline-flex; align-items: center; gap: var(--space-2); font-weight: 750; color: var(--color-ink); text-decoration: none; letter-spacing: -0.02em; }
.brand:hover { color: var(--color-ink); }
.brand-mark {
  width: 38px; height: 38px; border-radius: 8px;
  display: block; flex: none;
  background: url('../images/AAM.png') center / contain no-repeat;
  color: transparent; font-size: 0;
}
.site-nav { display: flex; align-items: center; gap: var(--space-5); }
.site-nav a:not(.btn) { color: var(--color-text-muted); text-decoration: none; font-size: var(--text-sm); font-weight: 550; }
.site-nav a:not(.btn):hover { color: var(--color-ink); }

.hero { padding: var(--space-20) 0 var(--space-16); }
.hero-grid { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: var(--space-12); align-items: center; }
.hero-grid > * { min-width: 0; }
.eyebrow { display: inline-block; font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-accent); margin-bottom: var(--space-4); }
.hero h1 { font-size: var(--text-4xl); letter-spacing: -0.03em; max-width: 14ch; }
.hero .lead { font-size: var(--text-lg); color: var(--color-text-muted); max-width: 52ch; }

.flow-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: var(--space-6); }
.flow-step { display: grid; grid-template-columns: 32px 1fr auto; gap: var(--space-3); align-items: center; padding: var(--space-3) 0; border-bottom: 1px dashed var(--color-border); }
.flow-step:last-child { border-bottom: 0; }
.flow-step .num { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--color-surface-2); border: 1px solid var(--color-border); font-size: var(--text-xs); font-weight: 700; }
.flow-step strong { display: block; font-size: var(--text-sm); }
.flow-step span { font-size: var(--text-xs); color: var(--color-text-muted); }

.section { padding: var(--space-16) 0; }
.section-alt { background: var(--color-surface); border-top: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border); }
.section-head { max-width: 640px; margin-bottom: var(--space-10); }
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-6); }
.feature { padding: var(--space-6); border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); }
.feature h3 { margin-top: var(--space-3); }
.feature p { color: var(--color-text-muted); font-size: var(--text-sm); margin: 0; }
.feature-icon { width: 36px; height: 36px; border-radius: var(--radius-md); background: var(--color-accent-soft); color: var(--color-accent); display: grid; place-items: center; }

.guardrails { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-4); }
.guardrail { display: flex; gap: var(--space-3); padding: var(--space-4); border-radius: var(--radius-md); background: var(--color-surface-2); border: 1px solid var(--color-border); font-size: var(--text-sm); }

.cta-band { background: var(--color-ink); color: var(--color-bg); border-radius: var(--radius-lg); padding: var(--space-12); display: flex; justify-content: space-between; align-items: center; gap: var(--space-6); flex-wrap: wrap; }
.cta-band h2 { color: inherit; margin: 0; }
[data-theme="dark"] .cta-band { background: var(--color-surface-2); color: var(--color-text); border: 1px solid var(--color-border); }

.site-footer { padding: var(--space-10) 0; border-top: 1px solid var(--color-border); font-size: var(--text-sm); color: var(--color-text-muted); }
.site-footer .container { display: flex; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.site-footer nav { display: flex; gap: var(--space-5); flex-wrap: wrap; }
.site-footer a { color: var(--color-text-muted); text-decoration: none; }
.site-footer a:hover { color: var(--color-ink); }

/* Legal pages */
.prose { max-width: 760px; margin: 0 auto; padding: var(--space-12) var(--space-6) var(--space-16); }
.prose h2 { margin-top: var(--space-10); font-size: var(--text-xl); }
.prose p, .prose li { color: var(--color-text-muted); }
.prose .notice { padding: var(--space-4); border-radius: var(--radius-md); background: var(--color-warning-soft); color: var(--color-warning); font-size: var(--text-sm); }

/* Auth pages */
.auth-page { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; }
.auth-main { display: grid; place-items: center; padding: var(--space-10) var(--space-4); }
.auth-card { width: 100%; max-width: 420px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: var(--space-8); }
.auth-card h1 { font-size: var(--text-2xl); }
.auth-card .switch { margin-top: var(--space-6); font-size: var(--text-sm); color: var(--color-text-muted); text-align: center; }

/* Phase 5 — public pricing & contact */
.hp-field { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.site-nav a[aria-current="page"] { color: var(--color-ink); font-weight: 650; }
.period-toggle { display: inline-flex; padding: 3px; border-radius: var(--radius-pill); background: var(--color-surface-2); border: 1px solid var(--color-border); }
.period-toggle button { border: 0; background: none; padding: 6px 14px; border-radius: var(--radius-pill); font: inherit; font-size: var(--text-sm); font-weight: 600; color: var(--color-text-muted); cursor: pointer; }
.period-toggle button[aria-pressed="true"] { background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-sm); }
.plan-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); }
.plan-card { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-5); border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); }
.plan-card.is-featured { border-color: var(--color-accent); box-shadow: var(--focus-ring); }
.plan-card h3 { margin: 0; }
.plan-price { font-size: var(--text-xl); overflow-wrap: anywhere; font-weight: 750; font-variant-numeric: tabular-nums; }
.plan-price small { font-size: var(--text-sm); font-weight: 500; color: var(--color-text-muted); }
.plan-card ul { list-style: none; margin: 0; padding: 0; font-size: var(--text-sm); color: var(--color-text-muted); display: grid; gap: 6px; flex: 1; }
.plan-card li::before { content: "✓ "; color: var(--color-success); font-weight: 700; }

/* ---------- Registration page specific styles ---------- */
.auth-page:has(.register-card) {
  position: relative;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 14% 18%, rgba(255, 196, 66, 0.22), transparent 20rem),
    radial-gradient(circle at 86% 72%, rgba(242, 84, 45, 0.16), transparent 22rem),
    radial-gradient(circle at 78% 12%, rgba(91, 141, 255, 0.13), transparent 18rem),
    var(--color-bg);
}
.auth-page:has(.register-card)::before,
.auth-page:has(.register-card)::after {
  content: ""; position: fixed; width: 260px; height: 260px; border-radius: 50%; pointer-events: none; z-index: 0; filter: blur(18px); opacity: 0.55;
  animation: register-orb 10s ease-in-out infinite alternate;
}
.auth-page:has(.register-card)::before { left: -110px; bottom: 8%; background: conic-gradient(from 90deg, #ff4f81, #ffd166, #4cc9f0, #7b61ff, #ff4f81); }
.auth-page:has(.register-card)::after { right: -130px; top: 12%; background: conic-gradient(from 180deg, #ffd166, #ff8c42, #ff4f81, #5f8cff, #ffd166); animation-delay: -5s; }
.auth-page:has(.register-card) .auth-main { position: relative; z-index: 1; }
.register-card {
  max-width: 460px;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(214, 168, 55, 0.42);
  background: color-mix(in srgb, var(--color-surface) 94%, transparent);
  box-shadow: 0 24px 70px rgba(92, 61, 10, 0.18), 0 0 38px rgba(255, 196, 66, 0.12);
  backdrop-filter: blur(16px);
}
.register-card::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 3px;
  background: linear-gradient(90deg, #ff4f81, #ffd166, #ff9f1c, #4cc9f0, #7b61ff, #ff4f81);
  background-size: 200% 100%; animation: register-shimmer 4s linear infinite;
}
.register-card h1 { background: linear-gradient(90deg, var(--color-text), #b78a25 65%, #e6b84a); -webkit-background-clip: text; background-clip: text; color: transparent; }
.register-badge { display: inline-flex; align-items: center; gap: 7px; margin-bottom: var(--space-4); padding: 6px 11px; border: 1px solid rgba(214, 168, 55, 0.42); border-radius: var(--radius-pill); background: rgba(255, 209, 102, 0.12); color: #b58a25; font-size: var(--text-xs); font-weight: 750; letter-spacing: 0.03em; }
.register-card .input { transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition); }
.register-card .input:focus { border-color: #d4a72c; box-shadow: 0 0 0 3px rgba(212, 167, 44, 0.20), 0 8px 24px rgba(212, 167, 44, 0.10); transform: translateY(-1px); }
.register-card .btn-primary { border: 0; background: linear-gradient(135deg, #d9a826 0%, #f3cf62 48%, #b98418 100%); color: #241805; box-shadow: 0 10px 28px rgba(207, 158, 38, 0.30); }
.register-card .btn-primary:hover:not(:disabled) { background: linear-gradient(135deg, #e7b933, #ffe17a, #c59220); color: #241805; box-shadow: 0 14px 34px rgba(207, 158, 38, 0.42); }
.register-card a { color: #b18420; }
@keyframes register-shimmer { to { background-position: 200% 0; } }
@keyframes register-orb { 0% { transform: translate3d(-10px, 0, 0) scale(0.92); } 100% { transform: translate3d(28px, -24px, 0) scale(1.08); } }

/* ---------- Login page specific styles ---------- */
.auth-page:has(.login-card) {
  position: relative;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 10% 20%, rgba(255, 196, 66, 0.22), transparent 19rem),
    radial-gradient(circle at 88% 76%, rgba(76, 201, 240, 0.16), transparent 22rem),
    radial-gradient(circle at 82% 14%, rgba(255, 79, 129, 0.14), transparent 17rem),
    radial-gradient(circle at 24% 82%, rgba(123, 97, 255, 0.12), transparent 18rem),
    var(--color-bg);
}
.auth-page:has(.login-card)::before,
.auth-page:has(.login-card)::after {
  content: ""; position: fixed; width: 280px; height: 280px; border-radius: 50%; pointer-events: none; z-index: 0; filter: blur(22px); opacity: 0.48;
  animation: login-orb 11s ease-in-out infinite alternate;
}
.auth-page:has(.login-card)::before { left: -150px; top: 20%; background: conic-gradient(from 45deg, #ff4f81, #ffd166, #4cc9f0, #7b61ff, #ff4f81); }
.auth-page:has(.login-card)::after { right: -155px; bottom: 8%; background: conic-gradient(from 210deg, #ffd166, #ff9f1c, #ff4f81, #5f8cff, #ffd166); animation-delay: -6s; }
.auth-page:has(.login-card) .auth-main { position: relative; z-index: 1; }
.login-card {
  max-width: 440px;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(214, 168, 55, 0.44);
  background: color-mix(in srgb, var(--color-surface) 94%, transparent);
  box-shadow: 0 24px 70px rgba(92, 61, 10, 0.18), 0 0 42px rgba(255, 196, 66, 0.13);
  backdrop-filter: blur(16px);
}
.login-card::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 3px;
  background: linear-gradient(90deg, #7b61ff, #4cc9f0, #ffd166, #ff9f1c, #ff4f81, #7b61ff);
  background-size: 220% 100%; animation: login-shimmer 4.5s linear infinite;
}
.login-card h1 { background: linear-gradient(90deg, var(--color-text), #b78a25 60%, #e6b84a); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-badge { display: inline-flex; align-items: center; gap: 7px; margin-bottom: var(--space-4); padding: 6px 11px; border: 1px solid rgba(214, 168, 55, 0.42); border-radius: var(--radius-pill); background: rgba(255, 209, 102, 0.12); color: #b58a25; font-size: var(--text-xs); font-weight: 750; letter-spacing: 0.03em; }
.login-card .input { transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition); }
.login-card .input:focus { border-color: #d4a72c; box-shadow: 0 0 0 3px rgba(212, 167, 44, 0.20), 0 8px 24px rgba(212, 167, 44, 0.10); transform: translateY(-1px); }
.login-card .btn-primary { border: 0; background: linear-gradient(135deg, #d9a826 0%, #f3cf62 48%, #b98418 100%); color: #241805; box-shadow: 0 10px 28px rgba(207, 158, 38, 0.30); }
.login-card .btn-primary:hover:not(:disabled) { background: linear-gradient(135deg, #e7b933, #ffe17a, #c59220); color: #241805; box-shadow: 0 14px 34px rgba(207, 158, 38, 0.42); }
.login-card a { color: #b18420; }
[data-theme="dark"] .login-card h1 { background-image: linear-gradient(90deg, #fff, #f3cf62 65%, #ffd982); }
[data-theme="dark"] .login-badge { color: #f3cf62; }
@keyframes login-shimmer { to { background-position: 220% 0; } }
@keyframes login-orb { 0% { transform: translate3d(-8px, 0, 0) scale(0.92) rotate(0deg); } 100% { transform: translate3d(30px, -28px, 0) scale(1.08) rotate(18deg); } }

/* Workspace-wide luminous gold accents */
body:not(.dashboard-page) .card,
body:not(.dashboard-page) .auth-card,
body:not(.dashboard-page) .feature-card,
body:not(.dashboard-page) .pricing-card {
  border-color: rgba(214, 168, 55, 0.24);
  box-shadow: 0 12px 34px rgba(92, 61, 10, 0.08), 0 0 20px rgba(255, 196, 66, 0.055);
  transition: transform 220ms ease, border-color 220ms ease, box-shadow 220ms ease;
}
body:not(.dashboard-page) .card:hover,
body:not(.dashboard-page) .auth-card:hover,
body:not(.dashboard-page) .feature-card:hover,
body:not(.dashboard-page) .pricing-card:hover {
  transform: translateY(-3px);
  border-color: rgba(214, 168, 55, 0.48);
  box-shadow: 0 18px 44px rgba(92, 61, 10, 0.13), 0 0 26px rgba(255, 196, 66, 0.12);
}
body:not(.dashboard-page) .btn-primary {
  border: 0;
  background: linear-gradient(135deg, #b98418, #f3cf62 48%, #d99d24);
  color: #241805;
  box-shadow: 0 10px 28px rgba(207, 158, 38, 0.24);
}
body:not(.dashboard-page) .btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #cf9a22, #ffe17a, #b98418);
  box-shadow: 0 14px 34px rgba(207, 158, 38, 0.34), 0 0 22px rgba(255, 209, 102, 0.16);
}
body:not(.dashboard-page) .hero h1,
body:not(.dashboard-page) .auth-card h1,
body:not(.dashboard-page) .page-header h1 {
  background: linear-gradient(90deg, var(--color-text), #b78a25 58%, #e6b84a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
@media (prefers-reduced-motion: reduce) {
  body:not(.dashboard-page) .card,
  body:not(.dashboard-page) .auth-card,
  body:not(.dashboard-page) .feature-card,
  body:not(.dashboard-page) .pricing-card,
  body:not(.dashboard-page) .btn-primary { transition: none; }
}
