/* =============================================================
   MOTRJIM — Legal Translation System
   Design System & Component Library
   ============================================================= */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800;900&family=Crimson+Pro:ital,wght@0,400;0,600;0,700;1,400;1,600&family=Inter:wght@300;400;500;600;700&display=swap');

/* ── CSS Custom Properties ─────────────────────────────────── */
:root {
  /* Brand Palette */
  --gold-50:   #fffbeb;
  --gold-100:  #fef3c7;
  --gold-300:  #f5d98b;
  --gold-400:  #e2b83e;
  --gold-500:  #c9a040;
  --gold-600:  #a07828;
  --gold-700:  #78550f;
  --gold-800:  #4d3205;

  --purple-300: #c4b5fd;
  --purple-400: #a78bfa;
  --purple-500: #8b5cf6;
  --purple-600: #7c3aed;
  --purple-700: #6d28d9;
  --purple-800: #4c1d95;

  /* Backgrounds */
  --bg-void:     #040610;
  --bg-deep:     #080c18;
  --bg-base:     #0d1220;
  --bg-elevated: #141928;
  --bg-card:     rgba(255,255,255,0.035);
  --bg-card-hov: rgba(255,255,255,0.065);

  /* Text */
  --text-primary:   #eef0f8;
  --text-secondary: #8a94b0;
  --text-muted:     #505870;
  --text-gold:      var(--gold-500);
  --text-success:   #10b981;
  --text-error:     #f43f5e;
  --text-warning:   #f59e0b;
  --text-info:      var(--purple-400);

  /* Borders */
  --border-subtle: rgba(255,255,255,0.05);
  --border-light:  rgba(255,255,255,0.09);
  --border-gold:   rgba(201,160,64,0.3);
  --border-purple: rgba(139,92,246,0.3);
  --border-success:rgba(16,185,129,0.3);

  /* Glass */
  --glass-bg:     rgba(255,255,255,0.04);
  --glass-border: rgba(255,255,255,0.08);
  --glass-blur:   blur(24px);

  /* Shadows */
  --shadow-xs: 0 1px 4px rgba(0,0,0,0.25);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.35);
  --shadow-md: 0 6px 20px rgba(0,0,0,0.45);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.55);
  --shadow-xl: 0 24px 64px rgba(0,0,0,0.65);
  --shadow-gold:   0 6px 32px rgba(201,160,64,0.18);
  --shadow-purple: 0 6px 32px rgba(139,92,246,0.22);

  /* Radius */
  --r-xs:   4px;
  --r-sm:   8px;
  --r-md:   12px;
  --r-lg:   18px;
  --r-xl:   26px;
  --r-2xl:  36px;
  --r-full: 9999px;

  /* Transition */
  --t-fast: 120ms ease;
  --t-base: 240ms ease;
  --t-slow: 400ms cubic-bezier(0.4,0,0.2,1);

  /* Spacing scale */
  --s-1:  4px;
  --s-2:  8px;
  --s-3:  12px;
  --s-4:  16px;
  --s-5:  20px;
  --s-6:  24px;
  --s-8:  32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;

  /* Typography */
  --font-ar: 'Cairo', 'Noto Sans Arabic', system-ui, sans-serif;
  --font-en: 'Crimson Pro', Georgia, serif;
  --font-ui: 'Inter', system-ui, sans-serif;

  /* Z-index layers */
  --z-base: 1;
  --z-sticky: 20;
  --z-overlay: 100;
  --z-modal: 200;
  --z-toast: 300;
  --z-loading: 400;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }

/* ── Base ──────────────────────────────────────────────────── */
body, #motrjim-app {
  background-color: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-ar);
  min-height: 100vh;
  direction: rtl;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

#motrjim-app { position: relative; overflow-x: hidden; }

