/* ========================================
   AUTH MODAL STYLES
   ======================================== */

/* Auth Modal Overlay */
.auth-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 10002;
}

.auth-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Auth Modal */
.auth-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  width: 90%;
  max-width: 440px;
  max-height: 90vh;
  background: var(--panel);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 10003;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.auth-modal.active {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

:root[data-theme="dark"] .auth-modal {
  background: #1a1d26;
  border: 1px solid #2a2e3a;
}

:root[data-theme="light"] .auth-modal {
  background: #ffffff;
  border: 1px solid #e5e7eb;
}

/* Auth Modal Header */
.auth-modal-header {
  position: relative;
  padding: 20px 24px 0 24px;
  flex-shrink: 0;
}

.auth-modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s ease;
  z-index: 1;
}

.auth-modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Auth Modal Body */
.auth-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* Auth Logo */
.auth-logo {
  text-align: center;
  margin-bottom: 24px;
}

.auth-logo-img {
  height: 48px;
  width: auto;
}

/* Auth Title */
.auth-title {
  margin: 0 0 24px 0;
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
}

/* Auth Form */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth-input-group label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.auth-input-group input {
  width: 100%;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  transition: all 0.2s ease;
}

.auth-input-group input:focus {
  outline: none;
  border-color: #104fcc;
  box-shadow: 0 0 0 3px rgba(16, 79, 204, 0.1);
}

.auth-input-group input::placeholder {
  color: var(--muted);
}

:root[data-theme="dark"] .auth-input-group input {
  background: #0f0f0f;
}

:root[data-theme="light"] .auth-input-group input {
  background: #f9fafb;
}

/* Forgot Password */
.auth-forgot {
  text-align: right;
  margin-top: -8px;
}

.auth-forgot-link {
  font-size: 13px;
  color: #104fcc;
  text-decoration: none;
  font-weight: 500;
  transition: opacity 0.2s ease;
}

.auth-forgot-link:hover {
  opacity: 0.8;
}

/* Auth Buttons */
.auth-btn-primary,
.auth-btn-google {
  width: 100%;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.auth-btn-primary {
  background: #104fcc;
  color: #fff;
  margin-top: 8px;
}

.auth-btn-primary:hover {
  background: #0d3fa3;
}

.auth-btn-google {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.auth-btn-google:hover {
  background: rgba(255, 255, 255, 0.05);
}

:root[data-theme="light"] .auth-btn-google:hover {
  background: rgba(0, 0, 0, 0.03);
}

/* Divider */
.auth-divider {
  display: flex;
  align-items: center;
  margin: 24px 0;
  color: var(--muted);
  font-size: 13px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-divider span {
  padding: 0 16px;
}

/* Toggle Link */
.auth-toggle {
  text-align: center;
  margin-top: 24px;
  font-size: 14px;
  color: var(--text-secondary);
}

.auth-toggle-link {
  color: #104fcc;
  text-decoration: none;
  font-weight: 600;
  transition: opacity 0.2s ease;
}

.auth-toggle-link:hover {
  opacity: 0.8;
}

/* Mobile Responsive - Full screen on mobile like Telegram */
@media (max-width: 768px) {
  /* Block body scroll when modal is open - iOS compatible */
  body.auth-modal-open {
    overflow: hidden !important;
    touch-action: none;
  }
  
  .auth-modal-overlay.active {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
  }
  
  .auth-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    transform: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  :root[data-theme="dark"] .auth-modal {
    background: #000000;
  }

  .auth-modal.active {
    transform: none;
  }

  .auth-modal-header {
    padding: 16px 20px 0 20px;
    flex-shrink: 0;
  }

  .auth-modal-close {
    top: 16px;
    right: 16px;
  }

  .auth-modal-body {
    flex: 1;
    padding: 20px;
    padding-bottom: 60px;
    overflow-y: scroll !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
  }

  /* Different top margins for sign-in vs sign-up */
  .auth-modal[data-mode="signin"] .auth-modal-body {
    margin-top: 30px;
  }

  .auth-modal[data-mode="signup"] .auth-modal-body {
    margin-top: 50px;
  }

  .auth-title {
    font-size: 22px;
    margin-bottom: 32px;
  }

  .auth-logo {
    margin-bottom: 32px;
  }

  .auth-logo-img {
    height: 56px;
  }
}

/* Medium screens (769px - 1400px) */
@media (max-width: 1400px) and (min-width: 769px) {
  .auth-logo-img {
    height: 34px;
    width: auto;
  }

  .auth-form input,
  .auth-form label,
  .auth-form .checkbox-label,
  .auth-form .forgot-password,
  .auth-submit-btn,
  .auth-divider span,
  .auth-toggle-text,
  .auth-toggle-link {
    font-size: 13px;
  }
}

/* Dark theme scrollbar styling for auth modal */
:root[data-theme="dark"] .auth-modal-body::-webkit-scrollbar {
  width: 8px;
}

:root[data-theme="dark"] .auth-modal-body::-webkit-scrollbar-track {
  background: #1a1d26;
  border-radius: 4px;
}

:root[data-theme="dark"] .auth-modal-body::-webkit-scrollbar-thumb {
  background: #3a3f4b;
  border-radius: 4px;
}

:root[data-theme="dark"] .auth-modal-body::-webkit-scrollbar-thumb:hover {
  background: #4a4f5b;
}

/* Firefox scrollbar */
:root[data-theme="dark"] .auth-modal-body {
  scrollbar-width: thin;
  scrollbar-color: #3a3f4b #1a1d26;
}

/* Auth Error Message */
.auth-error-message {
  background: rgba(255, 71, 87, 0.1);
  border: 1px solid rgba(255, 71, 87, 0.3);
  color: #ff4757;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
  display: none;
}

/* Loading Spinner */
.loading-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

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

@keyframes slideIn {
  from { transform: translateX(100px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100px); opacity: 0; }
}

/* Hide reCAPTCHA v3 badge (Google allows this with disclosure text) */
.grecaptcha-badge {
  visibility: hidden !important;
  opacity: 0 !important;
  position: absolute !important;
  right: -9999px !important;
}

/* reCAPTCHA v2 container */
.recaptcha-container {
  display: flex;
  justify-content: center;
  margin: 16px 0;
  transform: scale(0.9);
  transform-origin: center;
}

/* Terms notice under signup button */
.auth-terms-notice {
  font-size: 12px;
  color: #71717a;
  text-align: center;
  margin-top: 12px;
  line-height: 1.5;
}

.auth-terms-notice a {
  color: #3b82f6;
  text-decoration: none;
}

.auth-terms-notice a:hover {
  text-decoration: underline;
}

/* reCAPTCHA disclosure text */
.recaptcha-notice {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 12px;
  line-height: 1.4;
}

.recaptcha-notice a {
  color: var(--accent);
  text-decoration: none;
}

.recaptcha-notice a:hover {
  text-decoration: underline;
}
