/* ============================================================
   AUTH / LOGIN SCREEN
   Full-screen dark background, radial glow, glassmorphism card
   ============================================================ */

/* ── Login Overlay ────────────────────────── */
#login-screen {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100dvh;
  padding: 16px 24px;
  overflow: hidden;
}


#login-screen.hidden {
  display: none;
}

/* Back button to welcome screen */
.login-back-btn {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 10;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.06);
  border: 0.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: white;
  transition: all 0.15s ease;
}

.login-back-btn:active {
  transform: scale(0.92);
}

/* ── Background Glow ─────────────────────── */
.login-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.login-bg::before {
  content: '';
  position: absolute;
  top: -20%;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(240, 192, 0, 0.12) 0%, rgba(240, 192, 0, 0.04) 40%, transparent 70%);
  border-radius: 50%;
  animation: loginGlowPulse 4s ease-in-out infinite;
}

.login-bg::after {
  content: '';
  position: absolute;
  bottom: -10%;
  left: 50%;
  transform: translateX(-50%);
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(240, 192, 0, 0.06) 0%, transparent 60%);
  border-radius: 50%;
  animation: loginGlowPulse 5s ease-in-out 1s infinite;
}

@keyframes loginGlowPulse {
  0%, 100% { opacity: 0.6; transform: translateX(-50%) scale(1); }
  50% { opacity: 1; transform: translateX(-50%) scale(1.08); }
}

/* ── Floating Particles (CSS only) ────────── */
.login-particles {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.login-particle {
  position: absolute;
  width: 2px;
  height: 2px;
  background: rgba(240, 192, 0, 0.4);
  border-radius: 50%;
  animation: particleFloat linear infinite;
}

.login-particle:nth-child(1) { left: 10%; animation-duration: 12s; animation-delay: 0s; }
.login-particle:nth-child(2) { left: 25%; animation-duration: 15s; animation-delay: 2s; width: 3px; height: 3px; background: rgba(255, 45, 85, 0.3); }
.login-particle:nth-child(3) { left: 40%; animation-duration: 10s; animation-delay: 4s; }
.login-particle:nth-child(4) { left: 55%; animation-duration: 14s; animation-delay: 1s; width: 1.5px; height: 1.5px; }
.login-particle:nth-child(5) { left: 70%; animation-duration: 11s; animation-delay: 3s; background: rgba(255, 45, 85, 0.25); }
.login-particle:nth-child(6) { left: 85%; animation-duration: 13s; animation-delay: 5s; width: 2.5px; height: 2.5px; }
.login-particle:nth-child(7) { left: 15%; animation-duration: 16s; animation-delay: 6s; width: 1px; height: 1px; background: rgba(255,255,255,0.15); }
.login-particle:nth-child(8) { left: 60%; animation-duration: 9s; animation-delay: 2.5s; background: rgba(255,255,255,0.1); }

@keyframes particleFloat {
  0% {
    transform: translateY(100vh) scale(0);
    opacity: 0;
  }
  10% {
    opacity: 1;
    transform: translateY(90vh) scale(1);
  }
  90% {
    opacity: 0.6;
  }
  100% {
    transform: translateY(-10vh) scale(0.5);
    opacity: 0;
  }
}

/* ── (ECG removed — replaced by logo PNG) ── */

/* ── Login Content ───────────────────────── */
.login-content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: visible;
}

/* ── Logo Section ────────────────────────── */
.login-logo {
  width: auto;
  height: auto;
  max-width: 140px;
  margin-bottom: 8px;
  padding-top: 0;
  flex-shrink: 0;
  display: block;
  animation: logoPulse 3s ease-in-out infinite;
}
@media (min-width: 480px) {
  .login-logo { max-width: 180px; }
}

#login-screen > *:first-child {
  margin-top: 0;
}

@media (min-width: 768px) {
  #login-screen {
    padding: 32px 24px 24px;
  }
}

@keyframes logoPulse {
  0%, 100% { filter: drop-shadow(0 0 8px rgba(240, 192, 0, 0.2)); transform: scale(1); }
  50% { filter: drop-shadow(0 0 20px rgba(240, 192, 0, 0.4)); transform: scale(1.03); }
}

.login-brand {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--red-accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}

.login-tagline {
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

/* ── Glass Form Card ─────────────────────── */
.login-card {
  width: 100%;
  background: rgba(19, 19, 26, 0.7);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 32px 28px;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.4),
    0 0 60px rgba(240, 192, 0, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* ── Autofill dark override (login) ──────── */
.login-field-input:-webkit-autofill,
.login-field-input:-webkit-autofill:hover,
.login-field-input:-webkit-autofill:focus,
.login-field-input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 30px #1C1C26 inset !important;
  -webkit-text-fill-color: white !important;
  caret-color: white;
  border-color: rgba(255,255,255,0.1) !important;
  transition: background-color 5000s ease-in-out 0s;
}

.login-title {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 24px;
  color: var(--text-primary);
}

/* ── Floating Label Inputs ───────────────── */
.login-field {
  position: relative;
  margin-bottom: 16px;
}

.login-field-input {
  width: 100%;
  padding: 20px 20px 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: #fff;
  font-size: 16px;
  font-family: var(--font-body);
  outline: none;
  transition: all 0.25s ease;
  appearance: none;
}

.login-field-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.login-field-label {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.4);
  pointer-events: none;
  transition: all 0.25s var(--ease-out-expo);
  transform-origin: left center;
}

/* Float up on focus or when input has value */
.login-field-input:focus + .login-field-label,
.login-field-input:not(:placeholder-shown) + .login-field-label {
  top: 10px;
  transform: translateY(0) scale(0.75);
  color: var(--red-accent);
  font-weight: 500;
}

