/* ======================================================
   AUTH PAGE — Login / Sign Up
   Matches site design system: glass, brand green + orange
====================================================== */

/* ── Full-screen layout ── */
.auth-page {
  min-height: 100vh;
  padding-top: 0 !important;   /* override body padding-top:96px */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(24px, 4vw, 56px);
  overflow-x: hidden;
}

.auth-page::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(120deg, rgba(4,106,56,0.18), transparent 38%),
    linear-gradient(300deg, rgba(255,103,31,0.12), transparent 42%);
  opacity: 0.85;
}

.auth-page::after {
  content: "";
  position: fixed;
  inset: auto 0 0 0;
  height: 42vh;
  pointer-events: none;
  background: linear-gradient(0deg, rgba(4,106,56,0.14), transparent);
}

/* ── Access layout ── */
.auth-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(380px, 450px);
  gap: clamp(30px, 6vw, 88px);
  align-items: center;
}

.auth-intro {
  max-width: 620px;
}

.auth-kicker {
  margin: 0 0 18px;
  color: var(--brand-green);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 1.8px;
  text-transform: uppercase;
}

.auth-intro h1 {
  margin: 0 0 18px;
  max-width: 760px;
  font-size: clamp(2.8rem, 5.8vw, 5.6rem);
  line-height: 1.02;
  letter-spacing: 0;
  font-weight: 900;
}

.auth-copy {
  max-width: 540px;
  margin: 0;
  font-size: 1rem;
  line-height: 1.75;
  opacity: 0.78;
}

.auth-access-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 38px;
}

.auth-access-grid > div {
  min-height: 126px;
  padding: 18px;
  border-radius: 16px;
}

body.theme-dark .auth-access-grid > div {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
}

body.theme-light .auth-access-grid > div {
  background: #fff;
  border: 1px solid rgba(0,0,0,0.1);
  box-shadow: 0 10px 30px rgba(0,0,0,0.06);
}

.auth-access-grid span {
  display: block;
  margin-bottom: 16px;
  color: var(--brand-orange);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 1px;
}

.auth-access-grid strong {
  display: block;
  margin-bottom: 8px;
  font-size: 0.92rem;
}

.auth-access-grid p {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.55;
  opacity: 0.68;
}

/* ── Card ── */
.auth-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  padding: clamp(28px, 3.6vw, 42px);
  border-radius: 22px;
  justify-self: end;
}

body.theme-dark .auth-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 24px 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(4,106,56,0.12);
  backdrop-filter: blur(20px) saturate(160%);
}

body.theme-light .auth-card {
  background: rgba(255,255,255,0.85);
  border: 1px solid rgba(0,0,0,0.1);
  box-shadow: 0 24px 60px rgba(0,0,0,0.1);
  backdrop-filter: blur(20px) saturate(160%);
}

/* ── Logo / Brand ── */
.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.auth-brand--intro {
  justify-content: flex-start;
  margin-bottom: clamp(40px, 7vw, 78px);
}

.auth-brand--card {
  justify-content: center;
  margin-bottom: 16px;
}

.auth-brand img {
  width: 46px;
  height: 46px;
  object-fit: contain;
  cursor: pointer;
}

.auth-brand-name {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0;
}

.auth-brand-sub {
  font-size: 0.72rem;
  opacity: 0.5;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.auth-route-note {
  width: fit-content;
  margin: 0 auto 28px;
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--brand-green);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  text-align: center;
}

body.theme-dark .auth-route-note {
  background: rgba(4,106,56,0.12);
  border: 1px solid rgba(4,106,56,0.24);
}

body.theme-light .auth-route-note {
  background: rgba(4,106,56,0.08);
  border: 1px solid rgba(4,106,56,0.18);
}

/* ── Tab switcher ── */
.auth-tabs {
  display: flex;
  gap: 0;
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 32px;
}

body.theme-dark .auth-tabs {
  background: rgba(255,255,255,0.05);
}

