/* ===== Reset & Base ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Deep dark premium background */
  --bg-primary: #0a0a0f; 
  --bg-card: rgba(255, 255, 255, 0.03);
  --bg-card-border: rgba(255, 255, 255, 0.05);
  --bg-input: rgba(255, 255, 255, 0.04);
  --bg-input-focus: rgba(255, 255, 255, 0.08);
  
  /* Typography */
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-placeholder: #475569;
  
  /* Vibrant Accents */
  --accent: #8b5cf6;
  --accent-hover: #a78bfa;
  --accent-glow: rgba(139, 92, 246, 0.4);
  --accent-secondary: #ec4899;
  
  /* Status Colors */
  --error: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
  
  /* Spatial */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --transition: 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* ===== Light Theme ===== */
[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-card: rgba(255, 255, 255, 0.7);
  --bg-card-border: rgba(0, 0, 0, 0.08);
  --bg-input: rgba(0, 0, 0, 0.03);
  --bg-input-focus: rgba(0, 0, 0, 0.06);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-placeholder: #94a3b8;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-glow: rgba(99, 102, 241, 0.3);
  --accent-secondary: #d946ef;
  --error: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
}

[data-theme="light"] .shape {
  opacity: 0.15;
}

[data-theme="light"] .login-card {
  box-shadow:
    0 20px 40px rgba(0, 0, 0, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    inset 0 0 20px rgba(255, 255, 255, 0.5);
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: background 0.4s ease, color 0.4s ease;
}

/* ===== Animated Background ===== */
.background {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.shape {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.4;
  animation: float 20s cubic-bezier(0.4, 0, 0.2, 1) infinite alternate;
  transition: opacity 0.5s ease;
  will-change: transform;
}

.shape-1 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--accent), transparent 60%);
  top: -20%;
  left: -10%;
  animation-delay: 0s;
}

.shape-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--accent-secondary), transparent 60%);
  bottom: -20%;
  right: -10%;
  animation-delay: -5s;
}

.shape-3 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, #3b82f6, transparent 60%);
  top: 40%;
  left: 60%;
  transform: translate(-50%, -50%);
  animation-delay: -10s;
}

@keyframes float {

  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }

  25% {
    transform: translate(30px, -40px) scale(1.05);
  }

  50% {
    transform: translate(-20px, 20px) scale(0.95);
  }

  75% {
    transform: translate(15px, 35px) scale(1.03);
  }
}

/* ===== Login Container ===== */
.login-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  padding: 1rem;
  animation: fadeInUp 0.6s ease-out both;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== Login Card (Glassmorphism) ===== */
.login-card {
  background: var(--bg-card);
  backdrop-filter: blur(32px);
  -webkit-backdrop-filter: blur(32px);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  padding: 3rem 2.5rem 2.5rem;
  box-shadow:
    0 24px 48px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 0 32px rgba(255, 255, 255, 0.02);
  transition: all 0.4s ease;
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  z-index: 1;
}

/* ===== Header ===== */
.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.logo {
  display: inline-flex;
  margin-bottom: 1rem;
  animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {

  0%,
  100% {
    filter: drop-shadow(0 0 6px var(--accent-glow));
  }

  50% {
    filter: drop-shadow(0 0 18px var(--accent-glow));
  }
}

.login-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.35rem;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ===== Form ===== */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ===== Input Wrapper ===== */
.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 14px;
  color: var(--text-placeholder);
  pointer-events: none;
  transition: color var(--transition);
}

.input-wrapper input {
  width: 100%;
  padding: 0.9rem 1rem 0.9rem 2.8rem;
  background: var(--bg-input);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition:
    background var(--transition),
    border-color var(--transition),
    box-shadow var(--transition),
    transform var(--transition);
}

.input-wrapper input::placeholder {
  color: var(--text-placeholder);
  transition: opacity var(--transition);
}

.input-wrapper input:focus {
  background: var(--bg-input-focus);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
  transform: translateY(-1px);
}

.input-wrapper input:focus::placeholder {
  opacity: 0.5;
}

.input-wrapper input:focus~.input-icon,
.input-wrapper input:focus+.input-icon {
  color: var(--accent);
}

/* Focus icon color — using :has */
.input-wrapper:has(input:focus) .input-icon {
  color: var(--accent);
}

/* ===== Toggle Password ===== */
.toggle-password {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-placeholder);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  transition: color var(--transition);
}

.toggle-password:hover {
  color: var(--text-primary);
}

/* ===== Error Message ===== */
.error-message {
  display: block;
  min-height: 1.2rem;
  font-size: 0.78rem;
  color: var(--error);
  margin-top: 0.3rem;
  transition: opacity var(--transition);
}

/* ===== Animations ===== */
.stagger-1 { animation: fadeInUp 0.5s ease-out 0.1s both; }
.stagger-2 { animation: fadeInUp 0.5s ease-out 0.2s both; }
.stagger-3 { animation: fadeInUp 0.5s ease-out 0.3s both; }
.stagger-4 { animation: fadeInUp 0.5s ease-out 0.4s both; }

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

.shake {
  animation: shake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes slideDownAlert {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Form Alert ===== */
.form-alert {
  display: none;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  text-align: center;
}

.form-alert.error {
  display: block;
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.2);
  color: var(--error);
  animation: slideDownAlert 0.3s ease-out both;
}

.form-alert.success {
  display: block;
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.2);
  color: var(--success);
  animation: slideDownAlert 0.3s ease-out both;
}

/* ===== Submit Button ===== */
.btn-submit {
  position: relative;
  overflow: hidden;
  width: 100%;
  padding: 0.95rem;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition:
    transform var(--transition),
    box-shadow var(--transition),
    opacity var(--transition);
  box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-submit::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(rgba(255,255,255,0.2), transparent);
  border-radius: inherit;
  opacity: 0;
  transition: opacity var(--transition);
}

.btn-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px var(--accent-glow);
}

.btn-submit:hover::before {
  opacity: 1;
}

.btn-submit:active {
  transform: translateY(1px);
  box-shadow: 0 2px 10px var(--accent-glow);
}

.btn-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ===== Ripple Effect ===== */
.ripple {
  position: absolute;
  border-radius: 50%;
  transform: scale(0);
  animation: ripple 0.6s linear;
  background-color: rgba(255, 255, 255, 0.3);
  pointer-events: none;
}

@keyframes ripple {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* ===== Spinner ===== */
.spinner {
  animation: spin 0.8s linear infinite;
}

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

/* ===== Input Error State ===== */
.form-group.has-error .input-wrapper input {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.15);
}

/* ===== Theme Toggle Button ===== */
.theme-toggle {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
  z-index: 100;
  flex-shrink: 0;
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  transition: transform 0.4s ease;
}

.theme-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.theme-toggle:active {
  transform: scale(0.95);
}

.theme-toggle--fixed {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .login-card {
    padding: 2rem 1.25rem 1.5rem;
  }

  .login-header h1 {
    font-size: 1.3rem;
  }

  .theme-toggle--fixed {
    top: 0.75rem;
    right: 0.75rem;
    width: 36px;
    height: 36px;
  }

  .theme-toggle--fixed svg {
    width: 18px;
    height: 18px;
  }
}