/* Premium auth UI — design tokens */
:root {
  --bg-deep: #0b1220;
  --bg-card: rgba(255, 255, 255, 0.06);
  --border-subtle: rgba(255, 255, 255, 0.12);
  --primary: #3b82f6;
  --accent: #06b6d4;
  --profit: #10b981;
  --loss: #ef4444;
  --text: #f8fafc;
  --muted: #94a3b8;
  --font-display: "Sora", system-ui, sans-serif;
  --font-ui: "Inter", system-ui, sans-serif;
  --radius-lg: 20px;
  --radius-md: 12px;
  --shadow-glow: 0 0 0 1px rgba(59, 130, 246, 0.15), 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  --blur-glass: 20px;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-deep);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body[data-page="login"] .auth-shell,
body[data-page="register"] .auth-shell,
body[data-page="forgot"] .auth-shell {
  animation: fadeIn 0.7s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Ambient background */
.auth-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: radial-gradient(ellipse 120% 80% at 20% 20%, rgba(59, 130, 246, 0.12), transparent 50%),
    radial-gradient(ellipse 100% 60% at 80% 60%, rgba(6, 182, 212, 0.08), transparent 45%),
    linear-gradient(180deg, #0b1220 0%, #0a0f18 100%);
  pointer-events: none;
}

.auth-bg-gradient {
  position: absolute;
  inset: -50%;
  background: conic-gradient(from 180deg at 50% 50%, rgba(59, 130, 246, 0.06), transparent 40%, rgba(6, 182, 212, 0.05), transparent 70%);
  animation: rotateSlow 120s linear infinite;
}

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

.auth-grid-lines {
  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: 64px 64px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 50%, black, transparent);
  opacity: 0.6;
}

.auth-glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
  pointer-events: none;
}

.auth-glow-orb--1 {
  width: 400px;
  height: 400px;
  background: #3b82f6;
  top: 10%;
  left: 5%;
  animation: float1 18s ease-in-out infinite;
}

.auth-glow-orb--2 {
  width: 320px;
  height: 320px;
  background: #06b6d4;
  bottom: 15%;
  right: 8%;
  animation: float2 22s ease-in-out infinite;
}

@keyframes float1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(30px, 20px) scale(1.05); }
}

@keyframes float2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-25px, -15px) scale(1.08); }
}

/* Shell */
.auth-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
  max-width: 1440px;
  margin: 0 auto;
}

/* Left — branding */
.auth-visual {
  position: relative;
  padding: clamp(2rem, 5vw, 4rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2rem;
  overflow: hidden;
}

.auth-visual-inner {
  max-width: 520px;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.auth-logo-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.35), rgba(6, 182, 212, 0.25));
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 24px rgba(59, 130, 246, 0.25);
}

.auth-logo-mark svg {
  width: 24px;
  height: 24px;
  stroke: var(--text);
}

.auth-logo-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -0.02em;
}

.auth-headline {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.75rem, 3.5vw, 2.5rem);
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin: 0 0 1rem;
  background: linear-gradient(135deg, #f8fafc 0%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-subheadline {
  font-size: 1rem;
  color: var(--muted);
  margin: 0 0 2rem;
  max-width: 420px;
  line-height: 1.65;
}

/* Mini chart */
.auth-chart-wrap {
  position: relative;
  height: 120px;
  margin-bottom: 1.5rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  padding: 1rem;
  overflow: hidden;
}

.auth-chart-svg {
  width: 100%;
  height: 100%;
}

.auth-chart-path {
  fill: none;
  stroke: url(#chartGrad);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  animation: drawChart 2.5s ease forwards 0.3s;
}

@keyframes drawChart {
  to { stroke-dashoffset: 0; }
}

/* Floating stat cards */
.auth-float-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.auth-mini-card {
  padding: 0.875rem 1rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  backdrop-filter: blur(var(--blur-glass));
  animation: cardFloat 6s ease-in-out infinite;
}

.auth-mini-card:nth-child(2) { animation-delay: -1.5s; }
.auth-mini-card:nth-child(3) { animation-delay: -3s; }
.auth-mini-card:nth-child(4) { animation-delay: -4.5s; }

@keyframes cardFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.auth-mini-card-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.auth-mini-card-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
}

.auth-mini-card-value--up { color: var(--profit); }
.auth-mini-card-value--down { color: var(--loss); }

/* Ticker */
.auth-ticker {
  display: flex;
  gap: 2rem;
  overflow: hidden;
  padding: 0.75rem 0;
  border-top: 1px solid var(--border-subtle);
  margin-top: 0.5rem;
  mask-image: linear-gradient(90deg, transparent, black 8%, black 92%, transparent);
}

.auth-ticker-track {
  display: flex;
  gap: 2rem;
  animation: ticker 40s linear infinite;
  white-space: nowrap;
}