/* ── Ambient Background ────────────────────────────────────── */
.ambient-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.ambient-bg::before {
  content: '';
  position: absolute;
  top: -30%;
  right: -20%;
  width: 70vw;
  height: 70vw;
  background: radial-gradient(circle, rgba(139,92,246,0.07) 0%, transparent 65%);
  border-radius: 50%;
  animation: float1 20s ease-in-out infinite;
}
.ambient-bg::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -20%;
  width: 60vw;
  height: 60vw;
  background: radial-gradient(circle, rgba(201,160,64,0.05) 0%, transparent 65%);
  border-radius: 50%;
  animation: float2 25s ease-in-out infinite;
}
.grid-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px);
  background-size: 48px 48px;
}
@keyframes float1 { 0%,100%{transform:translate(0,0)} 50%{transform:translate(40px,-60px)} }
@keyframes float2 { 0%,100%{transform:translate(0,0)} 50%{transform:translate(-40px,50px)} }

/* ── Loading Overlay ───────────────────────────────────────── */
#loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(4,6,16,0.88);
  backdrop-filter: blur(10px);
  z-index: var(--z-loading);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: var(--s-5);
}
.loading-ring {
  width: 72px; height: 72px;
  border-radius: 50%;
  border: 3px solid rgba(201,160,64,0.15);
  border-top-color: var(--gold-500);
  animation: spin 0.9s linear infinite;
}
.loading-sub {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
}
#loading-message {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}
#loading-sub-message {
  font-size: 0.8rem;
  color: var(--text-muted);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast Notifications ───────────────────────────────────── */
.toast {
  position: fixed;
  bottom: var(--s-6);
  left: 50%;
  transform: translateX(-50%) translateY(0);
  z-index: var(--z-toast);
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-6);
  border-radius: var(--r-full);
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-lg);
  backdrop-filter: var(--glass-blur);
  font-size: 0.9rem;
  font-weight: 500;
  max-width: 480px;
  animation: toastIn 0.35s ease forwards;
}
.toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.toast-close {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 1.1rem; margin-right: auto;
  padding: 0 0 0 var(--s-2); line-height: 1;
}
.toast-info    { border-color: var(--border-purple); }
.toast-success { border-color: var(--border-success); }
.toast-error   { border-color: rgba(244,63,94,0.3);  }
.toast-warning { border-color: rgba(245,158,11,0.3); }
@keyframes toastIn {
  from { transform: translateX(-50%) translateY(30px); opacity:0; }
  to   { transform: translateX(-50%) translateY(0);   opacity:1; }
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--s-2);
  padding: 11px 26px;
  border: 1px solid transparent;
  border-radius: var(--r-full);
  font-family: var(--font-ar);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--t-base);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed !important; transform: none !important; }

.btn-primary {
  background: linear-gradient(135deg, var(--gold-500), var(--gold-700));
  color: #0a0600;
  box-shadow: var(--shadow-gold);
}
.btn-primary:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 36px rgba(201,160,64,0.38);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-light);
}
.btn-secondary:not(:disabled):hover {
  background: var(--bg-card-hov);
  border-color: var(--border-gold);
  transform: translateY(-1px);
}

.btn-purple {
  background: linear-gradient(135deg, var(--purple-500), var(--purple-700));
  color: #fff;
  box-shadow: var(--shadow-purple);
}
.btn-purple:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 36px rgba(139,92,246,0.38);
}

.btn-success {
  background: linear-gradient(135deg, #059669, #047857);
  color: #fff;
}
.btn-success:not(:disabled):hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(5,150,105,0.32); }

.btn-danger {
  background: rgba(244,63,94,0.12);
  color: #f43f5e;
  border-color: rgba(244,63,94,0.25);
}
.btn-danger:not(:disabled):hover { background: rgba(244,63,94,0.22); transform: translateY(-1px); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
  padding: 9px 18px;
}
.btn-ghost:not(:disabled):hover { color: var(--text-primary); border-color: var(--border-light); }

.btn-full { width: 100%; }
.btn-sm   { padding: 7px 16px; font-size: 0.82rem; }
.btn-lg   { padding: 15px 40px; font-size: 1.05rem; }
.btn-icon { width: 40px; height: 40px; padding: 0; border-radius: 50%; }

