/* RADIUS Sovereign — functional prototype
   Tokens from figma-spec.json (RADIUS Phase 5).
   Dark, bilingual EN/AR, brand blue/purple, Saudi cultural motifs. */

:root {
  --navy-900: #0A1524;
  --navy-800: #0E1B2E;
  --navy-700: #132840;
  --navy-600: #1B3250;
  --navy-500: #243d5d;

  --blue-400: #5374fa;
  --blue-300: #869efa;
  --blue-200: #bac7fd;

  --purple-500: #8B6FF7;
  --purple-400: #A48AFF;
  --purple-300: #B89CFF;

  --text:      #E7ECF5;
  --text-dim:  #97A3B8;
  --text-mute: #5b6979;

  --bg-0: #060B15;
  --bg-1: #0B1524;
  --bg-2: #0F1C30;

  --line:        rgba(172, 185, 214, 0.12);
  --line-strong: rgba(172, 185, 214, 0.22);

  --focus:   #7A94FF;
  --success: #38D9A9;
  --warn:    #FFB05A;

  --grad-brand: linear-gradient(135deg, #5374fa 0%, #8B6FF7 100%);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;

  --font-display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --font-body:    'Inter', system-ui, sans-serif;
  --font-mono:    'DM Mono', ui-monospace, SFMono-Regular, monospace;
  --font-ar:      'Noto Kufi Arabic', 'Inter', sans-serif;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

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

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  background-image:
    radial-gradient(1200px 600px at 50% -10%, rgba(139,111,247,0.12), transparent 60%),
    radial-gradient(900px 500px at 90% 110%, rgba(83,116,250,0.10), transparent 60%);
  background-attachment: fixed;
}

body[dir="rtl"] { font-family: var(--font-ar); }

a { color: var(--blue-300); text-decoration: none; }
a:hover { color: var(--blue-200); }
button { font-family: inherit; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 4px; }

.skip-link { position: absolute; top: -40px; left: 8px; background: var(--navy-700); color: var(--text); padding: 8px 12px; border-radius: 6px; }
.skip-link:focus { top: 8px; }

/* ===== Layout ===== */
.app { max-width: 1440px; margin: 0 auto; padding: 24px 28px 64px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 14px; margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex; align-items: center; gap: 12px;
  font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; font-size: 17px;
}
.brand-mark {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--grad-brand);
  display: grid; place-items: center;
  color: #fff; font-size: 12px;
}
.brand-ar { color: var(--text-dim); font-size: 12px; font-weight: 400; font-family: var(--font-ar); }

.topbar-right { display: flex; gap: 8px; align-items: center; }

.kbd {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  font-family: var(--font-mono); font-size: 10px;
  color: var(--text-dim);
  background: rgba(255,255,255,0.02);
}

/* ===== Tabs ===== */
.navtabs {
  display: flex; gap: 4px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 18px;
}
.navtab {
  flex: 1;
  background: transparent; border: 0; cursor: pointer;
  padding: 10px 14px;
  color: var(--text-dim); font-size: 13px; letter-spacing: 0.01em;
  border-radius: 8px;
  transition: all 140ms var(--ease-out);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.navtab:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.navtab.is-active {
  color: var(--text);
  background: linear-gradient(135deg, rgba(83,116,250,0.18), rgba(139,111,247,0.18));
  border: 1px solid rgba(139,111,247,0.45);
}
.navtab .count {
  font-size: 10px; font-family: var(--font-mono);
  background: rgba(255,255,255,0.05);
  padding: 1px 6px; border-radius: 999px;
  color: var(--text-dim);
}
.navtab.is-active .count { color: var(--blue-200); background: rgba(83,116,250,0.18); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px;
  border: 0; border-radius: 10px;
  font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all 180ms var(--ease-out);
}
.btn-primary {
  background: var(--grad-brand); color: #fff;
  box-shadow: 0 6px 22px -6px rgba(83,116,250,0.5);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 32px -8px rgba(83,116,250,0.65); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-ghost {
  background: rgba(255,255,255,0.02); color: var(--text);
  border: 1px solid var(--line-strong);
}
.btn-ghost:hover { background: rgba(139,111,247,0.06); border-color: rgba(139,111,247,0.5); }

.btn-danger {
  background: rgba(255,176,90,0.08); color: var(--warn);
  border: 1px solid rgba(255,176,90,0.3);
}

.btn-sm { padding: 6px 10px; font-size: 11px; }

/* ===== Tab panels ===== */
.tab-panel { display: none; animation: fadeIn 220ms var(--ease-out); }
.tab-panel.is-active { display: block; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ===== Cards / surfaces ===== */
.card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px;
}
.card-title { font-family: var(--font-display); font-size: 16px; font-weight: 600; margin: 0 0 6px; color: var(--text); }
.card-sub   { color: var(--text-dim); font-size: 12px; margin: 0; }

.label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-mute);
}

