/* ===== Login page — scoped to .login-page ===== */

.login-page {
  display: block;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0;
  overflow-x: hidden;
  background: #050508;
}

/* ----- Immersive background ----- */
.auth-scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.auth-mesh {
  position: absolute;
  inset: -50%;
  background:
    radial-gradient(ellipse 80% 50% at 20% 40%, rgba(59, 130, 246, 0.35) 0%, transparent 55%),
    radial-gradient(ellipse 60% 45% at 75% 25%, rgba(139, 92, 246, 0.4) 0%, transparent 50%),
    radial-gradient(ellipse 50% 40% at 60% 80%, rgba(34, 211, 238, 0.2) 0%, transparent 45%),
    linear-gradient(160deg, #050508 0%, #0c0a14 40%, #080810 100%);
  animation: meshShift 18s ease-in-out infinite alternate;
}

@keyframes meshShift {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-2%, 1%) scale(1.04); }
}

.auth-orbs {
  position: absolute;
  inset: 0;
}

.auth-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
  will-change: transform;
}

.auth-orb-1 {
  width: min(520px, 70vw);
  height: min(520px, 70vw);
  background: #3b82f6;
  top: -12%;
  left: -8%;
  animation: orbDrift1 22s ease-in-out infinite;
}

.auth-orb-2 {
  width: min(420px, 55vw);
  height: min(420px, 55vw);
  background: #8b5cf6;
  bottom: -5%;
  right: -5%;
  animation: orbDrift2 26s ease-in-out infinite;
}

.auth-orb-3 {
  width: min(280px, 40vw);
  height: min(280px, 40vw);
  background: #22d3ee;
  top: 45%;
  left: 38%;
  animation: orbDrift3 20s ease-in-out infinite;
}

@keyframes orbDrift1 {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(40px, 30px); }
}

@keyframes orbDrift2 {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-35px, -25px); }
}

@keyframes orbDrift3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(25px, -35px) scale(1.1); }
}

.auth-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 50%, black 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 50%, black 20%, transparent 75%);
}

.auth-noise {
  position: absolute;
  inset: 0;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ----- Shell layout ----- */
.auth-shell {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: clamp(1.5rem, 4vw, 3rem);
}

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-primary);
  margin-bottom: 1.75rem;
}

.auth-brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  box-shadow: 0 8px 32px rgba(99, 102, 241, 0.45);
}

.auth-brand-icon svg {
  width: 22px;
  height: 22px;
  color: #fff;
}

.auth-brand-text {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ----- Auth panel ----- */
.auth-panel {
  width: 100%;
  max-width: 420px;
}

.auth-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  padding: 2.25rem;
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.07) 0%, rgba(255, 255, 255, 0.02) 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 24px 64px -16px rgba(0, 0, 0, 0.55),
    0 0 80px -24px rgba(99, 102, 241, 0.2);
  animation: cardIn 0.9s cubic-bezier(0.16, 1, 0.3, 1) 0.15s both;
  overflow: hidden;
}

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

.auth-card-shine {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
  opacity: 0.6;
}

.auth-header {
  margin-bottom: 1.75rem;
  text-align: center;
}

.auth-title {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.4rem;
}

.auth-subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.5;
  transition: opacity 0.3s ease;
}

.auth-subtitle.is-switching {
  opacity: 0;
}

/* Tabs */
.auth-tabs {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem;
  padding: 0.3rem;
  margin-bottom: 1.75rem;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.auth-tab {
  position: relative;
  z-index: 1;
  padding: 0.65rem 1rem;
  border: none;
  border-radius: 11px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.25s ease;
}

.auth-tab.active {
  color: var(--text-primary);
}

.auth-tab-indicator {
  position: absolute;
  top: 0.3rem;
  left: 0.3rem;
  width: calc(50% - 0.425rem);
  height: calc(100% - 0.6rem);
  border-radius: 11px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.35), rgba(139, 92, 246, 0.35));
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.25);
  transition: transform 0.35s cubic-bezier(0.34, 1.4, 0.64, 1);
  pointer-events: none;
}

.auth-tabs.signup-mode .auth-tab-indicator {
  transform: translateX(calc(100% + 0.25rem));
}

/* Form */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.auth-field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.45rem;
}

.auth-field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.auth-field-row label {
  margin-bottom: 0;
}

.auth-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-input-icon {
  position: absolute;
  left: 1rem;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
  transition: color 0.2s ease;
}

