:root {
  --brand: #440887;
  --brand-light: #6b2fd6;
  --accent: #190685;
  --card-bg: rgba(255, 255, 255, 0.92);
  --bs-font-sans-serif: "Nunito Sans", sans-serif;
  --bs-body-font-family: var(--bs-font-sans-serif);
}

* { box-sizing: border-box; }

body.login-page,
body.login-page *:not(code):not(pre) {
  font-family: "Nunito Sans", sans-serif;
}

body.login-page {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: linear-gradient(135deg, #1a0a3e 0%, #440887 40%, #2d1b69 70%, #0f0628 100%);
  display: flex;
  flex-direction: column;
  position: relative;
}

.login-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 1.5rem;
  padding-bottom: 4rem;
  position: relative;
  z-index: 1;
}

.orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.45;
  pointer-events: none;
  z-index: 0;
}
.orb-1 { width: 320px; height: 320px; background: #8b5cf6; top: -80px; left: -60px; animation: loginFloat 12s ease-in-out infinite; }
.orb-2 { width: 280px; height: 280px; background: #3b82f6; bottom: -60px; right: -40px; animation: loginFloat 14s ease-in-out infinite reverse; }
.orb-3 { width: 200px; height: 200px; background: #ec4899; top: 40%; right: 10%; animation: loginFloat 10s ease-in-out infinite 2s; }

@keyframes loginFloat {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(20px, -25px, 0) scale(1.08); }
}

.login-scene {
  perspective: 1200px;
  width: 100%;
  max-width: 440px;
  position: relative;
  z-index: 1;
}

.login-card-3d {
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.15s ease-out, box-shadow 0.3s ease;
  border: none;
  border-radius: 1.25rem;
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow:
    0 2px 0 rgba(255,255,255,0.25) inset,
    0 25px 50px -12px rgba(0, 0, 0, 0.55),
    0 45px 80px -20px rgba(68, 8, 135, 0.5);
  overflow: hidden;
}

.login-card-3d::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--brand), var(--brand-light), #a78bfa);
}

.login-brand {
  text-align: center;
  padding: 2rem 1.5rem 0.5rem;
}

.login-brand-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  border-radius: 18px;
  background: linear-gradient(145deg, var(--brand-light), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 25px rgba(68, 8, 135, 0.45), 0 4px 0 rgba(255,255,255,0.15) inset;
}

.login-brand-icon svg {
  width: 32px;
  height: 32px;
  fill: #fff;
}

.login-brand h1 {
  font-size: 1.35rem;
  font-weight: 700;
  color: #1a1035;
  margin: 0 0 0.25rem;
  letter-spacing: -0.02em;
}

.login-brand p {
  font-size: 0.875rem;
  color: #6b7280;
  margin: 0;
}

.login-body {
  padding: 1.25rem 1.75rem 2rem;
}

.form-floating > .form-control {
  border-radius: 0.75rem;
  border: 1px solid #e5e7eb;
  background: #fafafa;
}

.form-floating > .form-control:focus {
  border-color: var(--brand-light);
  box-shadow: 0 0 0 0.2rem rgba(107, 47, 214, 0.2);
  background: #fff;
}

.login-otp-input {
  letter-spacing: 0.35em;
  font-weight: 700;
  font-size: 1.15rem;
  text-align: center;
}

.btn-login {
  border: none;
  border-radius: 0.75rem;
  padding: 0.85rem 1rem;
  font-weight: 600;
  font-size: 1rem;
  background: linear-gradient(145deg, var(--brand-light), var(--accent));
  color: #fff;
  box-shadow: 0 8px 20px rgba(25, 6, 133, 0.4), 0 2px 0 rgba(255,255,255,0.12) inset;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-login:hover {
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(25, 6, 133, 0.5), 0 2px 0 rgba(255,255,255,0.15) inset;
}

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

.login-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  font-size: 0.84rem;
}

.login-meta-row .form-check-label {
  color: #4b5563;
  font-weight: 600;
}

.login-link {
  color: var(--brand-light);
  font-weight: 700;
  text-decoration: none;
}

.login-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

.login-back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 1rem;
  font-size: 0.84rem;
  font-weight: 600;
  color: #6b7280;
  text-decoration: none;
}

.login-back:hover { color: var(--brand); }