/* ── Password Screen ───────────────────────────────────────── */
.password-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-6);
  position: relative;
  z-index: var(--z-base);
}
.password-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  border-radius: var(--r-2xl);
  padding: var(--s-12) var(--s-8);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-gold), var(--shadow-xl);
  text-align: center;
  animation: scaleIn 0.5s cubic-bezier(0.34,1.56,0.64,1);
}
.logo-glyph {
  width: 88px; height: 88px;
  background: linear-gradient(135deg, var(--gold-500), var(--purple-600));
  border-radius: var(--r-xl);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2.8rem;
  margin-bottom: var(--s-5);
  box-shadow: var(--shadow-gold);
}
.password-card h1 {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  background: linear-gradient(135deg, var(--gold-400), var(--purple-300));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: var(--s-1);
}
.password-card .tagline {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: var(--s-8);
}
.pw-input-wrap {
  position: relative;
  margin-bottom: var(--s-4);
}
.pw-input {
  width: 100%;
  padding: 14px 52px 14px 52px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-light);
  border-radius: var(--r-full);
  color: var(--text-primary);
  font-family: var(--font-ar);
  font-size: 1.1rem;
  text-align: center;
  letter-spacing: 0.25em;
  transition: var(--t-base);
  outline: none;
}
.pw-input:focus {
  border-color: var(--gold-500);
  box-shadow: 0 0 0 4px rgba(201,160,64,0.12);
  background: rgba(255,255,255,0.07);
}
.pw-input.shake { animation: shake 0.4s ease; }
.pw-toggle {
  position: absolute;
  left: 16px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: var(--s-1);
  border-radius: var(--r-sm);
  transition: var(--t-fast);
}
.pw-toggle:hover { color: var(--text-primary); }
.pw-error {
  color: var(--text-error);
  font-size: 0.8rem;
  margin-top: var(--s-2);
  min-height: 1.2em;
  transition: var(--t-base);
}

/* ── Mode Select Screen ────────────────────────────────────── */
.mode-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--s-8);
  position: relative;
  z-index: var(--z-base);
}
.mode-header { text-align: center; margin-bottom: var(--s-12); }
.mode-header .back-btn {
  display: inline-flex; align-items: center; gap: var(--s-2);
  color: var(--text-muted); font-size: 0.85rem;
  background: none; border: none; cursor: pointer;
  margin-bottom: var(--s-5); transition: var(--t-fast);
}
.mode-header .back-btn:hover { color: var(--text-primary); }
.mode-header h2 {
  font-size: 2.4rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--gold-400), var(--purple-300));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: var(--s-2);
}
.mode-header p { color: var(--text-secondary); font-size: 1rem; }

.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-6);
  max-width: 860px;
  width: 100%;
}
.mode-card {
  background: var(--glass-bg);
  border: 2px solid var(--border-light);
  border-radius: var(--r-xl);
  padding: var(--s-10) var(--s-8);
  text-align: center;
  cursor: pointer;
  transition: var(--t-slow);
  backdrop-filter: var(--glass-blur);
  position: relative;
  overflow: hidden;
}
.mode-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 50%, rgba(255,255,255,0.02));
  pointer-events: none;
}
.mode-card:hover { transform: translateY(-8px); }
.mode-card.autopilot:hover { border-color: var(--purple-500); box-shadow: var(--shadow-purple), var(--shadow-lg); }
.mode-card.expert:hover    { border-color: var(--gold-500);   box-shadow: var(--shadow-gold),   var(--shadow-lg); }

.mode-icon {
  width: 84px; height: 84px;
  border-radius: var(--r-lg);
  display: inline-flex;
  align-items: center; justify-content: center;
  font-size: 2.6rem;
  margin-bottom: var(--s-5);
}
.autopilot .mode-icon { background: linear-gradient(135deg, var(--purple-700), var(--purple-500)); }
.expert    .mode-icon { background: linear-gradient(135deg, var(--gold-700),   var(--gold-500));   }

.mode-card h3 { font-size: 1.5rem; font-weight: 800; margin-bottom: var(--s-3); }
.autopilot h3 { color: var(--purple-300); }
.expert    h3 { color: var(--gold-300);   }

.mode-card > p { color: var(--text-secondary); font-size: 0.9rem; line-height: 1.8; margin-bottom: var(--s-6); }

