/* =============================================
   auth-popup.css  —  SpeedScan
   ============================================= */

/* ── Backdrop ── */
.ap-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  z-index: 900;
}
.ap-backdrop.open { display: block; animation: apFadeIn 0.22s ease; }

/* ── Modal — positioned in upper-center ── */
.ap-modal {
  display: none; position: fixed;
  inset: 0; z-index: 901;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 16px 16px;
  overflow-y: auto;
}
.ap-modal.open { display: flex; }

.ap-modal-inner {
  width: 100%; max-width: 420px;
  border-radius: 20px;
  display: flex; flex-direction: column; gap: 16px;
  animation: apSlideUp 0.26s cubic-bezier(.4,0,.2,1);

  /* dark theme */
  background: #0f1e3a;
  border: 1px solid rgba(148,163,184,0.14);
  box-shadow: 0 32px 80px rgba(0,0,0,0.55), 0 8px 24px rgba(0,0,0,0.3),
              inset 0 1px 0 rgba(255,255,255,0.06);
  padding: 24px 22px 22px;
}

:root[data-theme="light"] .ap-modal-inner {
  background: #ffffff;
  border-color: rgba(15,23,42,0.10);
  box-shadow: 0 24px 64px rgba(15,23,42,0.14), 0 6px 20px rgba(15,23,42,0.08);
}

@keyframes apFadeIn  { from { opacity:0 } to { opacity:1 } }
@keyframes apSlideUp { from { opacity:0; transform:translateY(20px) } to { opacity:1; transform:translateY(0) } }

