:root {
  --primary: #818cf8;
  --primary-hover: #6366f1;
  --primary-deep: #4f46e5;
  --accent: #a78bfa;
  --accent-light: #c4b5fd;
  --bg-base: #0b0e18;
  --bg-card: rgba(12, 16, 30, 0.82);
  --text-primary: #ffffff;
  --text-secondary: #c4cde0;
  --text-tertiary: #6e7a94;
  --border: rgba(255, 255, 255, 0.08);
  --input-bg: rgba(255, 255, 255, 0.04);
  --input-border: rgba(255, 255, 255, 0.08);
  --error-color: #f87171;
  --error-bg: rgba(248, 113, 113, 0.08);
  --error-border: rgba(248, 113, 113, 0.2);
  --success-color: #34d399;
  --radius: 12px;
  --radius-lg: 20px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
}

/* ─── Full-page layout ─── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

/* ─── Animated background ─── */
.auth-background {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 60% at 30% 20%, rgba(99, 102, 241, 0.10) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 70% 80%, rgba(139, 92, 246, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 50% 50%, rgba(6, 182, 212, 0.04) 0%, transparent 60%),
    linear-gradient(135deg, #080a14 0%, #0d1020 30%, #10132a 60%, #0b0e18 100%);
  background-size: 100% 100%, 100% 100%, 100% 100%, 300% 300%;
  animation: bgShift 25s ease infinite;
}

@keyframes bgShift {
  0%, 100% { background-position: 0% 0%, 100% 100%, 50% 50%, 0% 0%; }
  33% { background-position: 100% 20%, 0% 80%, 30% 70%, 50% 50%; }
  66% { background-position: 40% 100%, 60% 0%, 70% 30%, 100% 100%; }
}

.bg-gradient-1, .bg-gradient-2 {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  animation: orbFloat 20s ease-in-out infinite;
}

.bg-gradient-1 {
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.4) 0%, transparent 70%);
  top: -200px; right: -150px;
  opacity: 0.25;
}

.bg-gradient-2 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.35) 0%, transparent 70%);
  bottom: -200px; left: -200px;
  opacity: 0.20;
  animation-delay: -10s;
  animation-duration: 25s;
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(40px, -30px) scale(1.08); }
  66% { transform: translate(-30px, 40px) scale(0.95); }
}

.bg-pattern {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(99, 102, 241, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99, 102, 241, 0.025) 1px, transparent 1px);
  background-size: 50px 50px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 50%, black 0%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 50% 50%, black 0%, transparent 70%);
  animation: gridPulse 8s ease-in-out infinite alternate;
}

@keyframes gridPulse {
  0% { opacity: 0.3; } 100% { opacity: 0.7; }
}

/* ─── Auth container ─── */
.auth-container {
  width: 100%;
  max-width: 440px;
  position: relative;
  z-index: 2;
}

.auth-box {
  background: var(--bg-card);
  backdrop-filter: blur(40px) saturate(1.2);
  -webkit-backdrop-filter: blur(40px) saturate(1.2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(99, 102, 241, 0.05);
  animation: cardIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.auth-box-register {
  max-width: 540px;
  margin: 0 auto;
}

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

/* ─── Header ─── */
.auth-header {
  text-align: center;
  margin-bottom: 28px;
}

.logo-placeholder {
  display: inline-flex;
  margin-bottom: 16px;
  animation: logoFloat 4s ease-in-out infinite;
}

.logo-placeholder img {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(99, 102, 241, 0.3));
}

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

.auth-header h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
  background: linear-gradient(135deg, #e0e7ff, #c7d2fe, #a5b4fc, #818cf8);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: titleShimmer 6s ease-in-out infinite;
}

@keyframes titleShimmer {
  0%, 100% { background-position: 0% center; }
  50% { background-position: 200% center; }
}

.subtitle {
  font-size: 14px;
  color: var(--text-tertiary);
  font-weight: 400;
}

/* ─── Error message ─── */
.error-message {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--error-color);
  font-size: 13px;
  font-weight: 500;
  animation: shake 0.4s ease;
}

.error-message svg { flex-shrink: 0; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

/* ─── Form ─── */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

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

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-left: 2px;
}

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

.input-icon {
  position: absolute;
  left: 14px;
  color: var(--text-tertiary);
  pointer-events: none;
  transition: all 0.2s;
  z-index: 1;
  width: 18px;
  height: 18px;
}

.input-wrapper input {
  width: 100%;
  padding: 12px 14px 12px 42px;
  background: var(--input-bg);
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: all 0.2s;
  outline: none;
}

.input-wrapper input::placeholder {
  color: var(--text-tertiary);
  font-size: 13px;
}

.input-wrapper input:focus {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.12);
}

.input-wrapper.focused .input-icon {
  color: var(--primary);
  transform: scale(1.05);
}

.input-wrapper.valid input { border-color: var(--success-color); }
.input-wrapper.invalid input { border-color: var(--error-color); }

.field-hint {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-left: 2px;
}

/* ─── Captcha ─── */
.captcha-wrapper {
  display: flex;
  justify-content: center;
  padding: 4px 0;
}

.h-captcha {
  transform-origin: center;
  animation: scaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) 0.2s both;
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

/* ─── Submit button ─── */
.btn-primary {
  position: relative;
  width: 100%;
  padding: 13px 20px;
  background: linear-gradient(135deg, var(--primary-deep), var(--accent));
  border: none;
  border-radius: var(--radius);
  color: white;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.25s;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.3);
  margin-top: 4px;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.4);
  filter: brightness(1.1);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary span, .btn-primary .btn-arrow {
  position: relative;
  z-index: 1;
}

.btn-arrow { transition: transform 0.2s; }
.btn-primary:hover .btn-arrow { transform: translateX(3px); }

.btn-primary.loading {
  pointer-events: none;
  opacity: 0.7;
}

.btn-primary.loading .btn-arrow {
  animation: spin 0.8s linear infinite;
}

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

/* ─── Footer ─── */
.auth-footer {
  text-align: center;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.auth-footer p {
  color: var(--text-tertiary);
  font-size: 13px;
}

.link-primary {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  transition: all 0.2s;
}

.link-primary:hover {
  color: var(--accent-light);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .auth-container { max-width: 100%; }
  .auth-box { padding: 28px 22px; }
  .auth-box-register { max-width: 100%; }
  .auth-header h1 { font-size: 22px; }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .auth-page { padding: 16px; }
  .auth-box { padding: 24px 18px; border-radius: 16px; }
  .auth-header { margin-bottom: 22px; }
  .auth-header h1 { font-size: 20px; }
  .subtitle { font-size: 13px; }
  .input-wrapper input { padding: 11px 12px 11px 40px; font-size: 14px; }
  .btn-primary { padding: 12px 16px; font-size: 14px; }
}

/* ─── Accessibility ─── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

input:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.input-wrapper.loading::after {
  content: '';
  position: absolute;
  right: 14px;
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(129, 140, 248, 0.2); border-radius: 3px; }