/* ===== Tag chips ===== */
.tag {
  display: inline-flex; align-items: center;
  font-family: var(--font-mono);
  font-size: 10px; line-height: 1;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--line);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 140ms var(--ease-out);
  margin: 2px;
}
.tag:hover { color: var(--text); border-color: rgba(139,111,247,0.45); }
.tag.is-active {
  background: linear-gradient(135deg, rgba(83,116,250,0.22), rgba(139,111,247,0.22));
  border-color: rgba(139,111,247,0.55);
  color: var(--text);
}
.tag .tag-count { color: var(--text-mute); margin-left: 6px; }
.tag.is-active .tag-count { color: var(--blue-200); }

.tag-source     { color: var(--blue-300); border-color: rgba(134,158,250,0.25); }
.tag-consultant { color: var(--purple-300); border-color: rgba(184,156,255,0.25); }
.tag-topic      { color: var(--text-dim); }
.tag-year       { color: var(--success); border-color: rgba(56,217,169,0.22); }
.tag-ext        { color: var(--text-mute); }
.tag-lang       { color: var(--text-mute); }
.tag-stakeholder { color: var(--purple-300); border-color: rgba(184,156,255,0.30); }
.tag-due         { color: var(--success); border-color: rgba(56,217,169,0.30); }

/* ===== Overview / dashboard ===== */
.stat-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
  margin-bottom: 22px;
}
.stat {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px;
  position: relative; overflow: hidden;
}
.stat-num { font-family: var(--font-display); font-size: 32px; font-weight: 600; line-height: 1; letter-spacing: -0.02em; color: var(--text); }
.stat-label { color: var(--text-dim); font-size: 12px; margin-top: 6px; }
.stat-glow { position: absolute; inset: -40% -10% auto auto; width: 180px; height: 180px; background: radial-gradient(circle, rgba(83,116,250,0.25), transparent 60%); pointer-events: none; }

.section-title {
  font-family: var(--font-display); font-size: 22px; font-weight: 600;
  letter-spacing: -0.01em; margin: 28px 0 10px;
}
.section-sub { color: var(--text-dim); margin: 0 0 16px; }

/* ===== Search ===== */
.search-bar {
  display: flex; gap: 10px;
  background: var(--bg-1);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 10px;
  align-items: center;
  margin-bottom: 12px;
}
.search-bar input {
  flex: 1;
  background: transparent; border: 0; outline: 0;
  color: var(--text); font-size: 15px;
  padding: 8px 6px;
  font-family: inherit;
}
.search-bar .search-icon { color: var(--text-dim); padding-left: 4px; }

.suggest-row {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin: 10px 0 18px;
}

.results-meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
  color: var(--text-dim); font-size: 12px;
}

.results { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.result-item {
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  cursor: pointer; transition: all 140ms var(--ease-out);
}
.result-item:hover { border-color: rgba(139,111,247,0.45); transform: translateY(-1px); }
.result-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 4px; }
.result-title { font-family: var(--font-display); font-size: 15px; color: var(--text); margin: 0; }
.result-score-bar { display: flex; align-items: center; gap: 6px; }
.result-score-num { font-family: var(--font-mono); font-size: 11px; color: var(--blue-300); }
.result-score-track { width: 60px; height: 4px; background: var(--navy-700); border-radius: 2px; overflow: hidden; }
.result-score-fill { height: 100%; background: var(--grad-brand); }
.result-snippet { color: var(--text-dim); font-size: 13px; line-height: 1.5; margin: 4px 0; }
.result-snippet mark { background: rgba(83,116,250,0.25); color: var(--blue-200); padding: 0 2px; border-radius: 2px; }
.result-tags { margin-top: 6px; }

/* ===== Browse ===== */
.browse-layout { display: grid; grid-template-columns: 220px 1fr; gap: 18px; }
.facets .label { display: block; margin: 14px 0 6px; }
.facets-section { background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px; }