body.theme-light .auth-tabs {
  background: rgba(0,0,0,0.06);
}

.auth-tab {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: 9px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: inherit;
  opacity: 0.58;
  transition: opacity 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  letter-spacing: 0.3px;
}

.auth-tab.active {
  opacity: 1;
  background: var(--brand-green);
  color: #fff;
  box-shadow: 0 4px 14px rgba(4,106,56,0.35);
}

/* ── Form panels ── */
.auth-panel {
  display: none;
}

.auth-panel.active {
  display: block;
  animation: authFadeIn 0.25s ease;
}

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

/* ── Field ── */
.auth-field {
  margin-bottom: 18px;
  position: relative;
}

.auth-field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.4px;
  margin-bottom: 7px;
  opacity: 0.7;
  text-transform: uppercase;
}

.auth-field input {
  width: 100%;
  min-height: 48px;
  padding: 13px 16px;
  border-radius: 12px;
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  font-family: inherit;
}

body.theme-dark .auth-field input {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: #e5e5e5;
}

body.theme-light .auth-field input {
  background: #f7f7f7;
  border: 1px solid rgba(0,0,0,0.12);
  color: #111;
}

.auth-field input:focus {
  border-color: var(--brand-green);
  box-shadow: 0 0 0 3px rgba(4,106,56,0.15);
}

/* Password field with show/hide toggle */
.auth-field .pw-wrap {
  position: relative;
}

.auth-field .pw-wrap input {
  padding-right: 46px;
}

.auth-field .pw-toggle {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  color: inherit;
  opacity: 0.45;
  transition: opacity 0.2s ease;
  line-height: 1;
  font-size: 1rem;
}

.auth-field .pw-toggle:hover {
  opacity: 0.9;
}

/* ── Password strength bar ── */
.pw-strength {
  height: 3px;
  border-radius: 2px;
  margin-top: 6px;
  transition: width 0.3s ease, background 0.3s ease;
  width: 0%;
  background: transparent;
}

.pw-strength-text {
  margin-top: 8px;
  font-size: 0.72rem;
  line-height: 1.45;
  opacity: 0.55;
}

/* ── Remember me row ── */
.auth-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 22px;
  cursor: pointer;
  font-size: 0.82rem;
  opacity: 0.75;
  user-select: none;
}

.auth-remember input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--brand-green);
  cursor: pointer;
}

/* ── Submit button ── */
.auth-submit {
  width: 100%;
  min-height: 50px;
  padding: 14px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--brand-green), var(--brand-orange));
  color: #fff;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  cursor: pointer;
  transition: opacity 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
  position: relative;
}

.auth-submit:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(4,106,56,0.3), 0 6px 16px rgba(255,103,31,0.2);
}

.auth-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.auth-link-btn {
  display: block;
  width: fit-content;
  margin: 12px auto 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--brand-green);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.auth-otp-verify[hidden],
#otpRequestForm[hidden] {
  display: none !important;
}

/* Loading spinner inside button */
.auth-submit .spin {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Status message ── */
.auth-status {
  margin-top: 14px;
  font-size: 0.82rem;
  text-align: center;
  min-height: 20px;
  border-radius: 8px;
  padding: 0;
  transition: all 0.2s ease;
}

.auth-status.error {
  color: #ff4d4d;
  background: rgba(255,77,77,0.08);
  padding: 10px 14px;
}

.auth-status.success {
  color: var(--brand-green);
  background: rgba(4,106,56,0.08);
  padding: 10px 14px;
}

/* ── No-account hint ── */
.auth-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 0.82rem;
  margin-bottom: 18px;
  background: rgba(4,106,56,0.08);
  border: 1px solid rgba(4,106,56,0.2);
}

.auth-hint button {
  background: none;
  border: none;
  color: var(--brand-green);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  white-space: nowrap;
  text-decoration: underline;
}

/* ── Divider ── */
.auth-divider {
  text-align: center;
  font-size: 0.75rem;
  opacity: 0.35;
  margin: 20px 0 0;
  letter-spacing: 0.5px;
}


