/* VoteHub Auth Modal — 1:1 port of election-simulator-vh's SignInModal.css,
   made self-contained: the CSS variables it needs are defined on the scrim
   (light + [data-theme="dark"]) so it works on any page without depending on
   auth-styles.css, and every rule is scoped under .auth-modal to avoid leaking
   into the host theme. */

.auth-modal__scrim {
  /* ----- Theme tokens (light) ----- */
  --overlay-scrim: rgba(9, 10, 16, 0.6);
  --bg-elevated: #ffffff;
  --bg-surface: #eef0f7;
  --stroke-soft: #e5e5e5;
  --text-primary: #1a1a1a;
  --text-secondary: #4a4a4a;
  --text-muted: #737373;
  --menu-item-hover: #eef0f7;
  --field-border: #d2d2d7;
  --field-text: #1a1a1a;
  --field-focus: #c9b6ff;
  --field-placeholder: #737373;
  --disabled-bg: #f0f0f0;
  --disabled-text: #c7c7c7;
  --disabled-border: #e0e0e0;
  --primary-bg: #7c3aed;
  --primary-bg-hover: #6a2fdb;
  --primary-text: #ffffff;
  --accent-text-primary: #351c71;
  --accent-text-secondary: #7c3aed;
  --constructive-bg: #2ab56f;
  --constructive-text: #ffffff;
  --constructive-focus: #a7f3d0;
  --destructive-bg: #dc2626;
  --destructive-text: #ffffff;
  --destructive-focus: #fca5a5;
  --vh-text-sm: 0.875rem;
  --vh-text-xs: 0.75rem;
  --vh-text-xxs: 0.6875rem;
  --vh-button-radius-sm: 6px;

  position: fixed;
  inset: 0;
  /* Sit above any site header/nav and other fixed chrome. */
  z-index: 2147483000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: var(--overlay-scrim);
  padding: 32px 16px;
  /* Long forms (signup) scroll the overlay rather than boxing the card. */
  overflow-y: auto;

  /* ── Open/close animation ── */
  opacity: 0;
  transition: opacity 0.2s ease;
}

[data-theme="dark"] .auth-modal__scrim {
  --overlay-scrim: rgba(3, 4, 8, 0.72);
  --bg-elevated: #2a2a30;
  --bg-surface: #1d1d22;
  --stroke-soft: #3a3a3a;
  --text-primary: #f9f9f9;
  --text-secondary: #c9c9c9;
  --text-muted: #8b8b8b;
  --menu-item-hover: rgba(167, 139, 250, 0.16);
  --field-border: #3a3a3a;
  --field-text: #f9f9f9;
  --field-focus: #a78bfa;
  --field-placeholder: #8b8b8b;
  --disabled-bg: #1a1a1e;
  --disabled-text: #5f5f5f;
  --disabled-border: #26262c;
  --primary-bg: #7c3aed;
  --primary-bg-hover: #8e54ff;
  --primary-text: #fffff0;
  --accent-text-primary: #7c3aed;
  --accent-text-secondary: #a78bfa;
  --constructive-bg: #2ab56f;
  --constructive-text: #ffffff;
  --constructive-focus: #6ee7b7;
  --destructive-bg: #ef4444;
  --destructive-text: #ffffff;
  --destructive-focus: #fca5a5;
}

.auth-modal__scrim.is-open {
  opacity: 1;
}

.auth-modal__scrim .auth-modal.auth-container {
  max-width: 440px;
  width: 100%;
  padding: 0;
  min-height: 0;
  margin: auto 0;
}

