/* CSS Custom Properties with Light Theme Only */
:root {
  /* Light Theme (Default) */
  --primary-bg: #ffffff;
  --secondary-bg: #e2e7ee;
  --card-bg: #ffffff;
  --accent-color: #4a90e2;
  --accent-hover: #357abd;
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --border-focus: #4a90e2;
  --error-color: #ef4444;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --border-radius: 0.75rem;
  --border-radius-sm: 0.5rem;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* Manual Light Theme Override */
[data-theme="light"] {
  --primary-bg: #ffffff;
  --secondary-bg: #e2e7ee;
  --card-bg: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

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

html {
  transition: var(--transition);
}

body {
  font-family: var(--font-family);
  background: var(--primary-bg);
  color: var(--text-primary);
  line-height: 1.6;
  margin: 0;
  padding: 0;
  transition: var(--transition);
  overflow-x: hidden;
}

/* Theme Toggle Button with Enhanced Visibility */
.theme-toggle {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  background: var(--card-bg);
  border: 2px solid var(--border-color);
  color: var(--text-primary);
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 1.25rem;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.theme-toggle:hover {
  border-color: var(--accent-color);
  transform: scale(1.05) rotate(15deg);
  box-shadow: var(--shadow-lg);
}

.theme-toggle:focus {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

.theme-toggle:active {
  transform: scale(0.95);
}

/* Login Wrapper with Dynamic Background */
.login-wrapper {
  min-height: 100vh;
  padding: 1rem;
  background: linear-gradient(135deg, var(--primary-bg) 0%, var(--secondary-bg) 100%);
  transition: var(--transition);
}

/* Smooth Theme Transition for All Elements */
* {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Login Header */
.login-header {
  margin-bottom: 2rem;
}

.login-title {
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  letter-spacing: -0.025em;
  transition: var(--transition);
}

.login-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  font-weight: 400;
  margin: 0;
  transition: var(--transition);
}

/* Login Card with Enhanced Shadow */
.login-card {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border-color);
  overflow: hidden;
  transition: var(--transition);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.login-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
}

.login-card-body {
  padding: 2.5rem;
}

/* Logo Styling with Theme Adaptation */
.logo-container {
  margin-bottom: 2rem;
}

.logo-image {
  width: 120px;
  height: 120px;
  border-radius: 20%;
  border: 2px solid var(--border-color);
  object-fit: contain;
  transition: var(--transition);
  box-shadow: var(--shadow-md);
}

.logo-image:hover {
  transform: scale(1.05);
  border-color: var(--accent-color);
  box-shadow: var(--shadow-lg);
}

/* Form Styling with Enhanced Theme Support */
.login-form {
  width: 100%;
}

.form-group {
  position: relative;
}

/* Bootstrap Form Control Overrides with Better Theme Integration */
.form-floating > .form-control,
.form-floating > .form-select {
  background: var(--secondary-bg);
  border: 2px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--border-radius-sm);
  padding: 1rem 0.75rem;
  font-size: 1rem;
  transition: var(--transition);
}

.form-floating > .form-control:focus,
.form-floating > .form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 0.2rem rgba(74, 144, 226, 0.25);
  background: var(--secondary-bg);
}

.form-floating > .form-control::placeholder {
  color: transparent;
}

.form-floating > .form-control:focus::placeholder,
.form-floating > .form-control:not(:placeholder-shown)::placeholder {
  color: var(--text-muted);
}

/* Floating Labels with Better Contrast */
.form-floating > label {
  color: var(--text-secondary);
  font-weight: 500;
  padding: 1rem 0.75rem;
  transition: var(--transition);
}

.form-floating > .form-control:focus ~ label,
.form-floating > .form-control:not(:placeholder-shown) ~ label {
  color: var(--accent-color);
  transform: scale(0.85) translateY(-0.5rem) translateX(0.15rem);
}

/* Password Toggle with Enhanced Visibility */
.password-toggle {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 0.25rem;
  transition: var(--transition);
  z-index: 10;
}

.password-toggle:hover {
  color: var(--accent-color);
  background: rgba(74, 144, 226, 0.1);
  transform: translateY(-50%) scale(1.1);
}

.password-toggle:focus {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* Form Options */
.form-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.form-check-input {
  background-color: var(--secondary-bg);
  border: 2px solid var(--border-color);
  border-radius: 0.25rem;
  transition: var(--transition);
}

.form-check-input:checked {
  background-color: var(--accent-color);
  border-color: var(--accent-color);
}

.form-check-input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 0.2rem rgba(74, 144, 226, 0.25);
}

.form-check-label {
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: var(--transition);
}

/* Login Button with Enhanced Gradients */
.login-btn {
  background: linear-gradient(135deg, var(--accent-color) 0%, var(--accent-hover) 100%);
  border: none;
  color: white;
  font-weight: 600;
  font-size: 1rem;
  padding: 0.875rem 1.5rem;
  border-radius: var(--border-radius-sm);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.login-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.login-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--accent-hover) 0%, #2563eb 100%);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.login-btn:hover::before {
  left: 100%;
}

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

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