.mode-features { list-style: none; text-align: right; }
.mode-features li {
  display: flex; align-items: center; gap: var(--s-2);
  color: var(--text-muted); font-size: 0.82rem;
  padding: 3px 0;
}
.autopilot .mode-features li::before { content: '⟡'; color: var(--purple-400); font-size: 0.65rem; }
.expert    .mode-features li::before { content: '⟡'; color: var(--gold-500);   font-size: 0.65rem; }

.mode-cta {
  display: inline-flex; align-items: center; gap: var(--s-2);
  margin-top: var(--s-6);
  font-size: 0.9rem; font-weight: 700;
}
.autopilot .mode-cta { color: var(--purple-300); }
.expert    .mode-cta { color: var(--gold-300);   }

/* ── Step Wrapper ──────────────────────────────────────────── */
.step-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: var(--z-base);
}

/* ── Sticky Step Header ────────────────────────────────────── */
.step-header {
  position: sticky; top: 0; z-index: var(--z-sticky);
  background: rgba(8,12,24,0.92);
  backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border-subtle);
  padding: var(--s-3) var(--s-8);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--s-6);
}
.header-logo {
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  background: linear-gradient(135deg, var(--gold-500), var(--purple-400));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.progress-track {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}
.progress-node {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 700;
  transition: var(--t-base);
  flex-shrink: 0;
}
.progress-node.done    { background: linear-gradient(135deg, var(--gold-500), var(--gold-700)); color: #020100; }
.progress-node.active  { background: linear-gradient(135deg, var(--purple-500), var(--purple-700)); color: #fff; box-shadow: 0 0 0 4px rgba(139,92,246,0.2); }
.progress-node.pending { background: var(--bg-elevated); color: var(--text-muted); border: 1px solid var(--border-light); }
.progress-line {
  height: 2px;
  width: 28px;
  background: var(--border-subtle);
  flex-shrink: 0;
}
.progress-line.done { background: linear-gradient(90deg, var(--gold-700), var(--gold-500)); }

.header-mode-badge {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: 5px 14px;
  border-radius: var(--r-full);
  font-size: 0.78rem;
  font-weight: 600;
}
.mode-badge-autopilot { background: rgba(139,92,246,0.12); border: 1px solid var(--border-purple); color: var(--purple-300); }
.mode-badge-expert    { background: rgba(201,160,64,0.12);  border: 1px solid var(--border-gold);   color: var(--gold-300);   }

/* ── Step Body ─────────────────────────────────────────────── */
.step-body {
  flex: 1;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  padding: var(--s-10) var(--s-8);
}
.step-label {
  display: inline-flex; align-items: center; gap: var(--s-2);
  font-size: 0.73rem;
  font-weight: 700;
  color: var(--gold-500);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  margin-bottom: var(--s-2);
}
.step-label .step-num {
  width: 22px; height: 22px;
  background: rgba(201,160,64,0.15);
  border: 1px solid var(--border-gold);
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.7rem;
}
.step-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: var(--s-2);
  line-height: 1.3;
}
.step-description {
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.75;
  margin-bottom: var(--s-8);
}
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 10px;
  border-radius: var(--r-full);
  font-size: 0.72rem;
  font-weight: 600;
  margin-right: var(--s-2);
}
.badge-required { background: rgba(244,63,94,0.1); border: 1px solid rgba(244,63,94,0.25); color: #f43f5e; }
.badge-optional { background: rgba(80,88,112,0.15); border: 1px solid rgba(80,88,112,0.3); color: var(--text-muted); }

/* ── Step Navigation ───────────────────────────────────────── */
.step-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-8) 0 var(--s-4);
  border-top: 1px solid var(--border-subtle);
  margin-top: var(--s-8);
  gap: var(--s-3);
}
.step-nav-right, .step-nav-left { display: flex; gap: var(--s-3); }

/* ── Form Elements ─────────────────────────────────────────── */
.form-group { margin-bottom: var(--s-5); }
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--s-2);
}
.form-hint { font-size: 0.78rem; color: var(--text-muted); margin-top: var(--s-1); }

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 11px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-light);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-family: var(--font-ar);
  font-size: 0.9rem;
  transition: var(--t-base);
  outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--gold-500);
  box-shadow: 0 0 0 3px rgba(201,160,64,0.1);
  background: rgba(255,255,255,0.06);
}
.form-select {
  appearance: none;
  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='%23c9a040' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  padding-left: 38px;
  cursor: pointer;
}
.form-select option { background: var(--bg-elevated); }
.form-textarea { min-height: 110px; resize: vertical; line-height: 1.7; }

