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

:root {
  --bg-primary: #0f0f1a;
  --bg-card: rgba(255, 255, 255, 0.05);
  --bg-card-border: rgba(255, 255, 255, 0.08);
  --bg-input: rgba(255, 255, 255, 0.06);
  --bg-input-focus: rgba(255, 255, 255, 0.1);
  --text-primary: #f0f0f5;
  --text-secondary: #9ca3af;
  --text-placeholder: #6b7280;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.35);
  --error: #f87171;
  --success: #34d399;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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;
}

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

.shape {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.5;
  animation: float 20s ease-in-out infinite;
}

.shape-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #6366f1, transparent 70%);
  top: -15%;
  left: -10%;
  animation-delay: 0s;
}

.shape-2 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, #8b5cf6, transparent 70%);
  bottom: -10%;
  right: -10%;
  animation-delay: -7s;
}

.shape-3 {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, #a78bfa, transparent 70%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: -14s;
}

@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(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem 2rem;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* ===== 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.8rem 0.8rem 0.8rem 2.75rem;
  background: var(--bg-input);
  border: 1px solid transparent;
  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);
}

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

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

.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);
}

/* ===== 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);
}

.form-alert.success {
  display: block;
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.2);
  color: var(--success);
}

/* ===== Submit Button ===== */
.btn-submit {
  width: 100%;
  padding: 0.85rem;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  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 16px var(--accent-glow);
}

.btn-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px var(--accent-glow);
}

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

.btn-submit:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

/* ===== 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);
}

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

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