/* Loading Spinner */
.spinner {
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid transparent;
  border-top: 2px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Error Messages with Better Visibility */
.error-message {
  color: var(--error-color);
  font-size: 0.875rem;
  margin-top: 0.5rem;
  font-weight: 500;
  display: none;
  transition: var(--transition);
}

.form-control.is-invalid {
  border-color: var(--error-color);
}

.form-control.is-invalid + .error-message {
  display: block;
}

/* Bootstrap Alert Overrides with Theme Support */
.alert {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--border-radius-sm);
  padding: 1rem;
  margin-bottom: 1rem;
  transition: var(--transition);
}

.alert-danger {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--error-color);
  color: var(--error-color);
}

.alert-icon {
  margin-right: 0.5rem;
}

/* Bootstrap Alert Close Button */
.btn-close {
  transition: var(--transition);
  filter: none;
}

/* Footer with Better Theme Integration */
.login-footer {
  margin-top: 2rem;
}

.copyright {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
  transition: var(--transition);
}

/* Enhanced links with smooth transitions */
.copyright a { 
    text-decoration: none;
    color: var(--accent-hover);
    position: relative;
    transition: all 0.3s ease;
}

.copyright a:hover {
    color: var(--accent-hover);
}

.copyright a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -2px;
    left: 0;
    background: linear-gradient(45deg, #1877f2, #42a5f5);
    transition: width 0.3s ease;
}

.copyright a:hover::after {
    width: 100%;
}

/* Responsive Design with Enhanced Mobile Experience */
@media (max-width: 768px) {
  .login-title {
    font-size: 1.875rem;
  }
  
  .login-card-body {
    padding: 1.5rem;
  }
  
  .theme-toggle {
    top: 1rem;
    right: 1rem;
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1rem;
  }
  
  .logo-image {
    width: 100px;
    height: 100px;
  }
}

@media (max-width: 480px) {
  .login-wrapper {
    padding: 0.5rem;
  }
  
  .login-title {
    font-size: 1.5rem;
  }
  
  .login-subtitle {
    font-size: 0.875rem;
  }
  
  .login-card-body {
    padding: 1rem;
  }
  
  .form-floating > .form-control,
  .form-floating > .form-select {
    padding: 0.875rem 0.75rem;
    font-size: 0.875rem;
  }
  
  .form-floating > label {
    padding: 0.875rem 0.75rem;
    font-size: 0.875rem;
  }
  
  .login-btn {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
  }
  
  .logo-image {
    width: 80px;
    height: 80px;
  }
}

@media (max-width: 320px) {
  .login-card-body {
    padding: 0.75rem;
  }
  
  .login-title {
    font-size: 1.25rem;
  }
  
  .copyright {
    font-size: 0.75rem;
  }
}

/* System Theme Change Animation */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
  
  * {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High DPI Screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .login-card {
    box-shadow: var(--shadow-xl);
  }
}

/* Focus Visible for Better Accessibility */
.form-control:focus-visible,
.login-btn:focus-visible,
.theme-toggle:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* Print Styles */
@media print {
  .theme-toggle {
    display: none;
  }
  
  .login-card {
    box-shadow: none;
    border: 1px solid #000;
  }
}
