:root {
  --teal: #3FA0AD;
  --teal-dark: #2D7A85;
  --teal-darker: #1E5A63;
  --teal-pale: #D4ECEF;
  --gold: #E8B547;
  --gold-bright: #F5CF5A;
  --pink-bright: #E87598;
  --pistachio: #A8C88A;
  --pistachio-dark: #7FA668;
  --cream: #FEF8E8;
  --cream-warm: #FAEEC8;
  --ink: #1A2E33;
  --ink-soft: #3D4F54;
  --muted: #7A8A8E;
  --border: rgba(26,46,51,0.12);
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', -apple-system, sans-serif;
  --font-hand: 'Caveat', cursive;
  --font-ar: 'Cairo', 'Inter', sans-serif;
}

/* RTL overrides — applied when <html dir="rtl"> */
html[dir="rtl"] body,
html[dir="rtl"] .auth-container,
html[dir="rtl"] input,
html[dir="rtl"] button,
html[dir="rtl"] label {
  font-family: var(--font-ar);
}
html[dir="rtl"] .auth-logo-text {
  font-family: var(--font-display);
}

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

body {
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  background-image:
    radial-gradient(circle at 10% 20%, rgba(232,117,152,0.08), transparent 50%),
    radial-gradient(circle at 90% 80%, rgba(168,200,138,0.08), transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(63,160,173,0.05), transparent 70%);
}

/* ============================================================
   TOP BAR — Language Switcher
   ============================================================ */
.top-bar {
  width: 100%;
  max-width: 900px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 8px 4px 20px;
  gap: 8px;
}
html[dir="rtl"] .top-bar { justify-content: flex-start; }

.lang-switcher {
  display: inline-flex;
  gap: 4px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  box-shadow: 0 4px 14px rgba(26,46,51,0.06);
}
.lang-btn {
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s;
  min-width: 38px;
  text-transform: uppercase;
}
.lang-btn:hover { color: var(--ink); background: var(--cream); }
.lang-btn.active { background: var(--ink); color: var(--gold-bright); }
.lang-btn .flag { font-size: 14px; margin-inline-end: 4px; }

/* ============================================================
   AUTH CARD
   ============================================================ */
.page-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-container {
  width: 100%;
  max-width: 480px;
  background: white;
  border-radius: 24px;
  padding: 48px 40px;
  box-shadow: 0 20px 60px rgba(26,46,51,0.1);
  position: relative;
  overflow: hidden;
}

.auth-container::before {
  content: '';
  position: absolute;
  top: 0; inset-inline: 0;
  height: 6px;
  background: linear-gradient(90deg, var(--teal), var(--gold), var(--pink-bright), var(--pistachio));
}

.auth-logo { text-align: center; margin-bottom: 8px; }

.auth-logo-text {
  font-family: var(--font-display);
  font-weight: 900;
  font-style: italic;
  font-size: 52px;
  color: var(--teal-dark);
  letter-spacing: -2px;
  line-height: 1;
}
.auth-logo-text em { color: var(--gold); font-style: italic; }

.auth-subtitle {
  text-align: center;
  font-family: var(--font-hand);
  font-size: 20px;
  color: var(--muted);
  margin-bottom: 32px;
}
html[dir="rtl"] .auth-subtitle { font-family: var(--font-ar); font-weight: 500; }

.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--cream);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 28px;
}

.auth-tab {
  flex: 1;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  transition: all 0.2s;
}
.auth-tab.active { background: var(--ink); color: var(--gold-bright); }

.auth-form { display: none; }
.auth-form.active { display: block; animation: fadeIn 0.3s; }

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

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.form-field { margin-bottom: 16px; }
.form-field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.form-field input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
  background: var(--cream);
  transition: all 0.2s;
}
.form-field input:focus {
  outline: none;
  border-color: var(--teal);
  background: white;
}
.form-field input:invalid:not(:placeholder-shown) {
  border-color: var(--pink-bright);
}

/* ============================================================
   PASSWORD WRAPPER — eye toggle
   ============================================================ */