/* Formality Slider */
.formality-card {
  background: var(--glass-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  padding: var(--s-5);
}
.formality-card .fl-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--s-4);
}
.fl-label { font-size: 0.875rem; font-weight: 600; color: var(--text-primary); }
.fl-value {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--gold-500);
  background: rgba(201,160,64,0.1);
  border: 1px solid var(--border-gold);
  padding: 3px 12px;
  border-radius: var(--r-full);
}
input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-track {
  background: linear-gradient(to left, var(--gold-500) var(--fl-prog, 50%), var(--bg-elevated) var(--fl-prog, 50%));
  height: 6px;
  border-radius: var(--r-full);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  background: linear-gradient(135deg, var(--gold-400), var(--gold-700));
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(201,160,64,0.45);
  margin-top: -8px;
  transition: var(--t-fast);
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.2); }
.fl-ticks { display: flex; justify-content: space-between; margin-top: var(--s-2); }
.fl-tick {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: center;
  flex: 1;
}
.fl-tick.active { color: var(--gold-500); font-weight: 600; }

/* ── File Drop Zone ────────────────────────────────────────── */
.dropzone {
  border: 2px dashed var(--border-light);
  border-radius: var(--r-lg);
  padding: var(--s-12) var(--s-8);
  text-align: center;
  cursor: pointer;
  transition: var(--t-base);
  background: var(--glass-bg);
  position: relative;
  overflow: hidden;
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--gold-500);
  background: rgba(201,160,64,0.04);
}
.dropzone input[type="file"] {
  position: absolute; inset: 0;
  opacity: 0; cursor: pointer;
  width: 100%; height: 100%;
}
.dropzone-icon { font-size: 3.2rem; margin-bottom: var(--s-4); display: block; }
.dropzone h3 { font-size: 1.05rem; font-weight: 700; margin-bottom: var(--s-2); }
.dropzone p  { font-size: 0.82rem; color: var(--text-muted); margin-bottom: var(--s-4); }
.dropzone .formats {
  display: inline-flex; gap: var(--s-2);
  flex-wrap: wrap; justify-content: center;
}
.format-tag {
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
}

.file-preview {
  display: flex; align-items: center; gap: var(--s-4);
  padding: var(--s-4) var(--s-5);
  background: rgba(16,185,129,0.08);
  border: 1px solid var(--border-success);
  border-radius: var(--r-md);
  margin-top: var(--s-4);
  animation: fadeInUp 0.3s ease;
}
.file-preview .fp-icon { font-size: 2rem; flex-shrink: 0; }
.file-preview .fp-info { flex: 1; text-align: right; }
.file-preview .fp-name { font-weight: 600; font-size: 0.9rem; }
.file-preview .fp-size { font-size: 0.78rem; color: var(--text-muted); }
.fp-remove {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer; font-size: 1.1rem;
  padding: var(--s-1) var(--s-2); border-radius: var(--r-sm);
  transition: var(--t-fast);
}
.fp-remove:hover { color: var(--text-error); background: rgba(244,63,94,0.1); }

/* ── Card Component ────────────────────────────────────────── */
.card {
  background: var(--glass-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  padding: var(--s-6);
  backdrop-filter: var(--glass-blur);
  transition: var(--t-base);
}
.card:hover { border-color: var(--border-gold); }
.card-gold   { border-color: var(--border-gold);   background: rgba(201,160,64,0.04); }
.card-purple { border-color: var(--border-purple); background: rgba(139,92,246,0.04); }
.card-success{ border-color: var(--border-success); background: rgba(16,185,129,0.04); }

/* ── AI Suggestion Box ─────────────────────────────────────── */
.ai-box {
  background: rgba(139,92,246,0.06);
  border: 1px solid var(--border-purple);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  animation: fadeInUp 0.4s ease;
}
.ai-box-header {
  display: flex; align-items: center; gap: var(--s-2);
  margin-bottom: var(--s-4);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--purple-300);
}
.ai-spark { font-size: 1rem; }

