:root {
  --primary: #6c5ce7;
  --primary-hover: #5a4bd1;
  --primary-light: rgba(108, 92, 231, 0.15);
  --primary-subtle: rgba(108, 92, 231, 0.08);
  --primary-glow: rgba(108, 92, 231, 0.3);
  
  --bg-primary: #0a0a1a;
  --bg-secondary: #12122a;
  --bg-surface: #1a1a3e;
  --bg-elevated: #252550;
  --bg-input: rgba(255, 255, 255, 0.05);
  --bg-card: rgba(26, 26, 62, 0.9);
  
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-muted: rgba(255, 255, 255, 0.4);
  --text-placeholder: rgba(255, 255, 255, 0.3);
  
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(108, 92, 231, 0.5);
  --border-light: rgba(255, 255, 255, 0.12);
  
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.12);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 40px rgba(108, 92, 231, 0.15);
  
  --radius: 12px;
  --radius-lg: 20px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  /* REMOVED overflow: hidden to allow scrolling */
  padding: 20px 0;
}

/* Animated Background */
.bg-pattern {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: 
    radial-gradient(ellipse at 20% 50%, rgba(108, 92, 231, 0.15) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 50%, rgba(236, 72, 153, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 100%, rgba(16, 185, 129, 0.05) 0%, transparent 40%);
  pointer-events: none;
}

.bg-pattern::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: 
    radial-gradient(circle at 20% 80%, rgba(108, 92, 231, 0.03) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(236, 72, 153, 0.02) 0%, transparent 50%);
  animation: pulseGlow 8s ease-in-out infinite alternate;
}

@keyframes pulseGlow {
  0% { opacity: 0.5; }
  100% { opacity: 1; }
}

/* Loading Overlay - Dark Theme */
.modern-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 26, 0.95);
  backdrop-filter: blur(20px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  flex-direction: column;
}

.loader-content {
  text-align: center;
}

.modern-spinner {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
  gap: 12px;
}

.spinner-circle {
  width: 16px;
  height: 16px;
  background: var(--primary);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out;
  box-shadow: 0 0 20px var(--primary-glow);
}

.spinner-circle:nth-child(2) {
  animation-delay: 0.2s;
}

.spinner-circle:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-16px); }
}

.loading-text {
  font-size: 1rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.login-wrapper {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1200px;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  /* Added to ensure wrapper grows with content */
  height: auto;
}

.login-container {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  width: 100%;
  max-width: 1080px;
  background: var(--bg-card);
  backdrop-filter: blur(40px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  animation: fadeIn 0.6s ease-out;
  /* Ensure container can grow */
  height: auto;
  min-height: 0;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Left Side - Brand Panel - Dark Theme */
.brand-panel {
  background: linear-gradient(165deg, rgba(108, 92, 231, 0.15) 0%, rgba(26, 26, 62, 0.95) 50%, rgba(10, 10, 26, 0.98) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 48px;
  position: relative;
  overflow: hidden;
  border-right: 1px solid var(--border);
}

.brand-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: 
    radial-gradient(circle at 30% 40%, rgba(108, 92, 231, 0.08) 0%, transparent 60%),
    radial-gradient(circle at 70% 80%, rgba(236, 72, 153, 0.04) 0%, transparent 40%);
  pointer-events: none;
}

.brand-panel::after {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(108, 92, 231, 0.03) 0%, transparent 70%);
  animation: floatGlow 15s ease-in-out infinite alternate;
}

@keyframes floatGlow {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-30px, 30px) scale(1.2); }
}

.brand-content {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 320px;
}

.brand-logo-wrapper {
  width: 140px;
  height: 140px;
  background: var(--bg-surface);
  border-radius: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 32px;
  box-shadow: 
    0 8px 32px rgba(108, 92, 231, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  padding: 24px;
  animation: float 6s ease-in-out infinite;
  border: 1px solid var(--border);
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.brand-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 0%, #a78bfa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 40px;
}

.feature-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
}