.login-field-input:focus {
  border-color: #f0c000;
  box-shadow: 0 0 0 3px rgba(240, 192, 0, 0.15);
  background: rgba(255, 255, 255, 0.08);
}

.login-field-input.error {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

/* Password toggle */
.login-field-toggle {
  position: absolute;
  right: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.15s ease;
}

.login-field-toggle:hover {
  color: var(--text-secondary);
}

/* ── Error Message ───────────────────────── */
.login-error {
  display: none;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-md);
  border-radius: var(--radius-sm);
  background: var(--error-bg);
  border: 1px solid rgba(239, 68, 68, 0.2);
  font-size: 0.85rem;
  color: var(--error);
}

.login-error.visible {
  display: flex;
}

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

/* ── Login Button ────────────────────────── */
.login-btn {
  width: 100%;
  padding: 18px var(--space-lg);
  margin-top: 8px;
  background: linear-gradient(135deg, var(--red-primary), var(--red-accent));
  color: #131312;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.03em;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.25s ease;
  box-shadow: 0 4px 20px rgba(240, 192, 0, 0.25);
}

.login-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 28px rgba(240, 192, 0, 0.35);
}

.login-btn:active {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 2px 12px rgba(240, 192, 0, 0.2);
}

.login-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Loading spinner state */
.login-btn .btn-text { transition: opacity 0.2s ease; }

.login-btn .btn-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.login-btn .btn-spinner::after {
  content: '';
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: loginSpin 0.6s linear infinite;
}

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

.login-btn.loading .btn-text { opacity: 0; }
.login-btn.loading .btn-spinner { opacity: 1; }

/* Ripple on button */
.login-btn .ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: scale(0);
  animation: ripple 0.6s ease-out;
  pointer-events: none;
}

/* ── Forgot Password ─────────────────────── */
.login-forgot {
  display: block;
  text-align: center;
  margin-top: var(--space-sm);
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: color 0.2s ease;
}

.login-forgot:hover {
  color: var(--red-accent);
}

/* ── Footer ──────────────────────────────── */
.login-footer {
  margin-top: var(--space-md);
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

/* ── Error Shake Animation ───────────────── */
@keyframes loginShake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
  20%, 40%, 60%, 80% { transform: translateX(4px); }
}

.login-card.shake {
  animation: loginShake 0.5s ease-in-out;
}

/* ── Remember Me Checkbox ────────────────── */
.login-remember {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-secondary);
  -webkit-user-select: none;
  user-select: none;
}

.login-remember input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.login-remember input[type="checkbox"]:checked {
  background: var(--red-primary);
  border-color: var(--red-primary);
}

.login-remember input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* ── Welcome Screen ─────────────────────────── */
/* ── Welcome Screen ─────────────────────────── */
#welcome-screen {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: #0A0A0F;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 100dvh;
  padding: 24px;
  overflow-y: auto;
  text-align: center;
}

#welcome-screen.hidden {
  display: none !important;
}

.welcome-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 340px;
  width: 100%;
  text-align: center;
}

.welcome-logo {
  width: auto;
  height: auto;
  max-width: 60%;
  margin-bottom: 24px;
  flex-shrink: 0;
  animation: logoPulse 3s ease-in-out infinite;
}
@media (min-width: 480px) {
  .welcome-logo { max-width: 200px; }
}

.welcome-brand {
  font-family: 'Syne', sans-serif;
  font-size: 42px;
  font-weight: 900;
  letter-spacing: 0.06em;
  background: linear-gradient(135deg, #F0F0F5 0%, #f0c000 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 6px;
}

.welcome-tagline {
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 40px;
  font-family: 'DM Sans', sans-serif;
}

.welcome-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.welcome-btn {
  display: block;
  width: 100%;
  padding: 16px 24px;
  border-radius: 12px;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: all 0.25s ease;
  text-align: center;
  -webkit-appearance: none;
  appearance: none;
}

.welcome-btn-primary {
  background: linear-gradient(135deg, #f0c000, #d4a600);
  color: #fff;
  border: none;
  box-shadow: 0 4px 20px rgba(240, 192, 0, 0.3);
}

.welcome-btn-primary:active {
  transform: scale(0.97);
}

.welcome-btn-outline {
  background: transparent;
  color: #f0c000;
  border: 1.5px solid rgba(240, 192, 0, 0.4);
}

.welcome-btn-outline:active {
  background: rgba(240, 192, 0, 0.1);
}

.welcome-footer {
  margin-top: 32px;
  font-size: 10px;
  color: rgba(255,255,255,0.2);
  letter-spacing: 0.04em;
  font-family: 'DM Sans', sans-serif;
}

/* ── Login Register Link ────────────────────── */
.login-register-link {
  margin-top: 16px;
  text-align: center;
  font-size: 0.82rem;
  color: rgba(255,255,255,0.4);
  font-family: 'DM Sans', sans-serif;
}

.login-register-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 10px 24px;
  background: transparent;
  border: 1px solid rgba(240, 192, 0, 0.35);
  border-radius: 10px;
  color: #f0c000;
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.login-register-btn:active {
  background: rgba(240, 192, 0, 0.1);
}

/* ── Auth-aware visibility ───────────────── */
body.authenticated #login-screen,
body.authenticated #welcome-screen,
body.authenticated #register-shell {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
  z-index: -1 !important;
}

body:not(.authenticated) #app {
  display: none;
}

body:not(.authenticated) #splash-screen {
  display: none;
}

/* Hide admin nav for non-admins */
.nav-item[data-nav="admin"] {
  display: none !important;
}

body.role-admin .nav-item[data-nav="admin"],
body.role-superadmin .nav-item[data-nav="admin"] {
  display: flex !important;
}
