/* ══════════════════════════════════════════════════════════
   AUTH GATE — Email + OTP screens
   Ported from buletina-subscriber-portal-v48.
   Shown before dashboard shell; hidden on successful verify.
   Integration point for Shreyas: replace verifyOTP() body
   with a fetch('/api/affiliate/verify-otp', { code, email })
   call. showDashboard() is the success callback.
══════════════════════════════════════════════════════════ */

/* Full-page auth wrapper — covers everything while active */
#auth-gate {
  position: fixed; inset: 0; z-index: 999;
  background: var(--surface);
  display: flex; flex-direction: column;
  overflow: hidden;
}

/* Auth topbar — minimal branding, no nav tabs */
.auth-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; height: 56px;
  background: var(--sidebar);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.auth-topbar-logo {
  font-family: 'Sora', sans-serif; font-size: 1.0625rem; font-weight: 700;
  color: #fff; letter-spacing: -0.02em; text-decoration: none;
}
.auth-topbar-tag {
  font-family: 'Sora', sans-serif; font-size: 0.6875rem; font-weight: 500;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: rgba(255,255,255,0.45);
}

/* Screen switching */
.auth-screen { display: none; }
.auth-screen.active { display: flex; flex-direction: column; align-items: center; width: 100%; }

/* Auth card */
.auth-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 40px;
  text-align: center; width: 100%; max-width: 440px;
}
.auth-icon {
  width: 52px; height: 52px; background: var(--brand-pale);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
}
.auth-title {
  font-size: 1.375rem; font-weight: 700; color: var(--text);
  letter-spacing: -0.02em; margin-bottom: 8px;
  font-family: 'Sora', sans-serif;
}
.auth-sub {
  font-size: 0.875rem; color: var(--text-faint); font-weight: 300;
  margin-bottom: 28px; line-height: 1.6;
  font-family: 'Sora', sans-serif;
}
.auth-input {
  width: 100%; box-sizing: border-box;
  padding: 11px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 1rem;
  font-family: 'Sora', sans-serif; color: var(--text);
  background: var(--white); margin-bottom: 12px;
  outline: none; transition: border-color 0.15s;
  text-align: center;
}
.auth-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(29,158,117,0.12); }
.auth-btn {
  width: 100%; font-family: 'Sora', sans-serif; font-size: 0.9375rem;
  font-weight: 600; padding: 12px; border-radius: var(--radius-sm);
  border: none; cursor: pointer; transition: all 0.15s;
  background: var(--brand); color: #fff;
}
.auth-btn:hover { background: var(--brand-mid); }
.auth-privacy {
  font-size: 0.8125rem; color: var(--text-faint);
  margin-top: 16px; line-height: 1.5; font-family: 'Sora', sans-serif;
}
.auth-privacy a { color: var(--brand); }