/* ── Sources List ──────────────────────────────────────────── */
.sources-list { display: flex; flex-direction: column; gap: var(--s-3); }
.source-item {
  display: flex; align-items: flex-start; gap: var(--s-4);
  padding: var(--s-4) var(--s-5);
  background: var(--glass-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--r-md);
  transition: var(--t-base);
}
.source-item:hover { border-color: var(--border-gold); }
.source-icon { font-size: 1.6rem; flex-shrink: 0; }
.source-content { flex: 1; }
.source-name  { font-weight: 700; font-size: 0.92rem; margin-bottom: 2px; }
.source-desc  { font-size: 0.8rem; color: var(--text-muted); line-height: 1.6; }
.source-reason { font-size: 0.75rem; color: var(--gold-500); margin-top: 4px; }
.source-type {
  display: inline-flex; padding: 2px 9px;
  border-radius: var(--r-full);
  font-size: 0.7rem; font-weight: 600;
  background: rgba(201,160,64,0.1); border: 1px solid var(--border-gold); color: var(--gold-400);
  margin-top: var(--s-1);
}

/* ── Role Suggestion ───────────────────────────────────────── */
.role-card {
  background: rgba(139,92,246,0.06);
  border: 1px solid var(--border-purple);
  border-radius: var(--r-lg);
  padding: var(--s-6);
}
.role-header { display: flex; align-items: center; gap: var(--s-4); margin-bottom: var(--s-5); }
.role-avatar {
  width: 60px; height: 60px;
  background: linear-gradient(135deg, var(--purple-600), var(--purple-800));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; flex-shrink: 0;
}
.role-meta h3 { font-weight: 800; color: var(--purple-300); font-size: 1.05rem; }
.role-meta p  { font-size: 0.8rem; color: var(--text-muted); }
.role-specs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-3);
  margin-top: var(--s-4);
}
.role-spec {
  background: rgba(255,255,255,0.03);
  border-radius: var(--r-sm);
  padding: var(--s-3);
}
.role-spec-key  { font-size: 0.7rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 3px; }
.role-spec-val  { font-size: 0.85rem; color: var(--text-primary); }

/* ── Terminology Table ─────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--r-lg);
  border: 1px solid var(--border-light);
}
.term-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.term-table thead th {
  padding: var(--s-3) var(--s-4);
  text-align: right;
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold-500);
  background: rgba(201,160,64,0.06);
  border-bottom: 2px solid var(--border-gold);
  white-space: nowrap;
}
.term-table tbody tr { transition: var(--t-fast); }
.term-table tbody tr:hover td { background: rgba(255,255,255,0.02); }
.term-table tbody td {
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
  line-height: 1.6;
}
.term-table tbody tr:last-child td { border-bottom: none; }
.td-num    { color: var(--text-muted); font-size: 0.75rem; font-weight: 600; }
.td-orig   { font-weight: 700; color: var(--gold-300); }
.td-trans  { color: var(--purple-300); font-weight: 600; }
.td-expl   { color: var(--text-secondary); font-size: 0.78rem; }
.difficulty-pips { display: flex; gap: 3px; }
.pip {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--border-light);
}
.pip.on { background: var(--gold-500); }

/* ── Sample Translation Cards ──────────────────────────────── */
.sample-grid { display: flex; flex-direction: column; gap: var(--s-5); }
.sample-card {
  background: var(--glass-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: var(--t-base);
  animation: fadeInUp 0.35s ease;
}
.sample-card:hover { border-color: var(--border-gold); }
.sample-card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-3) var(--s-5);
  background: rgba(255,255,255,0.025);
  border-bottom: 1px solid var(--border-subtle);
}
.sample-part-label {
  font-size: 0.73rem; font-weight: 700;
  color: var(--gold-500); letter-spacing: 0.12em; text-transform: uppercase;
}
.sample-card-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.sample-panel { padding: var(--s-5); }
.sample-panel.sp-source { border-left: 1px solid var(--border-subtle); }
.sp-panel-label {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--text-muted); margin-bottom: var(--s-3);
  display: flex; align-items: center; gap: var(--s-1);
}
.sample-text {
  font-size: 0.88rem;
  line-height: 1.85;
  color: var(--text-primary);
}
.sample-text.en {
  direction: ltr;
  font-family: var(--font-en);
  font-size: 0.95rem;
  text-align: left;
}
.sample-notes {
  font-size: 0.75rem; color: var(--text-muted);
  border-top: 1px solid var(--border-subtle);
  margin-top: var(--s-3); padding-top: var(--s-3);
  font-style: italic;
}
.changes-badge {
  display: inline-flex; align-items: center; gap: var(--s-1);
  padding: 2px 9px; border-radius: var(--r-full);
  font-size: 0.7rem; font-weight: 600;
  background: rgba(16,185,129,0.1); border: 1px solid var(--border-success); color: var(--text-success);
  margin-top: var(--s-2);
}