.feature-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  border: 1px solid var(--border);
  backdrop-filter: blur(8px);
  transition: all 0.3s ease;
}

.feature-item:hover {
  background: rgba(108, 92, 231, 0.08);
  border-color: var(--primary);
  transform: translateX(4px);
}

.feature-icon {
  width: 36px;
  height: 36px;
  background: var(--primary-light);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  flex-shrink: 0;
  border: 1px solid rgba(108, 92, 231, 0.2);
}

.feature-icon svg {
  width: 18px;
  height: 18px;
}

.feature-text {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Right Side - Form - Dark Theme */
.form-section {
  padding: 56px 64px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: rgba(10, 10, 26, 0.3);
}

.form-header {
  margin-bottom: 36px;
}

.header-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--primary-subtle);
  border: 1px solid var(--border);
  border-radius: 100px;
  margin-bottom: 20px;
}

.header-badge img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.header-badge span {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
}

.form-header h1 {
  font-size: 30px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.form-header p {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Form Elements - Dark Theme */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  letter-spacing: 0.3px;
}

.input-wrapper {
  position: relative;
}

.form-control {
  width: 100%;
  padding: 13px 16px 13px 44px;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  font-weight: 400;
  transition: all 0.3s ease;
  outline: none;
}

.form-control::placeholder {
  color: var(--text-placeholder);
  font-weight: 400;
}

.form-control:hover {
  border-color: var(--border-light);
  background: rgba(255, 255, 255, 0.08);
}

.form-control:focus {
  border-color: var(--primary);
  background: rgba(108, 92, 231, 0.05);
  box-shadow: 0 0 0 4px var(--primary-light), 0 0 20px rgba(108, 92, 231, 0.1);
}

.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  transition: color 0.3s ease;
  pointer-events: none;
}

.form-control:focus ~ .input-icon {
  color: var(--primary);
}

.password-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.password-toggle:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
}

.password-toggle svg {
  width: 20px;
  height: 20px;
}

/* Options - Dark Theme */
.form-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.checkbox-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.checkbox-wrapper input[type="checkbox"] {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  background: var(--bg-input);
  appearance: none;
  cursor: pointer;
  position: relative;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.checkbox-wrapper input[type="checkbox"]:hover {
  border-color: var(--border-light);
}

.checkbox-wrapper input[type="checkbox"]:checked {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 20px var(--primary-glow);
}

.checkbox-wrapper input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 2px;
  width: 5px;
  height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.checkbox-wrapper span {
  font-size: 14px;
  color: var(--text-secondary);
}

.forgot-link {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.3s ease;
}

.forgot-link:hover {
  color: var(--primary);
  text-decoration: underline;
}

/* IP Info - Dark Theme */
.ip-info-container {
  margin-top: 20px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--border);
}

.ip-info, .location-info, .ip-error {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.ip-info svg, .location-info svg, .ip-error svg {
  color: var(--text-muted);
}

.ip-info strong, .location-info strong {
  color: var(--text-primary);
  font-weight: 600;
}

.ip-error {
  color: var(--error);
}

/* Submit Button - Dark Theme */
.btn-login {
  width: 100%;
  padding: 14px 24px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  border: none;
  border-radius: var(--radius);
  color: white;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
  box-shadow: 0 4px 20px rgba(108, 92, 231, 0.3);
}

.btn-login::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  transition: left 0.6s ease;
}

.btn-login:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(108, 92, 231, 0.4);
}

.btn-login:hover::before {
  left: 100%;
}

.btn-login:active {
  transform: translateY(0);
}

/* Loading State */
.btn-login.loading {
  pointer-events: none;
  opacity: 0.9;
}