.login-hint {
  font-size: 0.8rem;
  color: #6b7280;
  margin: 0 0 1rem;
  line-height: 1.45;
}

.login-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.5);
  padding: 1rem 1.5rem;
  margin: 0;
  z-index: 2;
  background: linear-gradient(to top, rgba(15, 6, 40, 0.85), transparent);
  pointer-events: none;
}

.side-label {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.14);
  pointer-events: none;
  user-select: none;
  z-index: 0;
  animation: labelGlow 8s ease-in-out infinite;
}
.side-label-left  { left: max(0.75rem, 2vw); }
.side-label-right { right: max(0.75rem, 2vw); animation-delay: 4s; }

@keyframes labelGlow {
  0%, 100% { opacity: 0.35; }
  50%       { opacity: 1; }
}

/* Sending overlay — CSS only spinner */
.login-card-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  padding: 1.5rem;
  text-align: center;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.login-card-overlay.is-active {
  opacity: 1;
  visibility: visible;
}

.login-spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid rgba(107, 47, 214, 0.18);
  border-top-color: var(--brand-light);
  animation: loginSpin 0.75s linear infinite;
}

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

.login-overlay-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  color: #1a1035;
}

.login-overlay-msg {
  margin: 0;
  font-size: 0.82rem;
  color: #6b7280;
  font-weight: 600;
  max-width: 16rem;
}

/* Reset OTP countdown */
.reset-timer {
  display: flex;
  align-items: center;
  gap: 0.95rem;
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
  border-radius: 0.95rem;
  background: linear-gradient(135deg, rgba(107, 76, 230, 0.1), rgba(139, 92, 246, 0.06));
  border: 1px solid rgba(107, 76, 230, 0.16);
  box-shadow: 0 6px 20px rgba(107, 76, 230, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.65);
  transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.reset-timer.is-low {
  animation: resetTimerPulse 1.1s ease-in-out infinite;
  border-color: rgba(245, 158, 11, 0.35);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), rgba(251, 191, 36, 0.06));
}

.reset-timer.is-expired {
  opacity: 0.82;
  border-color: rgba(239, 68, 68, 0.28);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(248, 113, 113, 0.05));
  animation: none;
}

@keyframes resetTimerPulse {
  0%, 100% { box-shadow: 0 6px 20px rgba(245, 158, 11, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.65); }
  50% { box-shadow: 0 8px 26px rgba(245, 158, 11, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.75); transform: translateY(-1px); }
}

.reset-timer-ring {
  flex-shrink: 0;
  filter: drop-shadow(0 4px 10px rgba(107, 76, 230, 0.2));
}

.reset-timer-ring svg {
  display: block;
  transform: rotate(-90deg);
}

.reset-timer-track {
  fill: none;
  stroke: rgba(107, 76, 230, 0.14);
  stroke-width: 4;
}

.reset-timer-progress {
  fill: none;
  stroke: url(#resetTimerGrad);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 150.8;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear;
}

.reset-timer.is-low .reset-timer-progress {
  stroke: #f59e0b;
}

.reset-timer.is-expired .reset-timer-progress {
  stroke: #ef4444;
}

.reset-timer-copy {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.reset-timer-value {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #190685;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.reset-timer.is-low .reset-timer-value {
  color: #d97706;
}

.reset-timer.is-expired .reset-timer-value {
  color: #dc2626;
}

.reset-timer-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

@media (max-width: 575.98px) {
  .login-wrapper { padding: 1rem; padding-top: 2.5rem; padding-bottom: 3.5rem; align-items: flex-start; }
  .login-brand { padding-top: 1.25rem; }
  .login-body { padding: 1rem 1.25rem 1.5rem; }
  .login-brand-icon { width: 56px; height: 56px; border-radius: 14px; }
  .orb-1, .orb-2 { opacity: 0.3; }
  .side-label { display: none; }
  .login-footer { font-size: 0.72rem; padding: 0.75rem; }
}

@media (max-width: 991.98px) {
  .side-label { font-size: 0.6rem; letter-spacing: 0.3em; }
}

@media (prefers-reduced-motion: reduce) {
  .orb, .login-card-3d, .side-label, .login-spinner, .reset-timer.is-low { animation: none !important; transition: none !important; }
  .reset-timer-progress { transition: none !important; }
}