.auth-modal .auth-card {
  position: relative;
  background-color: var(--bg-elevated);
  border-radius: 16px;
  border: 1px solid var(--stroke-soft);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  width: 100%;
  padding: 2.5rem 2rem;
  box-sizing: border-box;

  /* ── Open/close animation ── */
  opacity: 0;
  transform: translateY(6px) scale(0.98);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.auth-modal .auth-card.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.auth-modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  padding: 4px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.auth-modal__close:hover {
  color: var(--text-primary);
  background: var(--menu-item-hover, var(--bg-surface));
}

/* ── Expand/compress animation between sign-in and sign-up ── */
.auth-modal .auth-form-wrapper {
  position: relative;
  overflow: hidden;
  transition: height 0.28s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.auth-modal .form-section {
  display: block;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.auth-modal .form-section--active {
  position: relative;
  opacity: 1;
  transform: scaleY(1);
  transform-origin: top center;
}

.auth-modal .form-section--inactive {
  opacity: 0;
  transform: scaleY(0.92);
  pointer-events: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
}

/* ── Form styling (ported from auth-styles.css) ── */

.auth-modal .auth-header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-modal .auth-header__logo {
  display: block;
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.auth-modal .auth-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin: 0;
}

.auth-modal .form-group {
  margin-bottom: 1.5rem;
  width: 100%;
}

.auth-modal .form-group__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.auth-modal .form-group__row .form-label {
  margin-bottom: 0;
}

.auth-modal .form-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.auth-modal .form-row .form-group {
  margin-bottom: 0;
  flex: 1;
}

.auth-modal .form-label {
  display: block;
  font-size: var(--vh-text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.auth-modal .form-input {
  width: 100%;
  padding: 0.85rem 1rem;
  font-family: inherit;
  font-size: var(--vh-text-sm);
  border: 1px solid var(--field-border);
  border-radius: 12px;
  background-color: var(--bg-elevated);
  color: var(--field-text);
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

.auth-modal .form-input:focus {
  outline: none;
  border-color: var(--field-focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--field-focus) 20%, transparent);
}

.auth-modal .form-input::placeholder {
  color: var(--field-placeholder);
}

.auth-modal .form-input:disabled {
  cursor: not-allowed;
  background-color: var(--disabled-bg);
  color: var(--disabled-text);
  border-color: var(--disabled-border);
}

.auth-modal .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: var(--vh-text-sm);
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
  transition: background-color 0.2s;
  text-decoration: none;
  border: none;
  padding: 0.75rem 1.25rem;
}

.auth-modal .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.auth-modal .btn-primary {
  background-color: var(--primary-bg);
  color: var(--primary-text);
  width: 100%;
  padding: 0.875rem 1.25rem;
}

.auth-modal .btn-primary:hover:not(:disabled) {
  background-color: var(--primary-bg-hover);
}

.auth-modal .form-footer {
  text-align: center;
  margin-top: 1.5rem;
}

.auth-modal .form-footer p {
  font-size: var(--vh-text-sm);
  color: var(--text-muted);
  margin: 0;
}

.auth-modal .form-link {
  display: inline;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--accent-text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: inherit;
  cursor: pointer;
  transition: color 0.2s;
}

.auth-modal .form-link:hover {
  color: var(--accent-text-primary);
  text-decoration: underline;
}

.auth-modal .forgot-password {
  padding: 0;
  border: none;
  background: transparent;
  font-size: var(--vh-text-sm);
  color: var(--accent-text-secondary);
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s;
}

.auth-modal .forgot-password:hover {
  color: var(--accent-text-primary);
  text-decoration: underline;
}

.auth-modal .alert {
  padding: 0.75rem 1rem;
  border-radius: var(--vh-button-radius-sm);
  margin-top: 1rem;
  font-size: var(--vh-text-sm);
  font-weight: 500;
}

.auth-modal .alert[hidden] {
  display: none;
}

.auth-modal .alert-success {
  background-color: color-mix(in srgb, var(--constructive-bg) 15%, transparent);
  border: 1px solid var(--constructive-focus);
  color: var(--constructive-bg);
}

.auth-modal .alert-error {
  background-color: color-mix(in srgb, var(--destructive-bg) 15%, transparent);
  border: 1px solid var(--destructive-focus);
  color: var(--destructive-bg);
}

/* Compact four-segment password-strength meter. */
.auth-modal .password-strength {
  margin-top: 0.5rem;
}

.auth-modal .password-strength__meter {
  display: flex;
  gap: 4px;
}

.auth-modal .password-strength__seg {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background-color: var(--stroke-soft);
  transition: background-color 0.2s ease;
}

.auth-modal .password-strength__seg.is-filled {
  background-color: var(--constructive-bg);
}

.auth-modal .password-strength__hint {
  margin: 0.4rem 0 0;
  font-size: var(--vh-text-xs);
  color: var(--text-muted);
}

@media (max-width: 480px) {
  .auth-modal .auth-card {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
}

.auth-modal .auth-header__logo {
  font-size: 1.65rem;
}

/* ==========================================================================
   Upgrade to VoteHub Pro modal (shares the scrim/card/button/alert above)
   Ported from election-simulator-vh/src/components/UpgradeModal.css.
   ========================================================================== */

.auth-modal .upgrade-card {
  text-align: center;
}

.auth-modal .upgrade-card__header {
  margin-bottom: 1.5rem;
}

.auth-modal .upgrade-card__title {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  margin: 0 0 0.75rem;
}

.auth-modal .upgrade-card__subtitle {
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--text-muted);
  margin: 0 auto;
  max-width: 30ch;
}

/* ── Billing toggle ── */
.auth-modal .upgrade-billing {
  display: flex;
  gap: 0.3rem;
  padding: 0.3rem;
  margin-bottom: 2.5rem;
  border: 1px solid var(--stroke-soft);
  border-radius: 14px;
  background: var(--bg-surface);
}

.auth-modal .upgrade-billing__option {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.6rem 0.75rem;
  font-family: inherit;
  font-size: var(--vh-text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.auth-modal .upgrade-billing__option.is-active {
  color: var(--text-primary);
  background: var(--bg-elevated);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.auth-modal .upgrade-billing__option:not(.is-active):hover {
  color: var(--text-primary);
}

.auth-modal .upgrade-billing__save {
  padding: 0.12rem 0.4rem;
  font-size: var(--vh-text-xxs, 0.6875rem);
  line-height: 1.3;
  font-size: 10px;
  color: var(--primary-text);
  background: var(--primary-bg);
  border-radius: 999px;
}

/* ── Price ── */
.auth-modal .upgrade-price {
  margin-bottom: 2.5rem;
}

.auth-modal .upgrade-price__main {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.3rem;
}

.auth-modal .upgrade-price__amount {
  font-size: 2.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--text-primary);
}

.auth-modal .upgrade-price__period {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-muted);
}

.auth-modal .upgrade-price__note {
  display: block;
  text-align: center;
  margin-top: 0.5rem;
  font-size: var(--vh-text-sm);
  color: var(--text-muted);
}

/* ── CTA ── */
.auth-modal .upgrade-cta {
  font-size: 1rem;
  padding: 0.95rem 1.25rem;
}

.auth-modal .upgrade-cta:disabled {
  background-color: var(--disabled-bg);
  color: var(--disabled-text);
  border-color: var(--disabled-border);
}

.auth-modal .upgrade-signin {
  margin: 0.9rem 0 0;
  text-align: center;
  font-size: var(--vh-text-sm);
  color: var(--text-muted);
}

.auth-modal .upgrade-signin[hidden] {
  display: none;
}

/* ── What's included ── */
.auth-modal .upgrade-includes {
  margin-top: 1.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--stroke-soft);
  text-align: left;
}

.auth-modal .upgrade-includes__label {
  font-size: var(--vh-text-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 0.9rem;
}

.auth-modal .upgrade-features {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.auth-modal .upgrade-features__item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: var(--vh-text-sm);
  color: var(--text-secondary);
}

.auth-modal .upgrade-features__check {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: var(--primary-bg);
  background: color-mix(in srgb, var(--primary-bg) 14%, transparent);
  border-radius: 999px;
}