/* ==========================================================================
   ThreadToSale — Design System
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Outfit:wght@500;600;700;800&display=swap');

:root {
  --bg: #09090c;
  --bg-2: #0e0e13;
  --surface: #131319;
  --surface-2: #1a1a22;
  --surface-3: #22222c;
  --border: rgba(255, 255, 255, 0.07);
  --border-2: rgba(255, 255, 255, 0.12);

  --text: #f5f5f7;
  --text-2: #b4b4bf;
  --muted: #7c7c8a;

  --brand: #f26419;
  --brand-2: #ff8a3d;
  --brand-3: #ffb067;
  --brand-glow: rgba(242, 100, 25, 0.35);
  --brand-soft: rgba(242, 100, 25, 0.12);
  --grad: linear-gradient(135deg, #ff8a3d 0%, #f26419 50%, #e2440b 100%);
  --grad-text: linear-gradient(120deg, #ffd0a1 0%, #ff8a3d 40%, #f26419 100%);

  --green: #22c55e;
  --green-soft: rgba(34, 197, 94, 0.14);
  --yellow: #eab308;
  --yellow-soft: rgba(234, 179, 8, 0.14);
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, 0.12);
  --blue: #60a5fa;

  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.6);
  --shadow-brand: 0 10px 30px -8px var(--brand-glow);

  /* Form fields: resting, hover and focused backgrounds per theme. */
  --field-bg: var(--bg-2);
  --field-bg-hover: #121218;
  --field-bg-focus: #0c0c11;
  --placeholder: #6b6b78;

  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --font-display: 'Outfit', 'Inter', system-ui, sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Light Theme Variables */
html[data-theme="light"], body[data-theme="light"] {
  --bg: #f8fafc;
  --bg-2: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #e2e8f0;
  --border: rgba(15, 23, 42, 0.09);
  --border-2: rgba(15, 23, 42, 0.16);

  --text: #0f172a;
  --text-2: #475569;
  --muted: #64748b;

  --shadow: 0 10px 30px -10px rgba(15, 23, 42, 0.12);
  --shadow-brand: 0 10px 30px -8px rgba(242, 100, 25, 0.25);

  --field-bg: #f8fafc;
  --field-bg-hover: #ffffff;
  --field-bg-focus: #ffffff;
  --placeholder: #94a3b8;
}

/* RTL layout helpers */
[dir="rtl"] {
  direction: rtl;
  text-align: right;
}
[dir="rtl"] .lang-menu-dropdown,
[dir="rtl"] .theme-menu-dropdown,
[dir="rtl"] .account-dropdown {
  right: auto;
  left: 0;
}
[dir="rtl"] .lang-item {
  text-align: right;
}
[dir="rtl"] .topbar-actions {
  flex-direction: row-reverse;
}
[dir="rtl"] .sidebar {
  border-right: 0;
  border-left: 1px solid var(--border);
}

/* ==========================================================================
   Header Language & Theme Controls (Matching Exact Design Specification)
   ========================================================================== */
.header-i18n-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  position: relative;
  z-index: 90;
}

.lang-selector-wrap,
.theme-selector-wrap {
  position: relative;
  display: inline-flex;
}

.lang-trigger-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.98rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
}
.lang-trigger-btn:hover {
  background: var(--surface-3);
  border-color: rgba(242, 100, 25, 0.5);
  transform: translateY(-1px);
}
.lang-trigger-flag,
.lang-current-flag {
  font-size: 1.3rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}
.lang-trigger-code,
.lang-current-code {
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: 0.92rem;
  text-transform: uppercase;
}

.theme-trigger-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  color: var(--text);
  font-size: 1.25rem;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
}
.theme-trigger-btn:hover {
  background: var(--surface-3);
  border-color: rgba(242, 100, 25, 0.5);
  transform: translateY(-1px);
}
.theme-current-icon {
  display: inline-block;
  line-height: 1;
  font-size: 1.25rem;
}

.lang-menu-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 230px;
  background: #0e1424;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 6px;
  box-shadow: 0 20px 48px -6px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.06);
  z-index: 1000;
  backdrop-filter: blur(24px);
  animation: dropFadeIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
[data-theme="light"] .lang-menu-dropdown {
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.12);
  box-shadow: 0 20px 48px -6px rgba(15, 23, 42, 0.16), 0 0 0 1px rgba(15, 23, 42, 0.04);
}

.lang-menu-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 420px;
  overflow-y: auto;
}

.lang-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.94rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  text-align: left;
}
.lang-item:hover {
  background: rgba(255, 255, 255, 0.08);
}
[data-theme="light"] .lang-item:hover {
  background: rgba(15, 23, 42, 0.06);
}
.lang-item.active {
  background: rgba(255, 255, 255, 0.05);
}
[data-theme="light"] .lang-item.active {
  background: rgba(15, 23, 42, 0.04);
}

