/**
 * Helport AI — Full-screen login experience (scoped to #authModal only)
 * Does not affect other .auth-modal dialogs (manual, edit, onboard, etc.)
 */

/* Dedicated auth route — no scroll bleed, no dimmed app behind login */
body.auth-locked {
  overflow: hidden;
}

/* Hide dimmed app chrome — dedicated auth screen, not a floating modal */
body.auth-locked .app-shell {
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  filter: none !important;
}

body.auth-locked #authModal.auth-modal {
  pointer-events: auto;
  filter: none;
}

#authModal.auth-modal.auth-login-screen:not(.hidden) {
  display: flex !important;
  pointer-events: auto !important;
  visibility: visible !important;
  opacity: 1 !important;
}

#authModal.auth-modal.auth-login-screen.hidden,
#authModal.auth-modal.auth-login-screen.hidden.auth-login-screen {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

#authModal.auth-modal.auth-login-screen {
  position: fixed;
  inset: 0;
  z-index: 100001;
  align-items: stretch !important;
  justify-content: stretch !important;
  padding: 0 !important;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(1200px 640px at 8% 12%, rgba(16, 185, 129, 0.09), transparent 58%),
    radial-gradient(900px 520px at 92% 88%, rgba(6, 182, 212, 0.07), transparent 52%),
    #f8fafc !important;
  backdrop-filter: none !important;
}

html[data-theme='dark'] #authModal.auth-modal.auth-login-screen {
  background:
    radial-gradient(1200px 640px at 8% 12%, rgba(16, 185, 129, 0.12), transparent 58%),
    radial-gradient(900px 520px at 92% 88%, rgba(6, 182, 212, 0.08), transparent 52%),
    #0b1220 !important;
}

#authModal .auth-box.auth-box--login {
  position: relative;
  flex: 1;
  width: 100%;
  max-width: none !important;
  max-height: none !important;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0 !important;
  overflow: hidden;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
  text-align: left;
  animation: authLoginFadeIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes authLoginFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

#authModal .auth-login-theme {
  position: fixed;
  top: clamp(16px, 2.5vh, 28px);
  right: clamp(16px, 2.5vw, 32px);
  z-index: 12;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
}

html[data-theme='dark'] #authModal .auth-login-theme {
  background: rgba(17, 24, 39, 0.92);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

#authModal .auth-login-theme:hover {
  background: var(--surface-muted);
  color: var(--text);
  border-color: var(--border-strong);
}

#authModal .auth-login-theme:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

#authModal .auth-login-theme .ico-sun {
  display: none;
}

html[data-theme='dark'] #authModal .auth-login-theme .ico-moon {
  display: none;
}

html[data-theme='dark'] #authModal .auth-login-theme .ico-sun {
  display: block;
}

#authModal .auth-login-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}

#authModal .auth-login-brand {
  position: relative;
  overflow: hidden;
  padding: clamp(16px, 2.5vh, 28px) clamp(16px, 2.5vw, 32px);
  background: linear-gradient(180deg, #F7FBFA 0%, #FFFFFF 100%);
  border-right: 1px solid rgba(232, 247, 243, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#authModal .auth-login-brand-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 0;
}

#authModal .auth-login-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#authModal .auth-login-artwork {
  display: block;
  width: min(85%, 600px);
  max-width: 100%;
  max-height: min(92vh, 920px);
  height: auto;
  object-fit: contain;
  object-position: center center;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  user-select: none;
  pointer-events: none;
}

#authModal .auth-login-form-panel {
  position: relative;
  padding: clamp(32px, 5vh, 64px) clamp(28px, 5vw, 64px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.55);
}

html[data-theme='dark'] #authModal .auth-login-form-panel {
  background: rgba(11, 18, 32, 0.45);
}

#authModal .auth-login-form-inner {
  width: min(100%, 440px);
}

#authModal .auth-login-title {
  margin: 0 0 8px;
  font-size: clamp(1.55rem, 2.5vw, 1.85rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #0f172a;
  text-align: center;
}

html[data-theme='dark'] #authModal .auth-login-title {
  color: #f1f5f9;
}

#authModal .auth-login-sub {
  margin: 0 0 clamp(24px, 4vh, 36px);
  text-align: center;
  font-size: 0.95rem;
  color: var(--text-muted);
}

#authModal .auth-label {
  font-size: 0.82rem;
  margin-bottom: 8px;
  color: #334155;
}

html[data-theme='dark'] #authModal .auth-label {
  color: #94a3b8;
}

#authModal .auth-input-wrap {
  position: relative;
  margin-bottom: 20px;
}

#authModal .auth-input-wrap input {
  width: 100%;
  margin: 0;
  height: 52px;
  padding: 0 48px;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: var(--text);
  font-size: 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