/* OTP boxes */
.otp-wrap { position: relative; margin: 20px auto 8px; width: fit-content; }
.otp-boxes { display: flex; gap: 8px; pointer-events: none; }
.otp-box {
  width: 44px; height: 52px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); background: var(--white);
  transition: border-color 0.15s, background 0.1s;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Sora', sans-serif; font-size: 1.375rem; font-weight: 700; color: var(--text);
}
.otp-box.filled { border-color: var(--brand); background: var(--brand-pale); }
.otp-box.active { border-color: var(--brand); border-width: 2px; box-shadow: 0 0 0 3px rgba(29,158,117,0.12); }
.otp-box.error  { border-color: #e74c3c; background: #fdf0ef; }
.otp-input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: text; font-size: 16px; border: none; background: transparent;
}
.otp-hint  { font-size: 0.75rem; color: var(--text-faint); text-align: center; margin-top: 4px; font-weight: 300; font-family: 'Sora', sans-serif; }
.otp-error { font-size: 0.75rem; color: #e74c3c; text-align: center; margin-top: 4px; font-weight: 500; font-family: 'Sora', sans-serif; }
.otp-resend-btn {
  font-family: 'Sora', sans-serif; font-size: 0.8125rem; font-weight: 600;
  color: var(--brand); background: none; border: none; cursor: pointer;
  padding: 0; text-decoration: underline; text-underline-offset: 3px; transition: opacity 0.15s;
}
.otp-resend-btn:disabled { opacity: 0.4; cursor: not-allowed; text-decoration: none; }
.otp-back-link { font-size: 0.8125rem; color: var(--brand); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; font-family: 'Sora', sans-serif; }

/* Dashboard shell — hidden until auth passes */
#dashboard-shell { display: none; }
#dashboard-shell.revealed { display: block; }

@media (max-width: 480px) {
  .auth-card { padding: 28px 20px; }
  .otp-box   { width: 38px; height: 46px; font-size: 1.125rem; }
  .otp-boxes { gap: 6px; }
}

/* ── Dark mode ── */
[data-theme="dark"] {
  --brand:        #2dbd8a;
  --brand-mid:    #1D9E75;
  --brand-light:  #1a3028;
  --brand-pale:   #0f1f18;
  --text:         #f0f0f0;
  --text-muted:   #a8a8a8;
  --text-faint:   #707070;
  --border:       #2a2a2a;
  --surface:      #0a0a0a;
  --surface-2:    #111111;
  --white:        #1a1a1a;
  --gold:         #f4a261;
  --gold-pale:    #1f1508;
  --sidebar:      #000000;
}

/* Dark mode topbar border */
[data-theme="dark"] .topbar {
  border-bottom-color: rgba(255,255,255,0.06);
}

/* Dark mode auth gate */
[data-theme="dark"] #auth-gate {
  background: var(--surface);
}

/* Dark mode footer */
[data-theme="dark"] .site-footer {
  background: var(--surface-2);
  border-top-color: var(--border);
}

/* Dark mode modals */
[data-theme="dark"] .modal-box {
  background: var(--white);
  border: 1px solid var(--border);
}

/* Dark mode form inputs */
[data-theme="dark"] .form-input,
[data-theme="dark"] .auth-input {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

/* Dark mode table rows */
[data-theme="dark"] .ref-table tr.expandable:nth-child(even) td,
[data-theme="dark"] .earn-modal-table tr:nth-child(even) td {
  background: var(--surface-2);
}
/* ── Dark mode: hardcoded #fff elements ── */
[data-theme="dark"] .bounty-available-card,
[data-theme="dark"] .active-bounty-card,
[data-theme="dark"] .bounty-history-card {
  background: var(--white);
  border-color: var(--border);
}

[data-theme="dark"] .bounty-tab-btn.active {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

[data-theme="dark"] .bounty-deadline-pill.amber {
  background: #2a1800;
  color: #f4a261;
}

[data-theme="dark"] .ref-table tr.expandable:nth-child(odd) td {
  background: var(--white);
}

[data-theme="dark"] .ref-table tr.expandable:nth-child(even) td {
  background: var(--surface-2);
}

[data-theme="dark"] .ref-table th {
  background: var(--surface-2);
  color: var(--text-muted);
  border-bottom-color: var(--border);
}

[data-theme="dark"] .ref-table td {
  border-bottom-color: var(--border);
  color: var(--text);
}

[data-theme="dark"] .detail-inner {
  background: var(--surface-2);
}

[data-theme="dark"] .payout-table-wrap {
  background: var(--white);
  border-color: var(--border);
}

[data-theme="dark"] .payout-table th {
  background: var(--surface-2);
  color: var(--text-muted);
  border-bottom-color: var(--border);
}

[data-theme="dark"] .payout-table td {
  border-bottom-color: var(--border);
  color: var(--text);
}

[data-theme="dark"] .earn-card {
  background: var(--white);
  border-color: var(--border);
}

[data-theme="dark"] .earn-card.featured {
  background: var(--brand-mid);
}

[data-theme="dark"] .section-card,
[data-theme="dark"] .card {
  background: var(--white);
  border-color: var(--border);
}

[data-theme="dark"] .upload-dropzone {
  background: var(--surface-2);
  border-color: var(--border);
}

[data-theme="dark"] .tab-panel-header,
[data-theme="dark"] .page-header {
  background: var(--surface);
}

[data-theme="dark"] .acct-tab-btn {
  color: var(--text-faint);
}
[data-theme="dark"] .acct-tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--text);
}

