/* ============================================================================
   FragranceScout — Auth (sign in / sign up / reset) + logged-in avatar nav.
   Design language borrowed from index.html: glassmorphic surfaces,
   Hanken Grotesk uppercase micro-labels, Playfair headings, ink #1a1c1c CTA.
   ========================================================================== */

/* Login page owns the whole viewport — reset the UA body margin so the sky
   image bleeds to every edge (no white bars) and the page itself never scrolls. */
html:has(.auth-stage), body:has(.auth-stage) { margin: 0; padding: 0; }
.auth-stage, .auth-stage * { box-sizing: border-box; }

/* ---------- Login page shell ---------- */
.auth-stage {
  position: relative;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  /* Sky photo + a colour-matched gradient underneath so first paint (before the
     JPG decodes) is the same bright blue rather than a white flash. */
  background:
    url('../uploads/auth-bg.jpg') center 42%/cover no-repeat,
    linear-gradient(180deg, #6fa9dc 0%, #9cc3e4 46%, #dfeaf3 100%);
  background-color: #9cc3e4;
}
/* Very light wash so the frosted panel always has enough contrast regardless of
   where the clouds fall behind it, without dulling the sky. */
.auth-stage::before {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(120% 90% at 50% 38%, rgba(255,255,255,0) 40%, rgba(120,150,180,0.14) 100%);
  pointer-events: none;
}

/* Back-to-home crumb, top-left over the sky */
.auth-home {
  position: absolute; top: 28px; left: 32px; z-index: 5;
  display: inline-flex; align-items: center; gap: 10px;
  text-decoration: none;
  font-family: 'Hanken Grotesk', sans-serif;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.13em; text-transform: uppercase;
  color: #23425f;
  padding: 8px 14px 8px 10px; border-radius: 999px;
  background: rgba(255,255,255,0.34);
  border: 1px solid rgba(255,255,255,0.5);
  backdrop-filter: blur(10px) saturate(1.3);
  -webkit-backdrop-filter: blur(10px) saturate(1.3);
  transition: background .18s ease, color .18s ease;
}
.auth-home:hover { background: rgba(255,255,255,0.6); color: #10283d; }
.auth-home img { width: 24px; height: 24px; object-fit: contain; display: block; }
.auth-home .chev { font-size: 14px; line-height: 1; }

/* ---------- Glass panel ---------- */
.auth-card {
  position: relative; z-index: 2;
  width: 100%; max-width: 452px;
  /* Never exceed the viewport: if a window is unusually short, the card itself
     scrolls so the panel is fully reachable and the page never scrolls. */
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  padding: 34px 42px 28px;
  border-radius: 24px;
  background: rgba(250, 251, 253, 0.55);
  backdrop-filter: blur(30px) saturate(1.5);
  -webkit-backdrop-filter: blur(30px) saturate(1.5);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow:
    0 30px 70px rgba(26, 45, 71, 0.28),
    0 2px 6px rgba(26, 45, 71, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
  color: #1a1c1c;
  animation: authRise .55s cubic-bezier(.22,.61,.36,1) both;
}
@keyframes authRise {
  from { opacity: 0; transform: translateY(18px) scale(.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Panel header: emblem + wordmark + contextual title */
.auth-head { text-align: center; margin-bottom: 20px; }
.auth-brand {
  display: inline-flex; align-items: center; gap: 11px;
  margin-bottom: 16px;
}
.auth-brand img { width: 40px; height: 40px; object-fit: contain; display: block; }
.auth-brand .wordmark {
  font-family: 'Hanken Grotesk', sans-serif;
  font-size: 15px; font-weight: 700; letter-spacing: 0.34em; text-transform: uppercase;
  color: #16324a; padding-left: 0.34em;
}
.auth-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 500; font-size: 27px; line-height: 1.15;
  color: #12283c; margin: 0 0 7px;
}
.auth-sub {
  font-size: 14px; color: #47617a; margin: 0;
  line-height: 1.5;
}

/* ---------- Segmented tab switch ---------- */
.auth-switch {
  position: relative;
  display: grid; grid-template-columns: 1fr 1fr;
  background: rgba(23, 50, 74, 0.08);
  border: 1px solid rgba(255,255,255,0.45);
  border-radius: 12px; padding: 4px;
  margin-bottom: 24px;
}
.auth-switch .thumb {
  position: absolute; top: 4px; bottom: 4px; left: 4px;
  width: calc(50% - 4px);
  background: rgba(255,255,255,0.9);
  border-radius: 9px;
  box-shadow: 0 3px 10px rgba(26,45,71,0.14);
  transition: transform .28s cubic-bezier(.4,.0,.2,1);
}
.auth-stage[data-mode="signup"] .auth-switch .thumb { transform: translateX(100%); }
.auth-switch button {
  position: relative; z-index: 1;
  appearance: none; border: none; background: transparent; cursor: pointer;
  font-family: 'Hanken Grotesk', sans-serif;
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.11em; text-transform: uppercase;
  color: #5a7189; padding: 11px 0;
  transition: color .2s ease;
}
.auth-switch button.is-active { color: #12283c; }
.auth-stage[data-mode="signin"] .auth-switch button[data-goto="signin"],
.auth-stage[data-mode="signup"] .auth-switch button[data-goto="signup"] { color: #12283c; }

/* ---------- Google / SSO button ---------- */
.auth-google {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  height: 50px; border-radius: 12px; cursor: pointer;
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(255,255,255,0.9);
  box-shadow: 0 4px 14px rgba(26,45,71,0.1);
  font-family: 'Hanken Grotesk', sans-serif;
  font-size: 14px; font-weight: 600; letter-spacing: 0.01em; color: #2a2c31;
  transition: background .18s ease, box-shadow .18s ease, transform .06s ease;
}
.auth-google:hover { background: #ffffff; box-shadow: 0 6px 20px rgba(26,45,71,0.16); }
.auth-google:active { transform: translateY(1px); }
.auth-google svg { width: 19px; height: 19px; display: block; }

/* "or" divider */
.auth-or {
  display: flex; align-items: center; gap: 14px;
  margin: 16px 0;
  font-family: 'Hanken Grotesk', sans-serif;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase;
  color: #6a819a;
}
.auth-or::before, .auth-or::after {
  content: ""; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(40,74,104,0.28), transparent);
}

/* ---------- Fields ---------- */
.auth-field { margin-bottom: 14px; }
.auth-field label {
  display: block; margin-bottom: 7px;
  font-family: 'Hanken Grotesk', sans-serif;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  color: #3f5871;
}
.auth-input-wrap { position: relative; display: flex; align-items: center; }
.auth-field input {
  width: 100%; height: 50px;
  border: 1px solid rgba(40, 74, 104, 0.22);
  background: rgba(255,255,255,0.6);
  border-radius: 12px; padding: 0 15px;
  font-family: 'Inter', sans-serif; font-size: 15px; color: #12283c;
  outline: none;
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}
.auth-field input::placeholder { color: rgba(50, 80, 110, 0.5); }
.auth-field input:focus {
  border-color: #3a6ea5;
  background: rgba(255,255,255,0.82);
  box-shadow: 0 0 0 3px rgba(58, 110, 165, 0.16);
}
.auth-field.has-toggle input { padding-right: 46px; }
.auth-field.invalid input { border-color: #cf5b52; box-shadow: 0 0 0 3px rgba(207,91,82,0.14); }

/* Eye toggle inside password field */
.auth-eye {
  position: absolute; right: 8px;
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border: none; background: transparent;
  color: #6a819a; cursor: pointer; border-radius: 8px;
  transition: color .15s ease, background .15s ease;
}
.auth-eye:hover { color: #2a4a68; background: rgba(40,74,104,0.08); }
.auth-eye svg { width: 20px; height: 20px; }

/* Per-field error text */
.auth-err {
  display: none;
  margin: 6px 2px 0;
  font-family: 'Inter', sans-serif; font-size: 12px; color: #c0483f;
}
.auth-field.invalid .auth-err { display: block; }

/* Row: remember me + forgot link */
.auth-row {
  display: flex; align-items: center; justify-content: space-between;
  margin: 4px 0 22px;
}
.auth-check {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font-family: 'Inter', sans-serif; font-size: 13px; color: #3f5871; user-select: none;
}
.auth-check input { position: absolute; opacity: 0; width: 0; height: 0; }
.auth-check .box {
  width: 18px; height: 18px; border-radius: 5px; flex: none;
  border: 1px solid rgba(40,74,104,0.35);
  background: rgba(255,255,255,0.6);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s ease, border-color .15s ease;
}
.auth-check .box svg { width: 12px; height: 12px; opacity: 0; transform: scale(.6); transition: .15s ease; stroke: #fff; }
.auth-check input:checked + .box { background: #1a1c1c; border-color: #1a1c1c; }
.auth-check input:checked + .box svg { opacity: 1; transform: scale(1); }
.auth-check input:focus-visible + .box { box-shadow: 0 0 0 3px rgba(58,110,165,0.28); }

.auth-link {
  background: none; border: none; cursor: pointer; padding: 0;
  font-family: 'Hanken Grotesk', sans-serif;
  font-size: 12.5px; font-weight: 600; color: #2f5a86;
  text-decoration: none;
  transition: color .15s ease;
}
.auth-link:hover { color: #16324a; text-decoration: underline; }

/* ---------- Primary CTA ---------- */
.auth-submit {
  width: 100%; height: 52px; border: 1px solid #1a1c1c;
  background: #1a1c1c; color: #fff; cursor: pointer;
  border-radius: 12px;
  font-family: 'Hanken Grotesk', sans-serif;
  font-size: 12.5px; font-weight: 700; letter-spacing: 0.11em; text-transform: uppercase;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  transition: background .18s ease, transform .06s ease, box-shadow .18s ease;
  box-shadow: 0 10px 26px rgba(18, 28, 40, 0.28);
}
.auth-submit:hover { background: #000; box-shadow: 0 12px 30px rgba(18, 28, 40, 0.36); }
.auth-submit:active { transform: translateY(1px); }
.auth-submit[disabled] { opacity: 0.7; cursor: default; box-shadow: none; }
.auth-submit .spin {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff;
  animation: authSpin .7s linear infinite; display: none;
}
.auth-submit.loading .spin { display: inline-block; }
.auth-submit.loading .label { opacity: 0.85; }
@keyframes authSpin { to { transform: rotate(360deg); } }

/* Footer swap prompt under the panel body */
.auth-foot {
  text-align: center; margin-top: 22px;
  font-family: 'Inter', sans-serif; font-size: 13.5px; color: #47617a;
}
.auth-foot .auth-link { font-size: 13.5px; }

/* Terms fine print (signup) */
.auth-fine {
  margin: 2px 0 20px; font-family: 'Inter', sans-serif;
  font-size: 11.5px; line-height: 1.5; color: #5a7189; text-align: center;
}
.auth-fine a { color: #2f5a86; text-decoration: none; }
.auth-fine a:hover { text-decoration: underline; }

/* Top-level banner (errors / reset confirmation) */
.auth-banner {
  display: none;
  align-items: flex-start; gap: 10px;
  margin-bottom: 18px; padding: 12px 14px; border-radius: 11px;
  font-family: 'Inter', sans-serif; font-size: 13px; line-height: 1.45;
}
.auth-banner.show { display: flex; }
.auth-banner.error { background: rgba(207,72,63,0.12); border: 1px solid rgba(207,72,63,0.3); color: #a23a32; }
.auth-banner.ok    { background: rgba(46,125,90,0.12); border: 1px solid rgba(46,125,90,0.3); color: #276b4d; }
.auth-banner svg { flex: none; width: 17px; height: 17px; margin-top: 1px; }

/* The Google button / "or" divider carry [hidden] until auth.js confirms the
   provider is enabled; their display rules would otherwise out-rank the UA's
   [hidden] { display: none } and show a button that cannot work. */
.auth-stage [hidden] { display: none !important; }

/* ---------- View switching (signin / signup / reset / update) ---------- */
.auth-view { display: none; }
.auth-stage[data-mode="signin"] [data-view="signin"],
.auth-stage[data-mode="signup"] [data-view="signup"],
.auth-stage[data-mode="reset"]  [data-view="reset"],
.auth-stage[data-mode="update"] [data-view="update"] { display: block; }
/* Hide the segmented switch while resetting / setting a new password */
.auth-stage[data-mode="reset"] .auth-switch,
.auth-stage[data-mode="update"] .auth-switch { display: none; }

/* Fields that only belong to signup (name) live inside the signup view, so no
   extra rules needed — each view carries its own form. */

@media (max-width: 520px) {
  .auth-stage { padding: 84px 16px 40px; }
  .auth-card { padding: 32px 24px 28px; border-radius: 20px; }
  .auth-home { top: 18px; left: 16px; }
  .auth-title { font-size: 24px; }
}

/* ============================================================================
   Logged-in avatar nav (used on index.html in place of the sign in/up pills)
   ========================================================================== */
.user-menu { position: relative; }
.user-avatar {
  display: inline-flex; align-items: center; gap: 10px;
  height: 44px; padding: 0 6px 0 6px; cursor: pointer;
  background: transparent; border: none; border-radius: 12px;
  transition: background .16s ease;
}
.user-avatar:hover { background: rgba(255,255,255,0.4); }
.user-avatar .badge {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #2b567f, #14324c);
  color: #fff; font-family: 'Hanken Grotesk', sans-serif;
  font-size: 14px; font-weight: 700; letter-spacing: 0.02em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.28), 0 2px 8px rgba(20,50,76,0.35);
  overflow: hidden; text-transform: uppercase;
}
.user-avatar .badge img { width: 100%; height: 100%; object-fit: cover; display: block; }
.user-avatar .who {
  display: flex; flex-direction: column; align-items: flex-start; line-height: 1.1;
  padding-right: 6px; max-width: 150px;
}
.user-avatar .who .name {
  font-family: 'Hanken Grotesk', sans-serif; font-size: 13px; font-weight: 700;
  color: #16263a; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-avatar .who .tag {
  font-size: 9.5px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase;
  color: #5a7189;
}
.user-avatar .caret { color: #47617a; transition: transform .2s ease; }
.user-menu.open .user-avatar .caret { transform: rotate(180deg); }

.user-dropdown {
  position: absolute; top: calc(100% + 12px); right: 0;
  min-width: 240px; padding: 8px;
  background: rgba(250, 251, 253, 0.7);
  backdrop-filter: blur(26px) saturate(1.5);
  -webkit-backdrop-filter: blur(26px) saturate(1.5);
  border: 1px solid rgba(255,255,255,0.6);
  border-radius: 16px;
  box-shadow: 0 24px 54px rgba(20, 40, 61, 0.26), inset 0 1px 0 rgba(255,255,255,0.6);
  opacity: 0; visibility: hidden; transform: translateY(-8px) scale(.98);
  transform-origin: top right;
  transition: opacity .18s ease, transform .18s ease, visibility .18s;
  font-family: 'Hanken Grotesk', sans-serif;
}
.user-menu.open .user-dropdown { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }

.user-dropdown .dd-head {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px 12px;
  border-bottom: 1px solid rgba(40,74,104,0.14); margin-bottom: 6px;
}
.user-dropdown .dd-head .badge {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #2b567f, #14324c); color: #fff;
  font-size: 15px; font-weight: 700; text-transform: uppercase; overflow: hidden;
}
.user-dropdown .dd-head .badge img { width: 100%; height: 100%; object-fit: cover; }
.user-dropdown .dd-head .meta { min-width: 0; }
.user-dropdown .dd-head .n { font-size: 14px; font-weight: 700; color: #16263a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-dropdown .dd-head .e { font-size: 12px; color: #5a7189; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.user-dropdown a, .user-dropdown button {
  width: 100%; display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border: none; background: transparent; cursor: pointer;
  text-align: left; text-decoration: none; border-radius: 10px;
  font-family: 'Hanken Grotesk', sans-serif; font-size: 13.5px; font-weight: 600; color: #22364a;
  transition: background .14s ease, color .14s ease;
}
.user-dropdown a:hover, .user-dropdown button:hover { background: rgba(40,74,104,0.09); }
.user-dropdown svg { width: 17px; height: 17px; flex: none; color: #4a637d; }
.user-dropdown .dd-sep { height: 1px; background: rgba(40,74,104,0.14); margin: 6px 4px; }
.user-dropdown .dd-signout { color: #b23c33; }
.user-dropdown .dd-signout svg { color: #b23c33; }
.user-dropdown .dd-signout:hover { background: rgba(178,60,51,0.1); }

@media (max-width: 620px) {
  .user-avatar .who { display: none; }
  .user-avatar { padding: 0; }
}