/* Feedback Pane */
.feedback-pane {
  background: rgba(245,158,11,0.06);
  border: 1px solid rgba(245,158,11,0.22);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  margin-top: var(--s-5);
  animation: fadeInUp 0.3s ease;
}
.feedback-pane h4 { color: var(--text-warning); font-weight: 700; margin-bottom: var(--s-3); font-size: 0.9rem; }

/* ── Iterative Improvement ─────────────────────────────────── */
.improvement-steps { display: flex; flex-direction: column; gap: var(--s-4); }
.impr-step {
  background: var(--glass-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  transition: var(--t-base);
}
.impr-step.active   { border-color: var(--gold-500);   background: rgba(201,160,64,0.05); }
.impr-step.done     { border-color: var(--border-success); background: rgba(16,185,129,0.04); }
.impr-step.pending  {}
.impr-step-head {
  display: flex; align-items: center; gap: var(--s-4); margin-bottom: var(--s-3);
}
.impr-step-icon {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; flex-shrink: 0;
}
.impr-step.active  .impr-step-icon { background: linear-gradient(135deg, var(--gold-500), var(--gold-700)); }
.impr-step.done    .impr-step-icon { background: linear-gradient(135deg, #059669, #047857); }
.impr-step.pending .impr-step-icon { background: var(--bg-elevated); }
.impr-step-meta { flex: 1; }
.impr-step-title { font-weight: 700; font-size: 0.95rem; }
.impr-step-desc  { font-size: 0.8rem; color: var(--text-muted); }
.impr-step-progress {
  height: 3px;
  background: var(--bg-elevated);
  border-radius: var(--r-full);
  margin-bottom: var(--s-3);
  overflow: hidden;
}
.impr-step-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-500), var(--purple-500));
  border-radius: var(--r-full);
  transition: width 0.5s ease;
}
.translation-preview {
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: var(--s-5);
  font-family: var(--font-en);
  font-size: 0.9rem;
  line-height: 1.9;
  color: var(--text-primary);
  direction: ltr;
  text-align: left;
  max-height: 260px;
  overflow-y: auto;
  white-space: pre-wrap;
}