[data-theme="dark"] .lb-row {
  border-bottom-color: var(--border);
}
[data-theme="dark"] .lb-row:hover {
  background: var(--surface-2);
}

[data-theme="dark"] .swipe-card {
  background: var(--white);
  border-color: var(--border);
}

[data-theme="dark"] .swipe-filter-btn {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text-faint);
}
[data-theme="dark"] .swipe-filter-btn.active {
  background: var(--brand-pale);
  border-color: var(--brand);
  color: var(--brand);
}

[data-theme="dark"] .calc-slider-card,
[data-theme="dark"] .calc-results-card,
[data-theme="dark"] .calc-breakdown,
[data-theme="dark"] .calc-crt {
  background: var(--white);
  border-color: var(--border);
}

[data-theme="dark"] .calc-plan-btn {
  background: var(--surface-2);
  border-color: var(--border);
}
[data-theme="dark"] .calc-plan-btn.active {
  background: var(--brand-pale);
  border-color: var(--brand);
}


/* ── Dark mode toggle button ── */
#dark-mode-btn {
  background: none; border: none; cursor: pointer;
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.6); transition: color 0.15s, background 0.15s;
  flex-shrink: 0; margin-right: 8px;
  font-size: 1rem; line-height: 1;
}
#dark-mode-btn:hover {
  color: #fff; background: rgba(255,255,255,0.1);
}

/* ── AUTH TWO-COLUMN LAYOUT (desktop) ── */
.auth-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  align-self: stretch;
}

/* ensure the gate background fills edge-to-edge even with centred body */
#auth-gate {
  background: var(--surface);
}
#auth-gate::before {
  content: '';
  position: fixed;
  inset: 56px 0 0 0;
  background: #0D1B14;
  width: 32%;
  max-width: 440px;
  min-width: 320px;
  z-index: -1;
  pointer-events: none;
}
.auth-left {
  display: none; /* hidden on mobile */
  width: 32%;
  max-width: 440px;
  min-width: 320px;
  flex-shrink: 0;
  background: #0D1B14;
  padding: 36px 40px 40px;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.auth-left::before {
  content: '';
  position: absolute;
  top: -80px; right: -80px;
  width: 320px; height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(29,158,117,0.18) 0%, transparent 70%);
  pointer-events: none;
}
.auth-left::after {
  content: '';
  position: absolute;
  bottom: -60px; left: -60px;
  width: 240px; height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(29,158,117,0.10) 0%, transparent 70%);
  pointer-events: none;
}
.auth-left-top { position: relative; z-index: 1; }
.auth-left-headline {
  font-family: 'Sora', sans-serif;
  font-size: 1.75rem; font-weight: 700;
  color: #fff; line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 24px;
}
.auth-left-headline span { color: #1D9E75; }
.auth-left-badge {
  background: rgba(29,158,117,0.12);
  border: 1px solid rgba(29,158,117,0.3);
  border-radius: 8px;
  padding: 18px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.auth-left-badge-icon {
  width: 18px; height: 18px;
  color: #1D9E75;
  flex-shrink: 0;
  margin-top: 2px;
}
.auth-left-badge-text {
  font-family: 'Sora', sans-serif;
  font-size: 0.8125rem;
  color: rgba(255,255,255,0.85);
  line-height: 1.6;
}
.auth-left-badge-text strong {
  color: #fff;
  font-weight: 600;
  display: block;
  margin-bottom: 3px;
}
.auth-left-badge-text em {
  font-style: normal;
  color: #1D9E75;
  font-weight: 600;
  display: block;
  margin-top: 4px;
}
.auth-left-bottom {
  position: relative; z-index: 1;
}
.auth-left-tagline {
  font-family: 'Sora', sans-serif;
  font-size: 0.6875rem;
  color: rgba(255,255,255,0.3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.auth-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  background: var(--surface);
  overflow-y: auto;
}

@media (min-width: 800px) {
  .auth-left { display: flex; }
}