.auth-input-wrap input {
  width: 100%;
  padding: 0.95rem 3rem 0.95rem 2.85rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}

.auth-input-wrap input::placeholder {
  color: var(--text-muted);
}

.auth-input-wrap input:hover {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.45);
}

.auth-input-wrap input:focus {
  outline: none;
  border-color: rgba(139, 92, 246, 0.6);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
  background: rgba(0, 0, 0, 0.5);
}

.auth-input-wrap:focus-within .auth-input-icon {
  color: #a78bfa;
}

.auth-input-wrap.has-error input {
  border-color: rgba(239, 68, 68, 0.6);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.auth-toggle-pw {
  position: absolute;
  right: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
}

.auth-toggle-pw:hover {
  color: #a78bfa;
  background: rgba(255, 255, 255, 0.05);
}

.auth-toggle-pw svg {
  width: 18px;
  height: 18px;
}

.auth-toggle-pw .eye-closed {
  display: none;
}

.auth-toggle-pw.is-visible .eye-open {
  display: none;
}

.auth-toggle-pw.is-visible .eye-closed {
  display: block;
}

.auth-error {
  display: block;
  min-height: 1.15em;
  margin-top: 0.35rem;
  font-size: 0.78rem;
  color: var(--error);
}

.auth-strength {
  margin-top: 0.5rem;
}

.auth-strength-bar {
  height: 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  margin-bottom: 0.35rem;
}

.auth-strength-bar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 4px;
  transition: width 0.35s ease, background 0.35s ease;
}

.auth-strength-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.auth-forgot {
  border: none;
  background: none;
  padding: 0;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  color: #60a5fa;
  cursor: pointer;
  transition: color 0.2s ease;
}

.auth-forgot:hover {
  color: #a78bfa;
}

.auth-remember {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.auth-remember input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.auth-check {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  transition: all 0.2s ease;
  position: relative;
}

.auth-remember input:checked + .auth-check {
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border-color: transparent;
}

.auth-remember input:checked + .auth-check::after {
  content: '';
  position: absolute;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Submit button */
.auth-submit {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  margin-top: 0.25rem;
  padding: 1rem 1.5rem;
  border: none;
  border-radius: 14px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  box-shadow: 0 8px 28px rgba(99, 102, 241, 0.4);
}

.auth-submit-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #3b82f6 0%, #7c3aed 50%, #8b5cf6 100%);
  background-size: 200% 200%;
  animation: gradientFlow 6s ease infinite;
  transition: opacity 0.3s ease;
}

@keyframes gradientFlow {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.auth-submit:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 12px 36px rgba(99, 102, 241, 0.5);
}

.auth-submit:active:not(:disabled) {
  transform: translateY(0);
}

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

.auth-submit-text,
.auth-submit-arrow {
  position: relative;
  z-index: 1;
  transition: opacity 0.2s ease, transform 0.25s ease;
}

.auth-submit-arrow {
  width: 18px;
  height: 18px;
}

.auth-submit:hover:not(:disabled) .auth-submit-arrow {
  transform: translateX(3px);
}

.auth-submit-loader {
  display: none;
  position: absolute;
  z-index: 2;
  width: 22px;
  height: 22px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: authSpin 0.7s linear infinite;
}

.auth-submit.loading .auth-submit-text,
.auth-submit.loading .auth-submit-arrow {
  opacity: 0;
}

.auth-submit.loading .auth-submit-loader {
  display: block;
}

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

.auth-footer-note {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--text-muted);
}

/* Card tilt on mouse (applied via JS) */
.auth-card.tilt-active {
  transition: transform 0.1s ease-out;
}

/* Toast on login page */
.login-page .toast {
  top: auto;
  bottom: max(1.5rem, env(safe-area-inset-bottom));
  right: max(1.5rem, env(safe-area-inset-right));
  left: max(1.5rem, env(safe-area-inset-left));
  transform: translateY(120%);
}

.login-page .toast.show {
  transform: translateY(0);
}

/* ----- Responsive ----- */
@media (max-width: 480px) {
  .auth-card {
    padding: 1.5rem;
    border-radius: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-mesh,
  .auth-orb,
  .auth-submit-bg,
  .auth-card {
    animation: none !important;
  }

  .auth-tab-indicator {
    transition-duration: 0.01ms !important;
  }
}