/* ── Export Screen ─────────────────────────────────────────── */
.export-section { display: flex; flex-direction: column; gap: var(--s-6); }
.final-preview {
  background: var(--glass-bg);
  border: 1px solid var(--border-gold);
  border-radius: var(--r-lg);
  padding: var(--s-6);
}
.final-preview-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--s-4);
}
.final-preview-head h3 {
  font-size: 1rem; font-weight: 700; color: var(--gold-400);
  display: flex; align-items: center; gap: var(--s-2);
}
.final-text {
  font-family: var(--font-en);
  font-size: 0.9rem;
  line-height: 1.95;
  color: var(--text-primary);
  direction: ltr;
  text-align: left;
  max-height: 380px;
  overflow-y: auto;
  white-space: pre-wrap;
}
.export-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s-3);
}
.export-btn {
  display: flex; flex-direction: column; align-items: center; gap: var(--s-2);
  padding: var(--s-5) var(--s-3);
  background: var(--glass-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  cursor: pointer;
  transition: var(--t-slow);
  color: var(--text-primary);
  font-family: var(--font-ar);
  font-size: 0.85rem;
  font-weight: 600;
}
.export-btn:hover { transform: translateY(-5px); box-shadow: var(--shadow-md); }
.export-btn.eb-docx:hover { border-color: #2b79d9; }
.export-btn.eb-pdf:hover  { border-color: #f43f5e; }
.export-btn.eb-csv:hover  { border-color: #10b981; }
.export-btn.eb-xml:hover  { border-color: var(--text-warning); }
.export-icon { font-size: 2.2rem; }
.export-ext  { font-size: 0.7rem; color: var(--text-muted); }

.memory-export-card {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-4);
  padding: var(--s-5) var(--s-6);
  background: rgba(139,92,246,0.06);
  border: 1px solid var(--border-purple);
  border-radius: var(--r-lg);
}
.mem-info { flex: 1; }
.mem-info h4 { font-weight: 700; color: var(--purple-300); margin-bottom: 4px; }
.mem-info p  { font-size: 0.8rem; color: var(--text-muted); }

/* ── Autopilot Processing Screen ───────────────────────────── */
.autopilot-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-8);
  position: relative;
  z-index: var(--z-base);
}
.autopilot-panel {
  width: 100%; max-width: 620px;
  text-align: center;
}
.autopilot-ring-wrap {
  position: relative;
  width: 160px; height: 160px;
  margin: 0 auto var(--s-8);
}
.autopilot-svg { transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(255,255,255,0.06); stroke-width: 8; }
.ring-fill {
  fill: none;
  stroke: url(#ring-gradient);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 427;
  stroke-dashoffset: 427;
  transition: stroke-dashoffset 0.8s ease;
}
.autopilot-ring-text {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.autopilot-percent { font-size: 2.2rem; font-weight: 900; color: var(--gold-400); }
.autopilot-percent-sign { font-size: 1rem; font-weight: 600; }
.autopilot-step-label { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

.autopilot-panel h2 { font-size: 1.8rem; font-weight: 800; margin-bottom: var(--s-2); }
.autopilot-panel .sub { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: var(--s-8); }

.autopilot-task-list { list-style: none; text-align: right; }
.autopilot-task-list li {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  font-size: 0.88rem;
  color: var(--text-muted);
  transition: var(--t-base);
}
.autopilot-task-list li.atl-active { background: rgba(201,160,64,0.07); color: var(--text-primary); }
.autopilot-task-list li.atl-done  { color: var(--text-success); }
.atl-dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
}
.atl-dot.pending { background: var(--border-light); }
.atl-dot.active  { background: var(--gold-500); animation: pulsate 1.2s infinite; }
.atl-dot.done    { background: var(--text-success); }

/* ── Dividers ──────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border-subtle); margin: var(--s-6) 0; }
.divider-label {
  display: flex; align-items: center; gap: var(--s-3);
  color: var(--text-muted); font-size: 0.8rem; margin: var(--s-5) 0;
}
.divider-label::before, .divider-label::after {
  content: ''; flex: 1; height: 1px; background: var(--border-subtle);
}

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: var(--r-full); }
::-webkit-scrollbar-thumb:hover { background: var(--gold-700); }

/* ── Animations ────────────────────────────────────────────── */
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.92) translateY(16px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulsate {
  0%,100% { box-shadow: 0 0 0 0 rgba(201,160,64,0.4); }
  50%      { box-shadow: 0 0 0 8px rgba(201,160,64,0); }
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%,60% { transform: translateX(-10px); }
  40%,80% { transform: translateX(10px); }
}

.animate-in { animation: fadeInUp 0.4s ease; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 720px) {
  .mode-grid { grid-template-columns: 1fr; }
  .sample-card-body { grid-template-columns: 1fr; }
  .sample-panel.sp-source { border-left: none; border-top: 1px solid var(--border-subtle); }
  .export-buttons { grid-template-columns: repeat(2, 1fr); }
  .step-header { grid-template-columns: auto 1fr; }
  .progress-track { display: none; }
  .step-body { padding: var(--s-6) var(--s-4); }
  .role-specs { grid-template-columns: 1fr; }
}
