/* Login Page CSS - CSP Compliant (Fixed Visibility Issues) */

:root {
  --primary-color: #03a9f4;
  --primary-hover: #0288d1;
  --success-color: #4CAF50;
  --error-color: #f44336;
  --warning-color: #ff9800;
  --background-color: #0e0e0e;
  --surface-color: #1c1c1c;
  --text-color: #ffffff;
  --text-muted: #aaaaaa;
  --border-color: #2e2e2e;
  --border-radius: 12px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Global Reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #0e0e0e 0%, #1a1a1a 100%);
  color: var(--text-color);
  min-height: 100vh;
  line-height: 1.6;
  /* Always visible - this is the login page */
}

/* Connection Status */
.connection-status {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  z-index: 1000;
  transition: all 0.3s ease;
}

.connection-status.online {
  background: var(--success-color);
  color: white;
}

.connection-status.offline {
  background: var(--error-color);
  color: white;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.loading-overlay.show {
  opacity: 1;
  visibility: visible;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Main Container */
.container {
  max-width: 400px;
  margin: 0 auto;
  padding: 40px 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
}

/* Form Title */
h2 {
  text-align: center;
  margin-bottom: 30px;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-color);
}

/* Tab Navigation */
.tabs {
  display: flex;
  background: var(--surface-color);
  border-radius: var(--border-radius);
  padding: 4px;
  margin-bottom: 30px;
  border: 1px solid var(--border-color);
  position: relative;
  z-index: 1; /* Lower than overlay */
}

.tabs button {
  flex: 1;
  padding: 12px 20px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  cursor: pointer;
  border-radius: calc(var(--border-radius) - 4px);
  transition: all 0.3s ease;
}

.tabs button.active {
  background: var(--primary-color);
  color: white;
  box-shadow: 0 2px 8px rgba(3, 169, 244, 0.3);
}

.tabs button:hover:not(.active) {
  background: rgba(3, 169, 244, 0.1);
  color: var(--primary-color);
}

/* Forms */
.auth-form {
  background: var(--surface-color);
  padding: 30px;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
}

.auth-form.hidden {
  display: none;
}

/* Google Sign-in Button */
.google-btn {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: calc(var(--border-radius) - 2px);
  background: white;
  color: #333;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
  transition: all 0.3s ease;
}

.google-btn:hover {
  background: #f8f9fa;
  border-color: var(--primary-color);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.google-icon {
  width: 18px;
  height: 18px;
}

/* Divider */
.divider {
  text-align: center;
  margin: 20px 0;
  position: relative;
  color: var(--text-muted);
}

.divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border-color);
  z-index: 1;
}

.divider span {
  background: var(--surface-color);
  padding: 0 16px;
  position: relative;
  z-index: 2;
}

/* Form Inputs */
input[type="email"],
input[type="password"] {
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 16px;
  border: 1px solid var(--border-color);
  border-radius: calc(var(--border-radius) - 2px);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-color);
  font-size: 16px;
  transition: all 0.3s ease;
}

input[type="email"]:focus,
input[type="password"]:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(3, 169, 244, 0.1);
  background: rgba(255, 255, 255, 0.08);
}

input::placeholder {
  color: var(--text-muted);
}

/* Remember Me */
.remember-me-container {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.remember-me-container input[type="checkbox"] {
  width: auto;
  margin: 0;
  accent-color: var(--primary-color);
}

.remember-me-container label {
  color: var(--text-color);
  font-size: 14px;
  cursor: pointer;
}

/* Session Info */
.session-info {
  background: rgba(3, 169, 244, 0.1);
  border: 1px solid rgba(3, 169, 244, 0.3);
  border-radius: calc(var(--border-radius) - 4px);
  padding: 12px;
  margin-bottom: 20px;
  font-size: 13px;
  color: var(--text-color);
}

.session-info strong {
  color: var(--primary-color);
}

/* Hint Text */
.hint {
  display: block;
  margin-top: -8px;
  margin-bottom: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

/* CAPTCHA */
.captcha-wrapper {
  margin: 20px 0;
  display: flex;
  justify-content: center;
}

/* Submit Buttons */
button[type="submit"] {
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-radius: calc(var(--border-radius) - 2px);
  background: var(--primary-color);
  color: white;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-bottom: 16px;
}

button[type="submit"]:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(3, 169, 244, 0.3);
}

button[type="submit"]:disabled {
  background: #666;
  cursor: not-allowed;
  transform: none;
}

button[type="submit"].loading {
  position: relative;
  color: transparent;
}

button[type="submit"].loading::after {
  content: "Processing...";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
}

/* Links */
.forgot {
  text-align: center;
  margin-top: 16px;
}

.forgot a {
  color: var(--primary-color);
  text-decoration: none;
  font-size: 14px;
  transition: color 0.3s ease;
}

.forgot a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* Status Messages */
#status {
  margin-top: 20px;
  padding: 12px 16px;
  border-radius: calc(var(--border-radius) - 2px);
  font-weight: 500;
  text-align: center;
  min-height: 20px;
  transition: all 0.3s ease;
}

#status:empty {
  display: none;
}

/* Dynamic status styling based on content */
#status {
  background: rgba(244, 67, 54, 0.1);
  border: 1px solid var(--error-color);
  color: var(--error-color);
}