@keyframes ticker {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.auth-ticker-item {
  font-size: 0.8125rem;
  color: var(--muted);
}

.auth-ticker-item strong {
  color: var(--text);
  font-weight: 600;
}

.auth-ticker-item .up { color: var(--profit); }
.auth-ticker-item .down { color: var(--loss); }

/* Right — form column */
.auth-form-column {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1.5rem, 4vw, 3rem);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  padding: clamp(1.75rem, 4vw, 2.5rem);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  backdrop-filter: blur(var(--blur-glass));
  -webkit-backdrop-filter: blur(var(--blur-glass));
  box-shadow: var(--shadow-glow);
  position: relative;
  overflow: hidden;
}

.auth-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.4), transparent);
}

.auth-card-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
}

.auth-card-sub {
  font-size: 0.9375rem;
  color: var(--muted);
  margin: 0 0 1.75rem;
  line-height: 1.5;
}

.auth-error {
  display: none;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #fecaca;
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
}

.auth-error.is-visible {
  display: block;
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.auth-field {
  margin-bottom: 1.125rem;
}

.auth-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

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

.auth-input-icon {
  position: absolute;
  left: 0.875rem;
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
  z-index: 1;
}

.auth-input {
  width: 100%;
  padding: 0.8125rem 0.875rem 0.8125rem 2.75rem;
  font-family: var(--font-ui);
  font-size: 0.9375rem;
  color: var(--text);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-input-wrap--toggle .auth-input {
  padding-right: 2.75rem;
}

.auth-input:focus {
  border-color: rgba(59, 130, 246, 0.5);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.auth-input::placeholder {
  color: rgba(148, 163, 184, 0.6);
}

.auth-toggle-pass {
  position: absolute;
  right: 0.5rem;
  background: none;
  border: none;
  padding: 0.35rem;
  cursor: pointer;
  color: var(--muted);
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
}

.auth-toggle-pass:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.auth-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.auth-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--muted);
  user-select: none;
}

.auth-checkbox input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--primary);
  cursor: pointer;
}

.auth-link {
  color: var(--primary);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.2s;
}

.auth-link:hover {
  color: #60a5fa;
}

.auth-btn {
  position: relative;
  width: 100%;
  padding: 0.9375rem 1.25rem;
  font-family: var(--font-ui);
  font-size: 0.9375rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #2563eb 0%, #3b82f6 50%, #0ea5e9 100%);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 4px 24px rgba(59, 130, 246, 0.35);
}

.auth-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.15) 50%, transparent 60%);
  transform: translateX(-100%);
  transition: transform 0.6s ease;
}

.auth-btn:hover:not(:disabled)::after {
  transform: translateX(100%);
}

.auth-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 32px rgba(59, 130, 246, 0.4);
}

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

.auth-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.auth-btn.is-loading {
  color: transparent;
}

.auth-btn.is-loading::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1.25rem;
  height: 1.25rem;
  margin: -0.625rem 0 0 -0.625rem;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

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

.auth-footer-text a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.auth-footer-text a:hover {
  text-decoration: underline;
}

.auth-trust {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}

/* Password strength */
.auth-strength {
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.08);
  margin-top: 0.5rem;
  overflow: hidden;
  display: none;
}

.auth-strength.is-on { display: block; }

.auth-strength-bar {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  transition: width 0.3s, background 0.3s;
}

.auth-strength-label {
  font-size: 0.6875rem;
  color: var(--muted);
  margin-top: 0.35rem;
}

/* Select */
.auth-select {
  width: 100%;
  padding: 0.8125rem 0.875rem;
  font-family: var(--font-ui);
  font-size: 0.9375rem;
  color: var(--text);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  outline: none;
  cursor: pointer;
}

.auth-select:focus {
  border-color: rgba(59, 130, 246, 0.5);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

/* Loading overlay */
.auth-loading {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(11, 18, 32, 0.75);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
}

.auth-loading.is-visible {
  display: flex;
}

.auth-loading-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(59, 130, 246, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

/* Forgot — calm block */
.auth-secure-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 1rem;
  border-radius: 16px;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

/* Toast */
.auth-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  padding: 0.875rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  z-index: 2000;
  transition: transform 0.35s ease, opacity 0.35s ease;
  opacity: 0;
  max-width: min(90vw, 400px);
  text-align: center;
}

.auth-toast.is-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.auth-toast--ok {
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #6ee7b7;
}

.auth-toast--err {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fecaca;
}

/* Responsive */
@media (max-width: 1024px) {
  .auth-shell {
    grid-template-columns: 1fr;
  }

  .auth-visual {
    min-height: auto;
    padding-bottom: 0;
    padding-top: 2rem;
  }

  .auth-visual-inner {
    max-width: none;
  }

  .auth-float-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .auth-chart-wrap {
    max-width: 100%;
  }
}

@media (max-width: 768px) {
  .auth-headline {
    font-size: 1.5rem;
  }

  .auth-float-cards {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .auth-mini-card {
    padding: 0.65rem 0.75rem;
  }

  .auth-ticker {
    font-size: 0.75rem;
  }

  .auth-form-column {
    padding: 1.25rem 1rem 2rem;
  }
}

@media (max-width: 480px) {
  .auth-visual {
    padding: 1.25rem 1rem;
  }

  .auth-float-cards {
    grid-template-columns: 1fr;
  }
}