.lang-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.lang-item-flag {
  font-size: 1.15rem;
  line-height: 1;
}
.lang-item-name {
  color: var(--text);
  font-weight: 500;
}
.lang-item-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.lang-item-code {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.lang-check {
  color: #22c55e;
  font-weight: 800;
  font-size: 1.05rem;
  line-height: 1;
}

.theme-menu-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 170px;
  background: #0e1424;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 6px;
  box-shadow: 0 20px 48px -6px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.06);
  z-index: 1000;
  backdrop-filter: blur(24px);
  animation: dropFadeIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
[data-theme="light"] .theme-menu-dropdown {
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.12);
  box-shadow: 0 20px 48px -6px rgba(15, 23, 42, 0.16);
}

.theme-menu-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.theme-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
}
.theme-item:hover {
  background: rgba(255, 255, 255, 0.08);
}
[data-theme="light"] .theme-item:hover {
  background: rgba(15, 23, 42, 0.06);
}
.theme-check {
  color: #22c55e;
  font-weight: 800;
  font-size: 1rem;
}

@keyframes dropFadeIn {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}


[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  min-height: 100vh;
  min-height: 100dvh;
}
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.15; margin: 0; letter-spacing: -0.02em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button, a, input, select, textarea, .toggle, .chip, [role="button"] {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
img, svg { display: block; max-width: 100%; }
::selection { background: var(--brand); color: #fff; }
/* Safari paints its own dark highlight over buttons in a selection and
   ignores ::selection there. selection.js stops selections from starting on
   buttons and marks any caught in a wider one (.in-selection). */
.pill, .tag, .chip { -webkit-user-select: none; user-select: none; }
/* Safari can still paint a highlight over buttons; keep their text white on it. */
/* Light blue with white text wherever a highlight lands on a button. */
button::selection, button *::selection, .btn::selection, .btn *::selection { background: #7aa7f5; color: #fff; -webkit-text-fill-color: #fff; }
button, .btn, [role="button"] { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.in-selection, .in-selection * { background: #7aa7f5 !important; border-color: #7aa7f5 !important; color: #fff !important; -webkit-text-fill-color: #fff !important; }
.in-selection svg, .in-selection svg * { stroke: #fff !important; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; border: 2px solid var(--bg); }

.grad-text {
  background: var(--grad-text);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- Logo ---------- */
.logo { display: inline-flex; align-items: center; gap: 12px; font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; letter-spacing: -0.02em; flex-shrink: 0; }
.logo img { height: 44px; width: auto; max-height: 48px; filter: drop-shadow(0 6px 16px var(--brand-glow)); transition: transform 0.2s var(--ease); }
.logo:hover img { transform: scale(1.02); }
.logo img.logo-icon { width: 42px; height: 42px; }
.logo img.logo-full { height: 44px; width: auto; max-width: 230px; }
.logo-light-theme { display: none; }
[data-theme="light"] .logo-dark-theme { display: none; }
[data-theme="light"] .logo-light-theme { display: block; }
.logo b { color: var(--brand-2); font-weight: 700; }

/* ---------- Buttons ---------- */
.btn {
  --h: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--h); padding: 0 18px;
  border-radius: 12px; border: 1px solid transparent;
  font-weight: 600; font-size: 0.94rem; white-space: nowrap;
  cursor: pointer;
  transition: transform 0.15s var(--ease), box-shadow 0.25s var(--ease), background 0.2s, border-color 0.2s, opacity 0.2s;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary { background: var(--grad); color: #fff; box-shadow: var(--shadow-brand), inset 0 1px 0 rgba(255,255,255,.25); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 14px 36px -8px rgba(242, 100, 25, 0.6), inset 0 1px 0 rgba(255,255,255,.3); transform: translateY(-1px); }
.btn-secondary { background: var(--surface-2); border-color: var(--border-2); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-3); border-color: rgba(255,255,255,.2); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--red-soft); color: #fca5a5; border-color: rgba(239,68,68,.3); }
.btn-danger:hover:not(:disabled) { background: rgba(239,68,68,.2); }
.btn-white { background: #fff; color: #c2410c; }
.btn-white:hover { box-shadow: 0 10px 30px -10px rgba(255,255,255,.5); transform: translateY(-1px); }
.btn-sm { --h: 34px; padding: 0 12px; font-size: 0.85rem; border-radius: 10px; }
.btn-lg { --h: 54px; padding: 0 28px; font-size: 1.02rem; border-radius: 14px; }
.btn-block { width: 100%; }
.btn-icon { width: var(--h); padding: 0; }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.3); border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 8px; }
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.label { font-weight: 600; font-size: 0.95rem; }
.label .req { color: var(--brand-2); }
.hint { font-size: 0.8rem; color: var(--muted); }
.counter { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; transition: color 0.2s; }
.counter.near-limit { color: var(--yellow); font-weight: 600; }
.counter.at-limit { color: var(--red); font-weight: 600; }
.input, .textarea, .select {
  width: 100%;
  color: var(--text);
  background: var(--field-bg);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  padding: 13px 16px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.input::placeholder, .textarea::placeholder { color: var(--placeholder); }
.input:hover, .textarea:hover, .select:hover { background: var(--field-bg-hover); }
.input:focus, .textarea:focus, .select:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); background: var(--field-bg-focus); }
.textarea { resize: vertical; min-height: 110px; line-height: 1.55; }
.select {
  appearance: none; cursor: pointer; padding-right: 42px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23b4b4bf' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 16px center;
}
.select option { background: var(--surface); }

/* Segmented control */
.segmented { display: inline-flex; padding: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; gap: 4px; }
.segmented button {
  border: 0; background: transparent; padding: 9px 18px; border-radius: 10px;
  font-weight: 600; font-size: 0.92rem; color: var(--text-2); cursor: pointer; transition: all 0.2s var(--ease);
}
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--grad); color: #fff; box-shadow: var(--shadow-brand); }

/* Toggle */
.toggle { position: relative; width: 46px; height: 26px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle span { position: absolute; inset: 0; background: var(--surface-3); border-radius: 30px; cursor: pointer; transition: 0.25s var(--ease); border: 1px solid var(--border-2); }
.toggle span::before { content: ''; position: absolute; width: 20px; height: 20px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: 0.25s var(--ease); box-shadow: 0 2px 6px rgba(0,0,0,.4); }
.toggle input:checked + span { background: var(--grad); border-color: transparent; }
.toggle input:checked + span::before { transform: translateX(20px); }

/* Range */
input[type='range'] { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 6px; background: var(--surface-3); outline: none; }
input[type='range']::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 4px solid var(--brand); cursor: pointer; box-shadow: 0 0 0 4px var(--brand-soft); }
input[type='range']::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 4px solid var(--brand); cursor: pointer; }

/* Chips */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px;
  background: var(--surface-3); border: 1px solid var(--border);
  font-size: 0.8rem; font-weight: 500; color: var(--text-2); white-space: nowrap;
}
.chip button { border: 0; background: none; padding: 0; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.chip button:hover { color: var(--red); }
.chip-brand { background: var(--brand-soft); border-color: rgba(242,100,25,.3); color: var(--brand-3); }

/* Score badge */
.score {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 9px; font-weight: 700; font-size: 0.85rem; font-variant-numeric: tabular-nums;
}
.score svg { width: 13px; height: 13px; }
.score.hi { background: var(--green); color: #052e13; }
.score.mid { background: var(--yellow); color: #3a2a00; }
.score.lo { background: var(--surface-3); color: var(--text-2); }

/* Card */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }

/* Toasts */
.toasts { position: fixed; z-index: 1000; bottom: 24px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 10px; align-items: center; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px;
  /* Toasts stay dark in both themes, so their text colour is fixed too
     (var(--text) is near-black in light mode). */
  padding: 12px 18px; border-radius: 14px; background: rgba(28, 28, 36, 0.92); color: #f5f5f7; backdrop-filter: blur(14px);
  border: 1px solid var(--border-2); box-shadow: var(--shadow); font-size: 0.92rem; font-weight: 500;
  animation: toastIn 0.35s var(--ease);
}
.toast.out { animation: toastOut 0.25s var(--ease) forwards; }
.toast .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); }
.toast.error .dot { background: var(--red); box-shadow: 0 0 10px var(--red); }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(0.97); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px) scale(0.97); } }