/* Success state */
#status:has-text("✅"),
#status[data-type="success"] {
  background: rgba(76, 175, 80, 0.1) !important;
  border: 1px solid var(--success-color) !important;
  color: var(--success-color) !important;
}

/* Warning state */
#status:has-text("⚠️"),
#status[data-type="warning"] {
  background: rgba(255, 152, 0, 0.1) !important;
  border: 1px solid var(--warning-color) !important;
  color: var(--warning-color) !important;
}

/* Responsive Design */
@media (max-width: 480px) {
  .container {
    padding: 20px 16px;
  }
  
  .auth-form {
    padding: 24px 20px;
  }
  
  h2 {
    font-size: 1.75rem;
  }
  
  .tabs button {
    padding: 10px 16px;
    font-size: 14px;
  }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  .auth-form,
  input[type="email"],
  input[type="password"] {
    border-width: 2px;
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .loading-spinner {
    animation: none;
  }
}

/* Print Styles */
@media print {
  .connection-status,
  .loading-overlay,
  .google-btn,
  .captcha-wrapper,
  button[type="submit"] {
    display: none;
  }
  
  body {
    background: white;
    color: black;
  }
  
  .auth-form {
    box-shadow: none;
    border: 1px solid black;
  }
}

/* Enhanced Status Messages - Add to login.css */

/* Base status styling */
#status {
  margin-top: 20px;
  padding: 12px 16px;
  border-radius: calc(var(--border-radius) - 2px);
  font-weight: 500;
  text-align: center;
  min-height: 20px;
  transition: all 0.3s ease;
  opacity: 0;
  transform: translateY(-10px);
}

#status:not(:empty) {
  opacity: 1;
  transform: translateY(0);
}

/* Error state (default) */
#status,
.status-error {
  background: rgba(244, 67, 54, 0.1);
  border: 1px solid var(--error-color);
  color: var(--error-color);
}

/* Success state */
.status-success {
  background: rgba(76, 175, 80, 0.1) !important;
  border: 1px solid var(--success-color) !important;
  color: var(--success-color) !important;
}

/* Warning state */
.status-warning {
  background: rgba(255, 152, 0, 0.1) !important;
  border: 1px solid var(--warning-color) !important;
  color: var(--warning-color) !important;
}

/* Enhanced button loading states */
button[type="submit"].loading {
  position: relative;
  color: transparent !important;
  cursor: not-allowed;
  pointer-events: none;
}

button[type="submit"].loading::after {
  content: "Processing...";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-weight: 600;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Form shake animation for errors */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
  20%, 40%, 60%, 80% { transform: translateX(4px); }
}

.auth-form.error {
  animation: shake 0.5s ease-in-out;
}

/* Enhanced focus states for better UX */
input[type="email"]:invalid:not(:focus),
input[type="password"]:invalid:not(:focus) {
  border-color: var(--error-color);
  background: rgba(244, 67, 54, 0.05);
}

input[type="email"]:valid:not(:focus),
input[type="password"]:valid:not(:focus) {
  border-color: var(--success-color);
}

/* reCAPTCHA container enhancement */
.captcha-wrapper {
  margin: 20px 0;
  display: flex;
  justify-content: center;
  transition: all 0.3s ease;
}

.captcha-wrapper.error {
  animation: shake 0.5s ease-in-out;
}

/* Status message animations */
#status {
  animation: slideInUp 0.3s ease-out;
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Enhanced loading overlay */
.loading-overlay.show {
  opacity: 1;
  visibility: visible;
  backdrop-filter: blur(2px);
}

/* Responsive improvements */
@media (max-width: 480px) {
  #status {
    font-size: 14px;
    padding: 10px 12px;
  }
  
  button[type="submit"].loading::after {
    font-size: 14px;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  #status,
  .status-error,
  .status-success,
  .status-warning {
    border-width: 2px;
    font-weight: 700;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  #status,
  .auth-form.error,
  .captcha-wrapper.error {
    animation: none;
  }
  
  button[type="submit"].loading::after {
    animation: none;
  }
}

/* Hide Sign In button from header when already on login page */
.login-page .nav-button[href="/login"] {
  display: none;
}


.form-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 10, 0.6); /* Slightly darker for better visibility */
  z-index: 9998;
  border-radius: var(--border-radius);
  display: none;
  pointer-events: all;
  backdrop-filter: blur(2px);
  transition: opacity 0.3s ease; /* Smooth transition */
}

.form-overlay.show {
  display: block;
  
}

.form-overlay::after {
  content: "Processing...";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 18px;
  font-weight: 600;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Ensure the container is positioned relatively */
.auth-form-container {
  position: relative;
  z-index: 1;
}
/* Add this to your login.css */

/* Hide forms when they have the hidden class */
.auth-form.hidden {
  display: none;
}

/* CRITICAL: Also hide containers when they have the hidden class */
.auth-form-container.hidden {
  display: none;
}

/* Optional: More generic hidden class that works on any element */
.hidden {
  display: none !important;
}

/* Error toast notification */
.error-toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #d32f2f;
  color: white;
  padding: 16px 24px;
  border-radius: 4px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  z-index: 9999;
}

