/* Modern Design System Tokens */
:root {
  --bg-dark: #070a13;
  --bg-panel: rgba(15, 22, 42, 0.75);
  --bg-card-inactive: rgba(30, 41, 59, 0.4);
  --bg-card-hover: rgba(30, 41, 59, 0.8);
  --bg-card-active: rgba(56, 189, 248, 0.08);
  
  --border-color: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.15);
  --border-active: #38bdf8;
  --border-active-grad: linear-gradient(135deg, #38bdf8 0%, #6366f1 100%);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-active: #38bdf8;
  
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #6366f1;
  
  --accent: #38bdf8;
  --danger: #f87171;
  --danger-border: rgba(248, 113, 113, 0.2);
  --danger-bg: rgba(248, 113, 113, 0.06);
  --success: #34d399;
  
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --transition-fast: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
  --shadow-glow: 0 0 25px rgba(56, 189, 248, 0.15);
  --radius-lg: 16px;
  --radius-md: 12px;
}

/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  overflow-x: hidden;
  position: relative;
}

/* Background Decorative Glowing Orbs */
.background-decor {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  z-index: -1;
  pointer-events: none;
}

.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.12;
}

.orb-1 {
  width: 400px;
  height: 400px;
  background: var(--primary-light);
  top: 10%;
  left: 10%;
  animation: orbFloat 15s ease-in-out infinite alternate;
}

.orb-2 {
  width: 500px;
  height: 500px;
  background: var(--accent);
  bottom: 10%;
  right: 10%;
  animation: orbFloat 20s ease-in-out infinite alternate-reverse;
}

@keyframes orbFloat {
  0% {
    transform: translate(0, 0) scale(1);
  }
  100% {
    transform: translate(50px, 30px) scale(1.15);
  }
}

/* Central Login Card Container */
.login-container {
  width: 100%;
  max-width: 540px;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-lg);
  z-index: 1;
}

/* Branding/Header Styling */
.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.brand-logo {
  width: 68px;
  height: 68px;
  margin: 0 auto 16px auto;
  filter: drop-shadow(0 4px 10px rgba(56, 189, 248, 0.2));
}

.brand-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: linear-gradient(135deg, #ffffff 30%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 6px;
}

.brand-subtitle {
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Form Sections */
.login-form {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.section-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.12em;
  margin-bottom: 14px;
  text-transform: uppercase;
  border-left: 2px solid var(--accent);
  padding-left: 8px;
}

/* Level Grid Styling */
.level-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.level-card {
  background: var(--bg-card-inactive);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: var(--transition-smooth);
  position: relative;
  overflow: hidden;
  outline: none;
}

/* Hover effects */
.level-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Level card badge */
.level-badge {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 3px 8px;
  border-radius: 20px;
  width: max-content;
  margin-bottom: 10px;
  letter-spacing: 0.05em;
  transition: var(--transition-fast);
}

.level-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.level-subtitle {
  font-size: 0.72rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

/* Selected Active State */
.level-card.active {
  background: var(--bg-card-active);
  border: 1px solid transparent;
  box-shadow: var(--shadow-glow);
}

/* Dynamic border on active class */
.level-card.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: var(--radius-md);
  padding: 1.5px;
  background: var(--border-active-grad);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
}

.level-card.active .level-badge {
  color: var(--text-active);
  background: rgba(56, 189, 248, 0.12);
}

.level-card.active .level-title {
  color: var(--text-active);
}

/* Accessible Focus States */
.level-card:focus-visible,
input:focus-visible,
.password-toggle-btn:focus-visible,
.login-submit-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* Inputs & Form Fields */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}

.input-group label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
}

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

.input-wrapper input {
  width: 100%;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px 14px 44px;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.95rem;
  transition: var(--transition-fast);
}

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

.input-wrapper input:hover {
  border-color: var(--border-hover);
}

.input-wrapper input:focus {
  border-color: var(--accent);
  background: rgba(15, 23, 42, 0.9);
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.08);
  outline: none;
}

/* Input Icons */
.input-icon {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
  transition: var(--transition-fast);
}

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

/* Password Toggle Button */
.password-toggle-btn {
  position: absolute;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
  border-radius: 4px;
}

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

.toggle-icon {
  width: 18px;
  height: 18px;
}

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

.section-credentials:not(.hidden) {
  animation: slideDownFadeIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.hidden {
  display: none !important;
}

/* Submit Login Button */
.login-submit-btn {
  width: 100%;
  background: var(--border-active-grad);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 16px;
  font-family: var(--font-family);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
  margin-top: 8px;
  position: relative;
  overflow: hidden;
}

.login-submit-btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: -50%;
  width: 200%;
  height: 100%;
  background: linear-gradient(
    to right,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.15) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  transform: skewX(-25deg);
  transition: 0.75s;
  opacity: 0;
}

.login-submit-btn:hover:not(:disabled)::after {
  animation: shine 1.5s infinite;
  opacity: 1;
}

.login-submit-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.login-submit-btn:active:not(:disabled) {
  transform: translateY(1px);
}

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

@keyframes shine {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

/* Spinner for Loading State */
.btn-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 8px;
}

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

/* Errors & Message Area */
.error-container {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  animation: fadeIn 0.3s ease-out;
}

.error-icon {
  width: 18px;
  height: 18px;
  color: var(--danger);
  flex-shrink: 0;
  margin-top: 1px;
}

.error-text {
  font-size: 0.82rem;
  color: var(--danger);
  line-height: 1.4;
  font-weight: 500;
}

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

/* Footer Styling */
.gateway-footer {
  text-align: center;
  margin-top: 32px;
  color: var(--text-muted);
  font-size: 0.75rem;
  line-height: 1.6;
  z-index: 1;
}

.footer-notice {
  color: var(--text-muted);
  opacity: 0.7;
  font-size: 0.7rem;
  margin-top: 4px;
}

/* Responsive Breakpoints */
@media (max-width: 480px) {
  .login-container {
    padding: 24px 20px;
  }
  
  .brand-title {
    font-size: 1.25rem;
  }
  
  .level-grid {
    grid-template-columns: 1fr; /* Stack on small mobile screens */
    gap: 10px;
  }
  
  .level-card {
    padding: 14px;
  }
}