.doc-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px;
}
.doc-card {
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px;
  cursor: pointer; transition: all 140ms var(--ease-out);
}
.doc-card:hover { border-color: rgba(139,111,247,0.45); transform: translateY(-2px); }
.doc-title { font-size: 13px; color: var(--text); margin: 0 0 8px; line-height: 1.4; }
.doc-tags { display: flex; flex-wrap: wrap; gap: 3px; }
.doc-card .ext { font-family: var(--font-mono); font-size: 9px; color: var(--text-mute); text-transform: uppercase; }

/* ===== Upload ===== */
.dropzone {
  border: 1.5px dashed rgba(139,111,247,0.4);
  border-radius: var(--r-lg);
  padding: 56px;
  text-align: center;
  background:
    radial-gradient(600px 220px at 50% -10%, rgba(139,111,247,0.30), transparent 60%),
    var(--bg-1);
  position: relative; overflow: hidden;
  cursor: pointer; transition: all 240ms var(--ease-out);
}
.dropzone:hover, .dropzone.is-drag {
  border-color: rgba(139,111,247,0.8);
  background:
    radial-gradient(600px 220px at 50% -10%, rgba(139,111,247,0.50), transparent 60%),
    var(--bg-1);
}
.drop-title { font-family: var(--font-display); font-size: 22px; color: var(--text); margin: 12px 0 6px; }
.drop-sub { color: var(--text-dim); margin: 0 0 14px; }
.drop-formats { display: flex; gap: 8px; justify-content: center; padding: 0; margin: 0; list-style: none; }
.drop-formats li {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.1em;
  color: var(--text-dim); padding: 4px 8px;
  border: 1px solid var(--line); border-radius: 6px;
}

.demo-cta-row { display: flex; gap: 10px; justify-content: center; margin-top: 18px; }

/* ===== Analyze ===== */
.analyze-grid {
  display: grid; grid-template-columns: 240px 1fr 280px; gap: 14px;
  align-items: start;
}
@media (max-width: 1100px) { .analyze-grid { grid-template-columns: 1fr; } }

.pipeline { display: flex; flex-direction: column; gap: 14px; }
.pipeline-stage {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 4px 0;
}
.pipeline-stage.is-pending { opacity: 0.4; }
.stage-dot {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1px solid var(--text-mute);
  display: grid; place-items: center;
  color: var(--text-mute); font-size: 11px;
  flex-shrink: 0;
}
.pipeline-stage.is-running .stage-dot {
  background: var(--grad-brand);
  border-color: transparent;
  color: #fff;
  animation: pulse 1.4s ease-in-out infinite;
}
.pipeline-stage.is-done .stage-dot {
  background: var(--success); border-color: var(--success); color: var(--navy-900);
}
.pipeline-stage.is-failed .stage-dot {
  background: var(--warn); border-color: var(--warn); color: var(--navy-900);
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(139,111,247,0.55); }
  50%      { box-shadow: 0 0 0 10px rgba(139,111,247,0); }
}

.stage-body { flex: 1; }
.stage-title { font-size: 13px; color: var(--text); }
.stage-sub { font-size: 11px; color: var(--text-mute); margin-top: 2px; }
.stage-bar { height: 3px; background: var(--navy-700); border-radius: 2px; overflow: hidden; margin-top: 6px; }
.stage-bar-fill { height: 100%; background: var(--grad-brand); transition: width 200ms linear; }

.brief-preview-skel { display: flex; flex-direction: column; gap: 8px; }
.skel-line { height: 12px; background: var(--navy-700); border-radius: 6px; opacity: 0.5; }
.skel-line.s60 { width: 60%; opacity: 0.4; }
.skel-line.s80 { width: 80%; opacity: 0.5; }
.skel-line.s40 { width: 40%; opacity: 0.3; }

/* ===== Brief ===== */
.brief-grid {
  display: grid; grid-template-columns: 200px 1fr 280px; gap: 14px;
  align-items: start;
}
@media (max-width: 1100px) { .brief-grid { grid-template-columns: 1fr; } }

.recent-rail { display: flex; flex-direction: column; gap: 6px; }
.recent-item {
  background: transparent; border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: 10px 12px;
  cursor: pointer; transition: all 140ms var(--ease-out);
}
.recent-item:hover { background: rgba(255,255,255,0.02); border-color: var(--line); }
.recent-item.is-active {
  background: linear-gradient(135deg, rgba(83,116,250,0.18), rgba(139,111,247,0.18));
  border-color: rgba(139,111,247,0.45);
}
.recent-title { font-size: 12px; color: var(--text); line-height: 1.35; }
.recent-meta  { font-size: 10px; color: var(--text-mute); margin-top: 3px; }