.password-wrapper {
  position: relative;
  width: 100%;
}
.password-wrapper input {
  padding-inline-end: 48px; /* make room for the toggle */
}
.pw-toggle {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  inset-inline-end: 10px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  border-radius: 8px;
  padding: 0;
  transition: color 0.18s, background 0.18s;
}
.pw-toggle:hover { color: var(--teal-dark); background: rgba(63,160,173,0.08); }
.pw-toggle:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px; }
.pw-toggle svg { width: 20px; height: 20px; display: block; pointer-events: none; }
.pw-toggle .icon-eye-off { display: none; }
.pw-toggle.is-visible .icon-eye { display: none; }
.pw-toggle.is-visible .icon-eye-off { display: block; }

/* Password match indicator */
.pw-match-hint {
  font-size: 12px;
  margin-top: 6px;
  font-weight: 600;
  min-height: 16px;
  transition: color 0.2s;
}
.pw-match-hint.match { color: var(--pistachio-dark); }
.pw-match-hint.mismatch { color: var(--pink-bright); }

.form-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  margin-bottom: 12px;
  line-height: 1.5;
}
.form-checkbox input {
  width: 18px; height: 18px; margin-top: 2px; cursor: pointer;
  accent-color: var(--teal-dark);
  flex-shrink: 0;
}

.btn-primary {
  width: 100%;
  padding: 16px;
  border-radius: 999px;
  border: none;
  background: var(--ink);
  color: var(--gold-bright);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
  margin-top: 8px;
}
.btn-primary:hover:not(:disabled) {
  background: var(--teal-darker);
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(26,46,51,0.2);
}
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary {
  display: block;
  width: 100%;
  padding: 14px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: white;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  font-family: inherit;
  margin-top: 12px;
  text-align: center;
  text-decoration: none;
  transition: all 0.2s;
}
.btn-secondary:hover { border-color: var(--teal); background: var(--teal-pale); }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.form-link {
  color: var(--teal-dark);
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
}
.form-link:hover { text-decoration: underline; }

.alert {
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 16px;
  font-size: 13px;
  line-height: 1.5;
  display: none;
}
.alert.show { display: block; animation: slideDown 0.3s; }
.alert.success { background: rgba(168,200,138,0.15); color: var(--pistachio-dark); border: 1px solid var(--pistachio); }
.alert.error { background: rgba(232,117,152,0.1); color: var(--pink-bright); border: 1px solid var(--pink-bright); }
.alert.info { background: var(--teal-pale); color: var(--teal-darker); border: 1px solid var(--teal); }

@keyframes slideDown {
  from { opacity: 0; max-height: 0; }
  to { opacity: 1; max-height: 200px; }
}

.password-strength {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}
.password-strength-bar {
  height: 100%;
  width: 0;
  transition: all 0.3s;
  border-radius: 2px;
}
.password-strength-bar.weak { background: var(--pink-bright); width: 33%; }
.password-strength-bar.medium { background: var(--gold); width: 66%; }
.password-strength-bar.strong { background: var(--pistachio-dark); width: 100%; }

.back-home {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
  margin-bottom: 24px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.back-home:hover { color: var(--ink); }

.guest-box {
  margin-top: 24px;
  padding: 20px;
  background: var(--cream);
  border-radius: 16px;
  text-align: center;
}
.guest-box h4 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 6px;
}
html[dir="rtl"] .guest-box h4 { font-family: var(--font-ar); }
.guest-box p {
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 12px;
  line-height: 1.5;
}
/* Customer was bounced here from the cart (?redirect=checkout.html).
   Outline the guest route so it is findable, but keep it quieter than the
   primary sign-in button above it. */
.guest-box.from-checkout {
  background: var(--teal-pale);
  border: 1px dashed var(--teal);
}
.guest-box.from-checkout h4 { color: var(--teal-darker); }

.loading-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: var(--gold-bright);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-inline-end: 8px;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 480px) {
  .auth-container { padding: 32px 24px; }
  .auth-logo-text { font-size: 40px; }
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .lang-btn { padding: 6px 8px; min-width: 34px; font-size: 11px; }
}