/* ── Local users snapshot ── */
.auth-users {
  margin-top: 16px;
  padding: 14px;
  border-radius: 12px;
  background: rgba(4,106,56,0.06);
  border: 1px solid rgba(4,106,56,0.16);
}

.auth-users-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
  font-size: 0.8rem;
  font-weight: 700;
}

.auth-users-head button {
  border: none;
  background: transparent;
  color: var(--brand-green);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  white-space: nowrap;
  text-decoration: underline;
}

.auth-users-list {
  display: grid;
  gap: 10px;
}

.auth-user-item {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
}

body.theme-light .auth-user-item {
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.08);
}

.auth-user-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  font-size: 0.8rem;
}

.auth-user-top strong {
  color: var(--brand-green);
}

.auth-user-top span,
.auth-user-meta {
  font-size: 0.72rem;
  opacity: 0.72;
  margin-top: 4px;
}

.auth-user-meta code {
  font-size: 0.72rem;
  word-break: break-all;
}

/* ── Logged-in bar on personal page ── */
.auth-bar {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: max-content;
  font-size: 0.78rem;
  line-height: 1;
  opacity: 1;
  white-space: nowrap;
}

.auth-bar span {
  display: none;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.auth-bar strong {
  color: var(--brand-green);
  opacity: 1;
  font-weight: 800;
  letter-spacing: .1px;
}

.auth-logout-btn {
  min-height: 44px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(4,106,56,0.42);
  background: rgba(4,106,56,0.12);
  color: var(--brand-green);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
}

.auth-logout-btn.is-login {
  border-color: rgba(4,106,56,0.42);
  background: rgba(4,106,56,0.12);
  color: var(--brand-green);
}

.auth-logout-btn.is-logout {
  border-color: rgba(255,103,31,0.48);
  background: rgba(255,103,31,0.1);
  color: var(--brand-orange);
}

.auth-logout-btn:hover {
  border-color: rgba(255,103,31,0.6);
  background: var(--brand-orange);
  color: #fff;
  transform: translateY(-1px);
}

@media (max-width: 768px) {
  .auth-bar {
    min-width: 0;
  }

  .auth-logout-btn {
    min-height: 44px;
    padding: 10px 14px;
    font-size: 0.72rem;
  }
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .auth-page {
    align-items: flex-start;
    padding: 14px;
  }

  .auth-shell {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .auth-intro {
    max-width: none;
    margin-bottom: 0;
  }

  .auth-brand--intro {
    margin-bottom: 18px;
  }

  .auth-intro h1 {
    font-size: clamp(2.05rem, 11vw, 3rem);
    letter-spacing: 0;
    margin-bottom: 12px;
  }

  .auth-copy {
    font-size: 0.9rem;
    line-height: 1.6;
  }

  .auth-access-grid {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    margin-top: 16px;
  }

  .auth-access-grid > div {
    min-height: auto;
    padding: 12px 10px;
    border-radius: 12px;
  }

  .auth-access-grid span {
    margin-bottom: 8px;
    font-size: 0.62rem;
  }

  .auth-access-grid strong {
    margin-bottom: 0;
    font-size: 0.72rem;
  }

  .auth-access-grid p {
    display: none;
  }

  .auth-card {
    padding: 22px 16px 20px;
    border-radius: 18px;
    max-width: none;
    justify-self: stretch;
  }

  .auth-brand--card {
    justify-content: flex-start;
    margin-bottom: 16px;
  }

  .auth-brand img {
    width: 40px;
    height: 40px;
  }

  .auth-route-note {
    margin: 0 0 18px;
  }

  .auth-tabs {
    margin-bottom: 20px;
  }

  .auth-field {
    margin-bottom: 14px;
  }

  .auth-hint {
    align-items: flex-start;
    flex-direction: column;
  }

  .auth-users {
    display: none !important;
  }
}

@media (min-width: 481px) and (max-width: 900px) {
  .auth-page {
    align-items: flex-start;
  }

  .auth-shell {
    grid-template-columns: 1fr;
    max-width: 680px;
  }

  .auth-card {
    max-width: none;
    justify-self: stretch;
  }

  .auth-brand--intro {
    margin-bottom: 44px;
  }
}

@media (max-width: 360px) {
  .auth-card {
    padding: 28px 18px 26px;
  }
}

/* ── Card entry animation ── */
.auth-card {
  animation: cardEntry 0.55s cubic-bezier(0.23, 1, 0.32, 1) both;
}

@keyframes cardEntry {
  from { opacity: 0; transform: translateY(28px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Animated background orbs ── */
.auth-orb {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(90px);
  opacity: 0.2;
  z-index: 0;
}

.auth-orb--1 {
  width: 480px;
  height: 480px;
  top: -120px;
  left: -140px;
  background: radial-gradient(circle, var(--brand-green) 30%, transparent 70%);
  animation: orbFloat1 16s ease-in-out infinite;
}

.auth-orb--2 {
  width: 400px;
  height: 400px;
  bottom: -80px;
  right: -100px;
  background: radial-gradient(circle, var(--brand-orange) 30%, transparent 70%);
  animation: orbFloat2 20s ease-in-out infinite;
  opacity: 0.15;
}

@keyframes orbFloat1 {
  0%,  100% { transform: translate(0, 0) scale(1); }
  33%        { transform: translate(40px, -30px) scale(1.07); }
  66%        { transform: translate(-24px, 20px) scale(0.93); }
}

@keyframes orbFloat2 {
  0%,  100% { transform: translate(0, 0) scale(1); }
  40%        { transform: translate(-35px, -25px) scale(1.06); }
  75%        { transform: translate(28px, 18px) scale(0.94); }
}

/* ── OTP digit grid ── */
.otp-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.otp-digit {
  width: 100%;
  min-height: 52px;
  text-align: center;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 0;
  border-radius: 12px;
  padding: 0;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.15s ease;
  font-family: inherit;
  caret-color: transparent;
}

body.theme-dark .otp-digit {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: #e5e5e5;
}

body.theme-light .otp-digit {
  background: #f7f7f7;
  border: 1px solid rgba(0,0,0,0.12);
  color: #111;
}

.otp-digit:focus {
  border-color: var(--brand-green);
  box-shadow: 0 0 0 3px rgba(4,106,56,0.2);
  transform: scale(1.08);
}

.otp-digit.filled {
  border-color: var(--brand-green);
  background: rgba(4,106,56,0.08);
}

@media (max-width: 380px) {
  .otp-grid { gap: 5px; }
  .otp-digit { min-height: 44px; font-size: 1.2rem; border-radius: 10px; }
}

/* ── Lockout timer ── */
.auth-lockout {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(255,77,77,0.08);
  border: 1px solid rgba(255,77,77,0.22);
  font-size: 0.82rem;
  margin-bottom: 16px;
  color: #ff4d4d;
  line-height: 1.4;
}

.auth-lockout svg {
  flex-shrink: 0;
  opacity: 0.8;
}

.auth-lockout-time {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
}

/* ── Attempt counter ── */
.auth-attempts {
  text-align: right;
  font-size: 0.72rem;
  margin-top: 8px;
  min-height: 18px;
  transition: opacity 0.25s ease, color 0.25s ease;
  opacity: 0;
}

.auth-attempts.visible { opacity: 0.6; }
.auth-attempts.warn    { opacity: 1; color: #ff9900; }
.auth-attempts.danger  { opacity: 1; color: #ff4d4d; font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  .auth-container { animation: none; }
  .auth-card { animation: none; }
  .auth-orb--1,
  .auth-orb--2 { animation: none; }
  .auth-submit .spin { animation: none; }
  .auth-field input,
  .otp-digit,
  .auth-submit { transition: none; }
}
