/* ═══════════════════════════════════════════════════
   AUTH MODAL — Split Two-Panel Design
   ═══════════════════════════════════════════════════ */

/* Overlay — centered on all screens */
.auth-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
  padding: 24px;
  box-sizing: border-box;
}

.auth-modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: rgba(18, 16, 14, 0.72);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  cursor: pointer;
  pointer-events: none;
  /* Don't block modal inputs — overlay handles outside click */
}

.mobile-perf .auth-modal-backdrop {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  background: rgba(18, 16, 14, 0.88);
}

/* Light backdrop for forgot/set-new — dims background, no dark patch */
.auth-modal-backdrop-light {
  background: rgba(18, 16, 14, 0.4) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* Hide footer when forgot/set-new password modals are open */
body.auth-modal-open footer {
  visibility: hidden;
  pointer-events: none;
}

.auth-modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* Modal container — z-index above backdrop, centered, good proportions */
.auth-modal {
  position: relative;
  z-index: 1;
  pointer-events: auto;
  width: 100%;
  max-width: 920px;
  min-height: 520px;
  height: 90vh;
  max-height: 90vh;
  display: grid;
  grid-template-columns: 300px 1fr;
  grid-template-rows: minmax(0, 1fr);
  border-radius: 28px;
  overflow: hidden;
  margin: auto;
  box-shadow:
    0 0 0 1px rgba(28, 26, 24, 0.06),
    0 32px 80px rgba(18, 16, 14, 0.32),
    0 8px 24px rgba(18, 16, 14, 0.16);
  transform: scale(0.95) translateY(20px);
  transition: transform 0.42s cubic-bezier(0.16, 1, 0.3, 1);
  margin: 0 auto;
}

.auth-modal-overlay.active .auth-modal {
  transform: scale(1) translateY(0);
}

/* Compact modal - Forgot Password, Set New Password - smaller, centered, fits content */
.auth-modal-compact {
  max-width: 340px !important;
  min-width: 260px;
  min-height: auto !important;
  height: auto !important;
  width: calc(100% - 48px);
  max-height: 85vh;
  display: block !important;
  grid-template-columns: none !important;
  overflow-y: auto;
  overflow-x: hidden;
  margin: auto;
}

.auth-modal-compact .am-form-side-compact {
  padding: 24px 22px;
  overflow: visible;
}

.auth-modal-compact .am-panel-title {
  font-size: 1.25rem;
}

.auth-modal-compact .am-panel-sub {
  font-size: 0.8rem;
}

.auth-modal-compact .am-submit {
  margin-top: 14px;
}

.auth-modal-compact .am-note {
  margin-top: 14px;
}

@media (max-width: 480px) {
  .auth-modal-compact {
    width: calc(100% - 32px);
    max-height: 82vh;
    max-height: 82dvh;
  }

  .auth-modal-compact .am-form-side-compact {
    padding: 20px 18px;
  }
}

@media (max-width: 360px) {
  .auth-modal-compact {
    width: calc(100% - 24px);
    min-width: 240px;
  }

  .auth-modal-compact .am-form-side-compact {
    padding: 18px 16px;
  }
}

/* ── Close button ── */
.am-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 20;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.2s;
}

.am-close:hover {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
  transform: rotate(90deg);
}

/* ═══════════════════════════
   LEFT DECORATIVE SIDE
   ═══════════════════════════ */
.am-side {
  background: #1C1A18;
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

.am-side::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 25% 80%, rgba(212, 96, 122, 0.22) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 15%, rgba(122, 158, 135, 0.14) 0%, transparent 50%),
    radial-gradient(ellipse at 10% 20%, rgba(100, 120, 200, 0.08) 0%, transparent 45%);
  pointer-events: none;
}

.am-side-orb {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(38px);
}

.am-side-orb-1 {
  width: 180px;
  height: 180px;
  bottom: -40px;
  left: -50px;
  background: rgba(212, 96, 122, 0.18);
}

.am-side-orb-2 {
  width: 140px;
  height: 140px;
  top: 20px;
  right: -30px;
  background: rgba(122, 158, 135, 0.14);
}

.am-side-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.am-side-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 28px;
}

.am-side-logo img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.am-side-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.45rem;
  font-weight: 700;
  color: rgba(245, 239, 228, 0.96);
  line-height: 1.3;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
}