html[data-theme='dark'] #authModal .auth-input-wrap input {
  background: #0f172a;
  border-color: rgba(148, 163, 184, 0.22);
}

#authModal .auth-input-wrap input:focus {
  outline: none;
  border-color: rgba(16, 185, 129, 0.55);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
}

#authModal .auth-input-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: #94a3b8;
  pointer-events: none;
  display: grid;
  place-items: center;
}

#authModal .auth-password-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s ease, color 0.15s ease;
}

#authModal .auth-password-toggle:hover {
  background: var(--surface-muted);
  color: var(--text);
}

#authModal .auth-password-toggle:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

#authModal .auth-password-toggle .auth-eye-hide {
  display: none;
}

#authModal .auth-password-toggle.is-visible .auth-eye-show {
  display: none;
}

#authModal .auth-password-toggle.is-visible .auth-eye-hide {
  display: block;
}

#authModal .auth-login-error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 18px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.45;
  color: #b91c1c;
  background: #fef2f2;
  border: 1px solid rgba(239, 68, 68, 0.22);
}

html[data-theme='dark'] #authModal .auth-login-error {
  color: #fecaca;
  background: rgba(127, 29, 29, 0.35);
  border-color: rgba(239, 68, 68, 0.28);
}

#authModal .auth-login-error[hidden] {
  display: none !important;
}

#authModal .auth-login-btn {
  width: 100%;
  height: 52px;
  margin: 6px 0 18px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #10b981 0%, #0d9488 52%, #0891b2 100%);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: 0 10px 28px rgba(13, 148, 136, 0.28);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

#authModal .auth-login-btn:hover:not(:disabled) {
  filter: brightness(1.04);
  box-shadow: 0 12px 32px rgba(13, 148, 136, 0.34);
  transform: translateY(-1px);
}

#authModal .auth-login-btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 6px 18px rgba(13, 148, 136, 0.24);
}

#authModal .auth-login-btn:disabled {
  opacity: 0.78;
  cursor: not-allowed;
}

#authModal .auth-login-btn.is-loading:disabled {
  cursor: wait;
}

#authModal .auth-login-btn.is-loading .auth-login-btn-arrow {
  display: none;
}

#authModal .auth-login-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 999px;
  animation: authLoginSpin 0.65s linear infinite;
}

#authModal .auth-login-btn.is-loading .auth-login-spinner {
  display: inline-block;
}

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

#authModal .auth-login-footnote {
  margin: 0;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-dim);
}

#authModal .auth-forgot-open {
  width: 100%;
  margin-top: 8px;
}

#authModal .auth-forgot-panel {
  margin-top: 0;
}

#authModal .auth-forgot-lead {
  margin: 0 0 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

#authModal .auth-forgot-panel input,
#authModal .auth-forgot-panel textarea {
  width: 100%;
  margin-bottom: 8px;
}

#authModal .auth-forgot-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

#authModal .auth-forgot-msg-ok {
  color: var(--ok, #15803d);
}

/* Large desktop — give artwork room without overflowing */
@media (min-width: 1400px) {
  #authModal .auth-login-artwork {
    width: min(88%, 640px);
  }

  #authModal .auth-login-form-inner {
    max-width: 460px;
  }
}

@media (max-width: 1366px) {
  #authModal .auth-login-brand {
    padding: clamp(12px, 2vh, 20px) clamp(12px, 2vw, 24px);
  }

  #authModal .auth-login-artwork {
    width: min(82%, 520px);
    max-height: min(88vh, 720px);
  }
}

/* Tablet — stacked full-screen sections */
@media (max-width: 900px) {
  #authModal .auth-login-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  #authModal .auth-login-brand {
    border-right: none;
    border-bottom: 1px solid #E8F7F3;
    padding: 20px 20px 12px;
    min-height: auto;
  }

  #authModal .auth-login-artwork {
    width: min(72%, 420px);
    max-height: 42vh;
  }

  #authModal .auth-login-form-panel {
    flex: 1;
    min-height: min(520px, 55vh);
    padding-bottom: clamp(32px, 6vh, 48px);
  }
}

@media (max-width: 480px) {
  #authModal .auth-login-brand {
    padding: 16px 16px 8px;
  }

  #authModal .auth-login-artwork {
    width: min(88%, 340px);
    max-height: 36vh;
  }

  #authModal .auth-login-form-panel {
    padding: 28px 20px 32px;
  }

  #authModal .auth-login-theme {
    top: 14px;
    right: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #authModal .auth-box.auth-box--login {
    animation: none;
  }

  #authModal .auth-login-spinner {
    animation: none;
    border-top-color: rgba(255, 255, 255, 0.65);
  }
}