/* Utilities */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.pulse-dot { position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex: none; }
.pulse-dot::after { content: ''; position: absolute; inset: 0; border-radius: 50%; background: var(--green); animation: ping 1.8s cubic-bezier(0, 0, 0.2, 1) infinite; }
.pulse-dot.brand, .pulse-dot.brand::after { background: var(--brand-2); }
.pulse-dot.off, .pulse-dot.off::after { background: var(--muted); animation: none; }
@keyframes ping { 75%, 100% { transform: scale(2.6); opacity: 0; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }


/* Header Nav Actions */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.nav-btn-signin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 20px;
  font-size: 0.98rem;
  font-weight: 600;
  border-radius: 12px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}
.nav-btn-signin:hover {
  background: var(--surface-3);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
  transform: translateY(-1px);
}
[data-theme="light"] .nav-btn-signin {
  background: rgba(15, 23, 42, 0.05);
  border-color: rgba(15, 23, 42, 0.12);
  color: #0f172a;
}
[data-theme="light"] .nav-btn-signin:hover {
  background: rgba(15, 23, 42, 0.09);
  border-color: rgba(15, 23, 42, 0.22);
  color: #000;
}

.nav-btn-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 24px;
  font-size: 1rem;
  font-weight: 700;
  border-radius: 12px;
  background: var(--grad);
  color: #fff;
  white-space: nowrap;
  box-shadow: 0 4px 18px rgba(242, 100, 25, 0.45);
  border: none;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}
.nav-btn-cta:hover {
  box-shadow: 0 8px 28px rgba(242, 100, 25, 0.65);
  transform: translateY(-1px);
  color: #fff;
}