.am-side-title em {
  font-style: italic;
  color: var(--rose, #D4607A);
}

.am-side-sub {
  font-size: 0.82rem;
  color: rgba(245, 239, 228, 0.44);
  line-height: 1.55;
  margin: 0 0 auto;
}

.am-side-stats {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 28px 0 24px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 16px;
}

.am-side-stat strong {
  display: block;
  font-family: 'Cabinet Grotesk', sans-serif;
  font-size: 1.2rem;
  font-weight: 800;
  color: rgba(245, 239, 228, 0.95);
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 2px;
}

.am-side-stat span {
  font-size: 0.72rem;
  color: rgba(245, 239, 228, 0.38);
  letter-spacing: 0.02em;
}

.am-side-avatars {
  display: flex;
  gap: -6px;
  margin-bottom: 8px;
}

.am-side-avatars span {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid #1C1A18;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
  font-family: 'Cabinet Grotesk', sans-serif;
  margin-right: -8px;
  flex-shrink: 0;
}

.am-side-join {
  font-size: 0.73rem;
  color: rgba(245, 239, 228, 0.36);
  margin: 8px 0 0;
  letter-spacing: 0.01em;
}

/* ═══════════════════════════
   RIGHT FORM SIDE
   ═══════════════════════════ */
.am-form-side {
  background: var(--cream, #FAF7F2);
  padding: 36px 36px 32px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

/* Ensure all interactive elements receive clicks */
.am-form-side a,
.am-form-side button,
.am-form-side .am-tab,
.am-form-side .am-submit,
.am-form-side .am-forgot,
.am-form-side .am-social-btn {
  pointer-events: auto;
  touch-action: manipulation;
}

/* Tab switcher */
.am-tabs {
  display: flex;
  gap: 2px;
  background: rgba(28, 26, 24, 0.055);
  border-radius: 12px;
  padding: 3px;
  margin-bottom: 28px;
  width: fit-content;
}

.am-tab {
  padding: 8px 20px;
  border-radius: 9px;
  font-size: 0.83rem;
  font-weight: 700;
  color: rgba(44, 40, 36, 0.45);
  background: none;
  border: none;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  font-family: 'Cabinet Grotesk', sans-serif;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.am-tab.active {
  background: #fff;
  color: #1C1A18;
  box-shadow: 0 1px 4px rgba(28, 26, 24, 0.1), 0 2px 10px rgba(28, 26, 24, 0.05);
}

.am-tab:not(.active):hover {
  color: rgba(44, 40, 36, 0.7);
  background: rgba(28, 26, 24, 0.04);
}

/* Panel */
.am-panel {
  display: none;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}

.am-panel.active {
  display: flex;
}

.am-panel-head {
  margin-bottom: 4px;
}

.am-panel-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: #1C1A18;
  letter-spacing: -0.025em;
  margin: 0 0 5px;
  line-height: 1.2;
}

.am-panel-sub {
  font-size: 0.84rem;
  color: rgba(44, 40, 36, 0.5);
  margin: 0;
  line-height: 1.4;
}

/* Step indicator (Sign Up 2-step) */
.am-step-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

.am-step-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(28, 26, 24, 0.08);
  color: rgba(44, 40, 36, 0.4);
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
}

.am-step-dot.active {
  background: var(--rose, #D4607A);
  color: #fff;
}

.am-step-line {
  width: 24px;
  height: 2px;
  background: rgba(28, 26, 24, 0.12);
  border-radius: 1px;
}

.am-signup-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.am-submit-next {
  margin-top: 6px;
}

.am-step-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: rgba(44, 40, 36, 0.6);
  cursor: pointer;
  margin-bottom: 8px;
  padding: 6px 0;
  transition: color 0.2s;
}

.am-step-back:hover {
  color: var(--rose, #D4607A);
}

/* ── Field ── */
.am-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.am-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  color: rgba(44, 40, 36, 0.5);
  font-family: 'Cabinet Grotesk', sans-serif;
}

.am-label[for] {
  cursor: pointer;
}

.am-field-tappable {
  cursor: text;
  display: flex;
  flex-direction: column;
  gap: 6px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.am-field-tappable .am-input-wrap {
  cursor: text;
}

/* Password field — extra space for autofill/password-manager popup */
.am-password-field {
  margin-top: 20px;
}

@media (max-width: 440px) {
  .am-password-field {
    margin-top: 32px;
  }
}

.am-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.am-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.am-input-wrap:focus-within {
  z-index: 2;
}

.am-field-icon {
  position: absolute;
  left: 14px;
  color: rgba(44, 40, 36, 0.3);
  pointer-events: none;
  transition: color 0.22s;
  flex-shrink: 0;
}

.am-field:focus-within .am-field-icon {
  color: var(--rose, #D4607A);
}

.am-input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px 12px 42px;
  background: #fff;
  border: 1.5px solid rgba(28, 26, 24, 0.1);
  border-radius: 12px;
  color: #1C1A18;
  font-family: 'Cabinet Grotesk', sans-serif;
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.22s, box-shadow 0.22s, background 0.22s;
  cursor: text;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: text;
  user-select: text;
  pointer-events: auto;
  position: relative;
  z-index: 1;
  box-sizing: border-box;
}

.am-input::placeholder {
  color: rgba(44, 40, 36, 0.28);
}

.am-input:focus {
  border-color: var(--rose, #D4607A);
  background: rgba(212, 96, 122, 0.025);
  box-shadow: 0 0 0 3px rgba(212, 96, 122, 0.08);
}

/* Row for two inputs side by side */
.am-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Password toggle */
.am-pw-toggle {
  position: absolute;
  right: 12px;
  color: rgba(44, 40, 36, 0.35);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  transition: color 0.2s;
}

.am-pw-toggle:hover {
  color: #1C1A18;
}

/* Forgot password */
.am-forgot {
  font-size: 0.74rem;
  color: var(--rose, #D4607A);
  font-weight: 600;
  cursor: pointer;
  background: none;
  border: none;
  font-family: 'Cabinet Grotesk', sans-serif;
  transition: opacity 0.2s;
  padding: 0;
  white-space: nowrap;
}

.am-forgot:hover {
  opacity: 0.7;
}

/* Divider */
.am-divider {
  display: flex;
  align-items: center;
  gap: 12px;
}

.am-divline {
  flex: 1;
  height: 1px;
  background: rgba(28, 26, 24, 0.08);
}

.am-divtext {
  font-size: 0.73rem;
  color: rgba(44, 40, 36, 0.38);
  white-space: nowrap;
  font-family: 'Cabinet Grotesk', sans-serif;
}

/* Social buttons */
.am-social-row {
  display: flex;
  gap: 8px;
}

.am-social-btn {
  flex: 1;
  padding: 10px 12px;
  background: #fff;
  border: 1.5px solid rgba(28, 26, 24, 0.1);
  border-radius: 11px;
  color: #1C1A18;
  font-family: 'Cabinet Grotesk', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  transition: border-color 0.22s, box-shadow 0.22s, transform 0.22s;
  text-decoration: none;
  white-space: nowrap;
}

.am-social-btn:hover {
  border-color: rgba(28, 26, 24, 0.22);
  box-shadow: 0 4px 14px rgba(28, 26, 24, 0.07);
  transform: translateY(-1px);
}

.am-social-apple {
  flex: 0 0 auto;
  padding: 10px 18px;
}

/* Submit button */
.am-submit {
  width: 100%;
  padding: 14px 20px;
  background: #1C1A18;
  color: rgba(250, 247, 242, 0.95);
  border: none;
  border-radius: 13px;
  font-family: 'Cabinet Grotesk', sans-serif;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.3s, box-shadow 0.3s, transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  min-height: 48px;
  gap: 9px;
  box-shadow: 0 4px 16px rgba(28, 26, 24, 0.16);
  position: relative;
  overflow: hidden;
  margin-top: 2px;
}

.am-submit::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--rose, #D4607A), #C04A64);
  opacity: 0;
  transition: opacity 0.3s;
}

.am-submit:hover::after {
  opacity: 1;
}

.am-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 32px rgba(212, 96, 122, 0.28);
}

.am-submit span,
.am-submit-icon {
  position: relative;
  z-index: 1;
}

.am-submit-icon {
  transition: transform 0.3s;
}

.am-submit:hover .am-submit-icon {
  transform: translateX(4px);
}

/* Mood chips */
.am-mood-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.am-mood-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.am-mood-chip {
  padding: 5px 12px;
  border-radius: 50px;
  border: 1.5px solid rgba(28, 26, 24, 0.1);
  background: #fff;
  font-size: 0.74rem;
  font-weight: 600;
  color: rgba(44, 40, 36, 0.5);
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Cabinet Grotesk', sans-serif;
}

.am-mood-chip:hover,
.am-mood-chip.selected {
  border-color: var(--rose, #D4607A);
  color: var(--rose, #D4607A);
  background: rgba(212, 96, 122, 0.06);
}

/* Password strength bars */
.am-strength {
  display: flex;
  gap: 4px;
  margin-top: 7px;
}

.am-strength-bar {
  height: 3px;
  flex: 1;
  border-radius: 3px;
  background: rgba(28, 26, 24, 0.08);
  transition: background 0.4s;
}

.am-strength-bar.weak {
  background: #E85C5C;
}

.am-strength-bar.medium {
  background: var(--amber, #C9853A);
}

.am-strength-bar.strong {
  background: var(--sage, #7A9E87);
}

/* Footer notes */
.am-note {
  font-size: 0.76rem;
  color: rgba(44, 40, 36, 0.42);
  line-height: 1.5;
  text-align: center;
}

.am-note a {
  color: var(--rose, #D4607A);
  text-decoration: none;
  font-weight: 600;
}

.am-note a:hover {
  text-decoration: underline;
}

/* ═══════════════════════════
   RESPONSIVE
   ═══════════════════════════ */

/* Narrow modal: stack panels vertically, hide left side */
@media (max-width: 720px) {
  .auth-modal {
    grid-template-columns: 1fr;
    max-width: 520px;
    min-height: unset;
  }

  .am-side {
    display: none;
  }

  .am-form-side {
    padding: 28px 24px 28px;
    min-height: 0;
  }

  .am-tabs {
    width: 100%;
  }

  .am-tab {
    flex: 1;
    text-align: center;
  }

  .am-row {
    grid-template-columns: 1fr;
  }

  .am-social-btn {
    font-size: 0.75rem;
    padding: 9px 8px;
  }

  .am-social-apple {
    flex: 0 0 auto;
  }
}

/* Phone: centered, fits screen, scroll if needed */
@media (max-width: 440px) {
  .auth-modal-overlay {
    padding: 16px 12px;
    align-items: center;
    justify-content: center;
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .auth-modal {
    width: calc(100% - 24px);
    max-width: 420px;
    height: 85vh;
    max-height: 85vh;
    border-radius: 22px;
    overflow: hidden;
    margin: auto;
    display: flex;
    flex-direction: column;
  }

  .auth-modal .am-close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 30;
    flex-shrink: 0;
  }

  .auth-modal .am-form-side {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
  }

  .am-form-side {
    padding: 20px 18px 24px;
  }

  .am-tabs {
    margin-bottom: 20px;
    padding: 2px;
  }

  .am-tab {
    padding: 6px 14px;
    font-size: 0.78rem;
  }

  .am-panel-title {
    font-size: 1.2rem;
  }

  .am-panel-sub {
    font-size: 0.78rem;
  }

  .am-panel {
    gap: 8px;
  }

  .am-field {
    gap: 4px;
  }

  .am-divider {
    margin: 12px 0;
  }

  .am-divtext {
    font-size: 0.68rem;
  }

  /* Email/input tap fix — z-index, pointer-events, larger tap area */
  .am-form-side .am-field-tappable,
  .am-form-side .am-input-wrap,
  .am-form-side .am-input {
    position: relative;
    z-index: 2;
    pointer-events: auto;
  }

  .am-form-side .am-input {
    padding: 14px 12px 14px 38px;
    font-size: 16px;
    min-height: 48px;
    -webkit-appearance: none;
    appearance: none;
  }

  .am-field-icon {
    left: 12px;
  }

  .am-mood-row {
    gap: 6px;
  }

  .am-mood-chip {
    padding: 4px 10px;
    font-size: 0.7rem;
  }

  .am-submit {
    padding: 12px 16px;
    font-size: 0.88rem;
    touch-action: manipulation;
    min-height: 48px;
  }

  .am-social-row {
    flex-direction: column;
  }

  .am-social-btn {
    padding: 10px 12px;
    font-size: 0.78rem;
  }

  .am-social-apple {
    flex: unset;
    padding: 10px 12px;
  }

  .am-note {
    font-size: 0.72rem;
  }

  .am-close {
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
  }
}

/* Very small phones */
@media (max-width: 360px) {
  .auth-modal-overlay {
    padding: 8px;
  }

  .auth-modal {
    max-height: calc(100vh - 16px);
  }

  .am-form-side {
    padding: 16px 14px 20px;
  }

  .am-panel-title {
    font-size: 1.1rem;
  }

  .am-panel-head {
    margin-bottom: 2px;
  }
}