/* ============================================
   AUTH MODAL — Premium Login UI
   ============================================ */

/* Kill legacy login elements permanently — no JS race can override these */
#google-login-btn,
#guest-badge,
.guest-badge {
  display: none !important;
  visibility: hidden !important;
  width: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
  position: absolute !important;
}

/* When logged in (class set by inline head script + api.js), hide login button */
.sb-logged-in #custom-login-btn {
  display: none !important;
}

/* Custom Login Button (replaces Google iframe) */
.btn-login-custom {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: #fff;
  border: none;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.btn-login-custom:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}
.btn-login-custom:active {
  transform: translateY(0);
}
.btn-login-custom svg {
  width: 14px;
  height: 14px;
  stroke: #fff;
  fill: none;
}

/* Auth Modal Overlay */
.auth-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}
.auth-modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

/* Auth Modal Card */
.auth-modal-card {
  background: var(--bg-surface, #ffffff);
  border: 1px solid var(--border-default, rgba(0,0,0,0.08));
  border-radius: 24px;
  width: 100%;
  max-width: 380px;
  padding: 32px 28px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.25);
  transform: scale(0.92) translateY(20px);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}
.auth-modal-overlay.show .auth-modal-card {
  transform: scale(1) translateY(0);
}

/* Close button */
.auth-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg-muted, rgba(0,0,0,0.04));
  border-radius: 50%;
  color: var(--text-secondary, #6b7280);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.auth-modal-close:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

/* Header */
.auth-modal-header {
  text-align: center;
  margin-bottom: 28px;
}
.auth-modal-logo {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  border-radius: 14px;
}
.auth-modal-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-primary, #1a1a2e);
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}
.auth-modal-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary, #6b7280);
}

/* Auth Options */
.auth-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.auth-option-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 18px;
  background: var(--bg-surface, #fff);
  border: 1.5px solid var(--border-default, rgba(0,0,0,0.1));
  border-radius: 14px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary, #1a1a2e);
  transition: all 0.25s ease;
  text-align: left;
}
.auth-option-btn:hover {
  border-color: var(--brand-primary, #6366f1);
  background: var(--brand-soft, rgba(99, 102, 241, 0.04));
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.08);
}
.auth-option-btn:active {
  transform: translateY(0);
}

.auth-option-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.auth-option-icon.google {
  background: #f3f4f6;
}
.auth-option-icon.whatsapp {
  background: rgba(37, 211, 102, 0.1);
}

.auth-option-label {
  flex: 1;
}
.auth-option-label strong {
  display: block;
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 1px;
}
.auth-option-label span {
  display: block;
  font-size: 0.75rem;
  color: var(--text-secondary, #8b8b9a);
  font-weight: 400;
}

/* Divider */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0;
  color: var(--text-secondary, #9ca3af);
  font-size: 0.75rem;
  font-weight: 500;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-default, rgba(0,0,0,0.08));
}

/* Phone Input Section */
.auth-phone-section {
  display: none;
}
.auth-phone-section.show {
  display: block;
  animation: authSlideIn 0.3s ease;
}

@keyframes authSlideIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-phone-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.auth-phone-prefix {
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: var(--bg-muted, #f3f4f6);
  border: 1.5px solid var(--border-default, rgba(0,0,0,0.1));
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary, #6b7280);
  flex-shrink: 0;
}

.auth-phone-input {
  flex: 1;
  min-width: 0;    /* Fixes input flexbox overflow */
  width: 100%;     /* Ensures it respects the flex container bounds */
  padding: 12px 14px;
  border: 1.5px solid var(--border-default, rgba(0,0,0,0.1));
  border-radius: 12px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text-primary, #1a1a2e);
  background: var(--bg-surface, #fff);
  outline: none;
  transition: border-color 0.2s;
}
.auth-phone-input:focus {
  border-color: var(--brand-primary, #6366f1);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.08);
}

/* OTP Input */
.auth-otp-row {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 12px;
}
.auth-otp-digit {
  width: 44px;
  height: 52px;
  border: 1.5px solid var(--border-default, rgba(0,0,0,0.12));
  border-radius: 12px;
  text-align: center;
  font-size: 1.3rem;
  font-weight: 800;
  font-family: inherit;
  color: var(--brand-primary, #6366f1);
  background: var(--bg-surface, #fff);
  outline: none;
  transition: all 0.2s;
  caret-color: var(--brand-primary, #6366f1);
}
.auth-otp-digit:focus {
  border-color: var(--brand-primary, #6366f1);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
  transform: scale(1.05);
}

.auth-otp-timer {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-secondary, #9ca3af);
  margin-bottom: 14px;
}
.auth-otp-timer strong {
  color: var(--brand-primary, #6366f1);
}

/* Submit buttons */
.auth-submit-btn {
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.25);
}
.auth-submit-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(99, 102, 241, 0.35);
}
.auth-submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.auth-submit-btn.loading {
  pointer-events: none;
  position: relative;
  color: transparent;
}
.auth-submit-btn.loading::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  top: 50%;
  left: 50%;
  margin: -10px 0 0 -10px;
}

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

.auth-back-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-secondary, #6b7280);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 0;
  margin-bottom: 14px;
  font-family: inherit;
  transition: color 0.2s;
}
.auth-back-btn:hover {
  color: var(--brand-primary, #6366f1);
}

/* Status message */
.auth-status {
  text-align: center;
  font-size: 0.8rem;
  padding: 8px 12px;
  border-radius: 10px;
  margin-bottom: 12px;
  display: none;
}
.auth-status.show {
  display: block;
  animation: authSlideIn 0.2s ease;
}
.auth-status.error {
  background: rgba(239, 68, 68, 0.08);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.15);
}
.auth-status.success {
  background: rgba(16, 185, 129, 0.08);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.15);
}

/* Footer */
.auth-modal-footer {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-secondary, #9ca3af);
  line-height: 1.5;
}

/* Dark mode */
.dark .auth-modal-card {
  background: var(--bg-surface, #1e293b);
  border-color: rgba(255,255,255,0.08);
}
.dark .auth-option-btn {
  background: rgba(30, 41, 59, 0.7);
  border-color: rgba(255,255,255,0.08);
}
.dark .auth-option-icon.google {
  background: rgba(255,255,255,0.08);
}
.dark .auth-phone-prefix {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.1);
}
.dark .auth-phone-input,
.dark .auth-otp-digit {
  background: rgba(30, 41, 59, 0.7);
  border-color: rgba(255,255,255,0.1);
  color: #edeef3;
}

/* Responsive */
@media (max-width: 400px) {
  .auth-modal-card {
    padding: 24px 20px;
  }
  .auth-otp-digit {
    width: 38px;
    height: 46px;
    font-size: 1.1rem;
  }
}

/* Auth Loading Overlay */
.auth-loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(12px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}
.auth-loading-overlay.show {
  opacity: 1;
  visibility: visible;
}
.auth-loading-card {
  text-align: center;
  padding: 40px;
}
.auth-loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: #8b5cf6;
  border-right-color: #6366f1;
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: authSpin 0.8s linear infinite;
}
@keyframes authSpin {
  to { transform: rotate(360deg); }
}
.auth-loading-text {
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  animation: authPulse 1.5s ease-in-out infinite;
}
@keyframes authPulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}