.btn-login.loading::before {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Alerts - Dark Theme */
.alert {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: slideDown 0.3s ease;
  border: 1px solid;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.alert svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

.alert-success {
  background: var(--success-bg);
  border-color: rgba(16, 185, 129, 0.3);
  color: #34d399;
}

.alert-danger {
  background: var(--error-bg);
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
}

.alert-warning {
  background: var(--warning-bg);
  border-color: rgba(245, 158, 11, 0.3);
  color: #fbbf24;
}

/* Footer - Dark Theme */
.login-footer {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.footer-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.3s ease;
}

.footer-link:hover {
  color: var(--text-secondary);
}

.footer-link strong {
  color: var(--primary);
  font-weight: 600;
}

.footer-link svg {
  width: 14px;
  height: 14px;
}

.security-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}

.security-note svg {
  width: 14px;
  height: 14px;
}

/* Legal Links Section */
.legal-links {
  margin-top: 20px;
  text-align: center;
  padding: 16px 0 8px 0;
}

.legal-text {
  font-size: 13px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 6px;
}

.legal-link-group {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.legal-link {
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.3s ease;
  font-weight: 500;
}

.legal-link:hover {
  color: var(--primary);
  text-decoration: underline;
}

.legal-separator {
  color: var(--text-muted);
  font-size: 12px;
}

/* Adjust footer margin to accommodate legal links */
.login-footer {
  margin-top: 16px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  text-align: center;
}

/* ============================================ */
/* RESPONSIVE FIXES - SCROLLING ON MOBILE */
/* ============================================ */

/* Tablet and smaller screens */
@media (max-width: 992px) {
  body {
    padding: 16px 0;
    min-height: 100vh;
    overflow-y: auto; /* Ensure scrolling works */
  }

  .login-wrapper {
    padding: 16px;
    min-height: auto;
    height: auto;
  }

  .login-container {
    grid-template-columns: 1fr;
    max-width: 480px;
    margin: 0 auto;
    border-radius: var(--radius-lg);
    height: auto;
    min-height: 0;
  }

  .brand-panel {
    display: none;
  }

  .form-section {
    padding: 40px 32px;
    height: auto;
  }
}

/* Mobile phones */
@media (max-width: 576px) {
  body {
    padding: 12px 0;
    overflow-y: auto !important; /* Force scrolling */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
  }

  .login-wrapper {
    padding: 12px;
    min-height: 100vh;
    height: auto;
    align-items: flex-start; /* Align to top on mobile */
    padding-top: 24px;
    padding-bottom: 40px;
  }

  .login-container {
    border-radius: var(--radius);
    max-width: 100%;
    margin: 0 auto;
    height: auto;
    min-height: 0;
    border: 1px solid var(--border);
  }

  .form-section {
    padding: 28px 20px 32px;
    height: auto;
    min-height: 0;
  }

  .form-header h1 {
    font-size: 24px;
  }

  .form-header p {
    font-size: 14px;
  }

  .form-control {
    font-size: 14px;
    padding: 12px 14px 12px 40px;
  }

  .btn-login {
    padding: 13px 20px;
    font-size: 14px;
  }

  .ip-info-container {
    flex-direction: column;
    align-items: flex-start;
    padding: 10px 14px;
  }

  .ip-info, .location-info, .ip-error {
    font-size: 12px;
    width: 100%;
  }

  .form-options {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .checkbox-wrapper {
    font-size: 13px;
  }

  .forgot-link {
    font-size: 13px;
  }

  .legal-link-group {
    flex-direction: row;
    gap: 6px;
  }
  
  .legal-link {
    font-size: 12px;
  }
  
  .legal-text {
    font-size: 12px;
  }

  .login-footer {
    margin-top: 20px;
    padding-top: 16px;
  }

  .footer-link {
    font-size: 12px;
  }

  .security-note {
    font-size: 11px;
  }

  /* Make alert messages more compact on mobile */
  .alert {
    padding: 10px 14px;
    font-size: 13px;
  }

  .alert svg {
    width: 16px;
    height: 16px;
  }
}

/* Very small screens */
@media (max-width: 380px) {
  .form-section {
    padding: 20px 16px 24px;
  }

  .form-header h1 {
    font-size: 20px;
  }

  .form-control {
    font-size: 13px;
    padding: 10px 12px 10px 36px;
  }

  .btn-login {
    padding: 11px 16px;
    font-size: 13px;
  }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-hover);
}