/* ── Header ── */
.ap-header {
  display: flex; align-items: center; gap: 10px;
}
/* X close — rightmost in RTL (visually left side) */
.ap-close {
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none;
  color: var(--muted, #64748b); cursor: pointer; flex-shrink: 0;
  margin-left: auto;
  transition: background 0.15s, color 0.15s;
  order: 0;
}
.ap-close:hover { background: rgba(148,163,184,0.1); color: var(--text, #f1f5f9); }
/* Back arrow — leftmost in RTL (visually right side) */
.ap-back-btn {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none;
  color: var(--muted, #64748b); cursor: pointer; flex-shrink: 0;
  order: 99;
  transition: background 0.15s, color 0.15s;
}
.ap-back-btn:hover { background: rgba(148,163,184,0.1); color: var(--text, #f1f5f9); }
.ap-logo { border-radius: 9px; flex-shrink: 0; order: 1;}
.ap-header-text { flex: 1; min-width: 0; order: 2;}
.ap-title    { font-size: 14px; font-weight: 800; color: var(--text, #f1f5f9); letter-spacing: -0.2px; }
.ap-subtitle { font-size: 11px; color: var(--muted, #64748b); margin-top: 1px; }

/* ── Password fields side by side ── */
.ap-pw-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Register / Login inner sections ── */
#apRegisterSection,
#apLoginSection {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── Extra spacing before continue btn ── */
#apPwNextBtn { margin-top: 10px; }

/* ── Progress bar ── */
.ap-progress { }
.ap-progress-track {
  height: 3px; border-radius: 2px;
  background: rgba(148,163,184,0.12);
  overflow: hidden;
}
.ap-progress-fill {
  height: 100%; border-radius: 2px;
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  transition: width 0.4s cubic-bezier(.4,0,.2,1);
}

/* ── Alert ── */
.ap-alert {
  padding: 10px 12px; border-radius: 10px;
  font-size: 12px; font-weight: 600; border: 1px solid;
  line-height: 1.6; animation: apFadeIn 0.2s ease;
}
.ap-alert.error   { color: #ef4444; background: rgba(239,68,68,0.08);  border-color: rgba(239,68,68,0.2); }
.ap-alert.success { color: #22c55e; background: rgba(34,197,94,0.08);  border-color: rgba(34,197,94,0.2); }
.ap-alert.warning { color: #f59e0b; background: rgba(245,158,11,0.08); border-color: rgba(245,158,11,0.2); }

/* ── Step ── */
.ap-step { display: flex; flex-direction: column; gap: 14px; }

/* ── Terms ── */
.ap-terms {
  font-size: 11px; color: var(--muted, #64748b);
  line-height: 1.7; text-align: center;
}
.ap-terms-link { color: #60a5fa; text-decoration: none; }
.ap-terms-link:hover { text-decoration: underline; }

/* ── Field ── */
.ap-field { display: flex; flex-direction: column; gap: 5px; }
.ap-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ap-label { font-size: 12px; font-weight: 700; color: var(--text, #e2e8f0); }
.ap-label-row { display: flex; align-items: center; justify-content: space-between; }
.ap-optional { font-weight: 400; color: var(--muted, #64748b); }
.ap-required { color: #ef4444; margin-right: 2px; }
.ap-field-hint { font-size: 11px; color: var(--muted, #64748b); line-height: 1.6; }
.ap-section-title { font-size: 15px; font-weight: 800; color: var(--text, #f1f5f9); margin: 0; }

/* ── Input ── */
.ap-input-wrap { position: relative; display: flex; align-items: center; }
.ap-icon {
  position: absolute; right: 11px;
  color: var(--muted, #64748b); pointer-events: none; z-index: 1;
  transition: color 0.15s;
}
.ap-input {
  width: 100%; height: 42px;
  padding: 0 36px 0 36px;
  border-radius: 10px;
  border: 1.5px solid rgba(148,163,184,0.18);
  background: rgba(15,23,42,0.6);
  color: var(--text, #f1f5f9);
  font-family: inherit; font-size: 13px;
  direction: ltr; text-align: right;
  outline: none; transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}
.ap-input--noicon { padding: 0 12px; }
.ap-input::placeholder { color: var(--muted, #64748b); opacity: 0.7; }
.ap-input:focus {
  border-color: #3b82f6;
  background: rgba(59,130,246,0.06);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.16);
}
.ap-input-wrap:focus-within .ap-icon { color: #60a5fa; }

:root[data-theme="light"] .ap-input {
  background: rgba(255,255,255,0.9);
  border-color: rgba(15,23,42,0.14);
  color: #0f172a;
}
:root[data-theme="light"] .ap-input:focus {
  background: #fff;
}

.ap-eye {
  position: absolute; left: 9px;
  width: 28px; height: 28px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none;
  color: var(--muted, #64748b); cursor: pointer; z-index: 3;
  transition: color 0.15s, background 0.15s;
}
.ap-eye:hover { color: #60a5fa; background: rgba(96,165,250,0.1); }

/* ── Password strength ── */
.ap-pw-strength { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.ap-pw-bar { height: 4px; border-radius: 3px; background: rgba(148,163,184,0.12); overflow: hidden; }

/* ── Email chip ── */
.ap-email-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 11px;
  background: rgba(59,130,246,0.08);
  border: 1px solid rgba(59,130,246,0.2);
  border-radius: 9px; font-size: 12px;
  color: #93c5fd;
}
.ap-chip-change {
  margin-right: auto;
  font-size: 11px; font-weight: 700;
  color: #60a5fa;
  background: none; border: none;
  cursor: pointer; padding: 0;
  transition: color 0.15s;
}
.ap-chip-change:hover { color: #93c5fd; }
:root[data-theme="light"] .ap-email-chip {
  background: rgba(59,130,246,0.06);
  border-color: rgba(59,130,246,0.2);
  color: #2563eb;
}
:root[data-theme="light"] .ap-chip-change { color: #2563eb; }

/* ── Date selects ── */
.ap-date-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

.ap-custom-select { position: relative; }

.ap-select-btn {
  width: 100%; height: 42px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1.5px solid rgba(148,163,184,0.18);
  background: rgba(15,23,42,0.6);
  color: var(--text, #f1f5f9);
  font-family: inherit; font-size: 12px; font-weight: 500;
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; transition: border-color 0.18s, box-shadow 0.18s;
  outline: none;
}
.ap-select-btn:hover, .ap-select-btn.open {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.14);
}
:root[data-theme="light"] .ap-select-btn {
  background: rgba(255,255,255,0.9);
  border-color: rgba(15,23,42,0.14);
  color: #0f172a;
}

.ap-select-dropdown {
  display: none;
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: #1e293b;
  border: 1px solid rgba(148,163,184,0.16);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.4);
  max-height: 200px; overflow-y: auto;
  z-index: 999;
  scrollbar-width: thin;
  scrollbar-color: rgba(148,163,184,0.2) transparent;
}
.ap-select-dropdown.open { display: block; animation: apFadeIn 0.15s ease; }

:root[data-theme="light"] .ap-select-dropdown {
  background: #ffffff;
  border-color: rgba(15,23,42,0.1);
  box-shadow: 0 12px 32px rgba(15,23,42,0.12);
}

.ap-select-option {
  padding: 9px 12px; font-size: 12px; font-weight: 500;
  color: var(--text, #e2e8f0); cursor: pointer;
  transition: background 0.12s;
  border-radius: 6px; margin: 2px 4px;
}
.ap-select-option:hover { background: rgba(59,130,246,0.12); color: #93c5fd; }
.ap-select-option.selected { background: rgba(59,130,246,0.16); color: #60a5fa; font-weight: 700; }
:root[data-theme="light"] .ap-select-option { color: #0f172a; }
:root[data-theme="light"] .ap-select-option:hover { background: rgba(59,130,246,0.08); color: #2563eb; }

/* ── Gender ── */
.ap-gender-row { display: flex; flex-wrap: wrap; gap: 7px; }
.ap-gender-btn {
  padding: 7px 14px; border-radius: 20px;
  border: 1.5px solid rgba(148,163,184,0.18);
  background: transparent;
  color: var(--muted, #94a3b8);
  font-family: inherit; font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all 0.18s;
}
.ap-gender-btn:hover {
  border-color: #3b82f6; color: #60a5fa;
  background: rgba(59,130,246,0.08);
}
.ap-gender-btn.selected {
  border-color: #3b82f6; color: #fff;
  background: #3b82f6;
}
:root[data-theme="light"] .ap-gender-btn { color: #64748b; border-color: rgba(15,23,42,0.14); }
:root[data-theme="light"] .ap-gender-btn.selected { color: #fff; }

/* ── Consent ── */
.ap-consent-block { display: flex; flex-direction: column; gap: 10px; }
.ap-consent-note { font-size: 10px; color: var(--muted, #475569); line-height: 1.6; }

/* ── Checkbox ── */
.ap-check-label {
  display: flex; align-items: flex-start; gap: 9px;
  font-size: 13px; color: var(--muted, #94a3b8);
  cursor: pointer; user-select: none; line-height: 1.5;
}
.ap-check-label--sm { font-size: 11px; }
.ap-check-wrap {
  position: relative !important;
  width: 17px; height: 17px;
  flex-shrink: 0; margin-top: 1px;
}
.ap-check {
  position: absolute !important; inset: 0;
  width: 17px !important; height: 17px !important;
  margin: 0 !important;
  opacity: 0 !important;
  cursor: pointer !important;
  pointer-events: auto !important;
  z-index: 5 !important;
  appearance: auto;
}
.ap-check-box {
  position: relative;
  width: 17px; height: 17px; border-radius: 5px;
  border: 1.5px solid rgba(148,163,184,0.25);
  background: rgba(15,23,42,0.4);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  pointer-events: none !important;
}
.ap-check:checked + .ap-check-box,
.ap-check-box.is-checked {
  background: #3b82f6 !important;
  border-color: #3b82f6 !important;
}
.ap-check:checked + .ap-check-box::after,
.ap-check-box.is-checked::after {
  content: ""; width: 9px; height: 5px;
  border-left: 2px solid #fff !important; border-bottom: 2px solid #fff !important;
  border-top: none !important; border-right: none !important;
  transform: rotate(-45deg) translate(1px,-1px); display: block !important;
  background: transparent !important;
}
:root[data-theme="light"] .ap-check-box { background: rgba(255,255,255,0.9); border-color: rgba(15,23,42,0.2); }

/* ── Button ── */
.ap-btn {
  width: 100%; height: 44px; border-radius: 11px; border: none;
  cursor: pointer; font-family: inherit; font-size: 14px; font-weight: 800; color: #fff;
  background: linear-gradient(90deg, #2563eb, #3b82f6);
  box-shadow: 0 8px 20px rgba(59,130,246,0.28);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}
.ap-btn:hover { transform: translateY(-1px); box-shadow: 0 12px 28px rgba(59,130,246,0.36); }
.ap-btn:active { transform: none; }
.ap-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.ap-btn--outline {
  background: transparent; border: 1.5px solid rgba(148,163,184,0.2);
  color: var(--text, #e2e8f0); box-shadow: none;
}
.ap-btn--outline:hover { border-color: #3b82f6; box-shadow: none; }
:root[data-theme="light"] .ap-btn--outline { color: #0f172a; border-color: rgba(15,23,42,0.15); }

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

/* ── Divider ── */
.ap-divider { position: relative; text-align: center; }
.ap-divider::before {
  content: ""; position: absolute; inset: 50% 0 auto;
  height: 1px; background: rgba(148,163,184,0.12);
}
.ap-divider span {
  position: relative; padding: 0 12px;
  font-size: 11px; color: var(--muted, #64748b);
  background: #0f1e3a;
}
:root[data-theme="light"] .ap-divider span { background: #fff; }

/* ── Social buttons ── */
.ap-social-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ap-social-row form {
  margin: 0;
  width: 100%;
}
.ap-social-btn {
  width: 100%;
  height: 42px; border-radius: 11px;
  border: 1.5px solid rgba(148,163,184,0.18);
  background: rgba(255,255,255,0.04);
  color: var(--text, #e2e8f0);
  font-family: inherit; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; cursor: pointer;
  transition: border-color 0.18s, background 0.18s, transform 0.15s;
}
.ap-social-btn:hover {
  border-color: rgba(96,165,250,0.35);
  background: rgba(96,165,250,0.06);
  transform: translateY(-1px);
}
:root[data-theme="light"] .ap-social-btn {
  background: #fff; border-color: rgba(15,23,42,0.14); color: #0f172a;
}

/* ── Link ── */
.ap-link {
  background: none; border: none;
  color: #60a5fa; font-size: 12px; font-weight: 700;
  cursor: pointer; padding: 0; transition: color 0.15s;
}
.ap-link:hover { color: #93c5fd; }

/* ── Sent screen ── */
.ap-sent-icon { display: flex; justify-content: center; margin: 4px 0; }
.ap-sent-title { font-size: 16px; font-weight: 900; color: var(--text, #f1f5f9); text-align: center; }
.ap-sent-body  { font-size: 13px; color: var(--muted, #94a3b8); text-align: center; line-height: 1.9; }

/* ── Hint ── */
.ap-hint { font-size: 12px; color: var(--muted, #64748b); line-height: 1.7; margin: 0; }

/* ── Trigger ── */
.topbar-login-btn, .ap-open { cursor: pointer; }