.brief-content { background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 22px; }
.brief-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 16px; }
.brief-title { font-family: var(--font-display); font-size: 22px; font-weight: 600; letter-spacing: -0.01em; color: var(--text); margin: 4px 0 0; }
.brief-section { margin-bottom: 16px; }
.brief-section h4 { display: block; margin: 0 0 8px; }

.win-theme {
  background: var(--bg-2);
  border: 1px solid rgba(139,111,247,0.25);
  border-radius: var(--r-md);
  padding: 14px;
  line-height: 1.6;
  cursor: text;
}

.scope-list, .stake-list { list-style: none; padding: 0; margin: 0; font-size: 13px; line-height: 1.8; }
.scope-list li::before { content: "·  "; color: var(--text-mute); }
.stake-list li::before { content: "·  "; color: var(--text-mute); }
.scope-coverage-covered { color: var(--success); }
.scope-coverage-partial { color: var(--blue-300); }
.scope-coverage-gap     { color: var(--warn); }

.cite-row { display: flex; flex-wrap: wrap; gap: 6px; }
.cite {
  font-family: var(--font-mono);
  font-size: 10px;
  background: rgba(83,116,250,0.12);
  color: var(--blue-300);
  padding: 4px 8px;
  border: 1px solid rgba(83,116,250,0.25);
  border-radius: 6px;
  cursor: pointer;
  transition: all 140ms var(--ease-out);
}
.cite:hover { background: rgba(83,116,250,0.22); color: var(--blue-200); }

.brief-actions { display: flex; flex-direction: column; gap: 10px; }
.gaps-card {
  background: var(--bg-1);
  border: 1px solid rgba(255,176,90,0.3);
  border-radius: var(--r-md);
  padding: 12px;
}

/* ===== Proposal generator ===== */
.proposal-grid {
  display: grid; grid-template-columns: 280px 1fr; gap: 16px;
  align-items: start;
}
@media (max-width: 1100px) { .proposal-grid { grid-template-columns: 1fr; } }

.proposal-stages { display: flex; flex-direction: column; gap: 10px; }
.proposal-preview {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 22px;
  min-height: 480px;
  position: relative;
}
.slide-frame {
  background: linear-gradient(135deg, var(--navy-700), var(--navy-800));
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 24px;
  margin-bottom: 12px;
  aspect-ratio: 16 / 9;
  display: flex; flex-direction: column; justify-content: space-between;
}
.slide-frame .slide-eyebrow { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.16em; color: var(--blue-300); text-transform: uppercase; }
.slide-frame .slide-title  { font-family: var(--font-display); font-size: 28px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; color: var(--text); margin: 12px 0; }
.slide-frame .slide-foot   { display: flex; justify-content: space-between; color: var(--text-mute); font-family: var(--font-mono); font-size: 10px; }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--bg-2); border: 1px solid rgba(139,111,247,0.45);
  color: var(--text);
  padding: 12px 18px; border-radius: 12px;
  box-shadow: 0 12px 40px -8px rgba(0,0,0,0.5);
  font-size: 13px;
  z-index: 100;
  opacity: 0; pointer-events: none;
  transition: opacity 220ms var(--ease-out), transform 220ms var(--ease-out);
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(-4px); }

/* ===== RTL adjustments ===== */
body[dir="rtl"] .stage-bar-fill { direction: ltr; }
body[dir="rtl"] .tag { font-family: var(--font-mono); }

/* ===== Misc ===== */
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.gap-12 { gap: 12px; }
.muted { color: var(--text-dim); }
.right { margin-left: auto; }
[hidden] { display: none !important; }

.frame-kicker {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-mute);
  display: inline-flex; align-items: center; gap: 8px;
  margin-bottom: 6px;
}
.frame-kicker .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--purple-400); }

.empty-illus {
  display: grid; place-items: center;
  padding: 44px 0 28px;
}
.illus-svg { width: 220px; height: 220px; }
.illus-svg .arc { fill: none; stroke: var(--blue-300); stroke-width: 1.2; opacity: 0.5; }
.illus-svg .star { fill: none; stroke: var(--purple-400); stroke-width: 1.4; opacity: 0.85; }
