/* ============================================================
   Auth Modal - auth-modal.css
   ============================================================ */

/* Verify-email panel */
.am-verify-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin: 0 auto 0.4rem;
  border-radius: var(--sgad-radius-full);
  background: var(--sgad-primary-container);
  color: var(--sgad-primary);
}
.am-verify-icon svg { width: 28px; height: 28px; }
.am-verify-hint { text-align: center; }
.am-verify-hint #am-verify-email { color: var(--sgad-on-surface); }

/* ── Overlay: full-screen, card anchored to top ─────────────── */
.am-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1.5rem 1rem 1rem;
  animation: am-fade-in 0.18s ease;
}

@keyframes am-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes am-scale-in {
  from { opacity: 0; transform: scale(0.96) translateY(-8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.am-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  z-index: 0;
}

/* ── Card: constrained width, centred ───────────────────────── */
.am-card {
  position: relative;
  z-index: 1;
  background: var(--sgad-surface);
  border-radius: var(--sgad-radius);
  width: 100%;
  max-width: 460px;
  padding: 2.25rem 2rem 2rem;
  box-shadow: var(--sgad-elev-2);
  animation: am-scale-in 0.2s ease;
  max-height: 90vh;
  overflow-y: auto;
}

/* ── Close button ──────────────────────────────────────────── */
.am-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  cursor: pointer;
  color: #999;
  padding: 6px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
  z-index: 2;
}

.am-close:hover {
  color: #111;
}

/* ── Logo ──────────────────────────────────────────────────── */
.am-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 1.4rem;
}

.am-logo img {
  height: 36px;
  width: auto;
  object-fit: contain;
}

.am-logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: #111;
  font-family: var(--sgad-font);
}

/* ── Headings & switch ─────────────────────────────────────── */
.am-title {
  font-size: 1.2rem;
  font-weight: 700;
  text-align: center;
  color: #111;
  margin: 0 0 0.3rem;
  font-family: var(--sgad-font);
}

.am-switch {
  text-align: center;
  font-size: 0.875rem;
  color: #777;
  margin-bottom: 1.35rem;
}

.am-link {
  background: none;
  border: none;
  cursor: pointer;
  color: #111;
  font-weight: 600;
  font-size: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 0;
  font-family: inherit;
}

/* ── Form fields ───────────────────────────────────────────── */
.am-field {
  position: relative;
  margin-bottom: 0.7rem;
}

.am-field input {
  width: 100%;
  padding: 0.7rem 1.1rem;
  border: 1px solid var(--sgad-border);
  border-radius: var(--sgad-radius-full);
  font-size: 0.9375rem;
  color: var(--sgad-ink);
  background: var(--sgad-surface);
  box-sizing: border-box;
  outline: none;
  font-family: var(--sgad-font);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.am-field input::placeholder {
  color: var(--sgad-muted);
}

.am-field input:focus {
  border-color: var(--sgad-primary);
  box-shadow: var(--sgad-focus-ring);
}

/* keep typed password clear of the eye toggle */
.am-field:has(.am-eye) input { padding-right: 2.9rem; }

.am-eye {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  background: none;
  border: none;
  border-radius: var(--sgad-radius-full);
  cursor: pointer;
  color: var(--sgad-muted);
  padding: 0;
  transition: color var(--sgad-ease), background var(--sgad-ease);
}

.am-eye:hover { color: var(--sgad-on-surface); }
.am-eye:focus-visible { outline: none; box-shadow: var(--sgad-focus-ring); }

.am-eye svg {
  width: 18px;
  height: 18px;
}

/* ── Password strength indicator ───────────────────────────── */
.am-pw-strength {
  display: none;
  margin: -0.25rem 0 0.7rem;
  padding: 0.65rem 0.8rem;
  background: var(--sgad-surface-variant);
  border: 1px solid var(--sgad-outline);
  border-radius: var(--sgad-radius-md);
  grid-template-columns: 1fr 1fr;
  gap: 0.2rem 0.75rem;
}

.am-pw-strength.am-pw-visible {
  display: grid;
}

.am-pw-rule {
  font-size: 0.775rem;
  color: var(--sgad-muted);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.am-pw-rule::before {
  content: '○';
  font-size: 0.7rem;
}

.am-pw-rule.met {
  color: var(--sgad-success);
}

.am-pw-rule.met::before {
  content: '✓';
}

/* ── Terms acceptance checkbox ─────────────────────────────── */
.am-terms-check {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  font-size: 0.8rem;
  color: var(--sgad-muted);
  line-height: 1.45;
  margin-bottom: 0.9rem;
  cursor: pointer;
}

.am-terms-check input[type="checkbox"] {
  margin-top: 0.15rem;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--sgad-primary);
}

.am-terms-check a {
  color: var(--sgad-on-surface);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── Supporting text ───────────────────────────────────────── */

.am-forgot {
  display: block;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  color: #555;
  text-decoration: underline;
  text-underline-offset: 2px;
  margin-bottom: 1rem;
  padding: 0;
  font-family: inherit;
  text-align: left;
}

.am-hint {
  font-size: 0.875rem;
  color: #777;
  margin-bottom: 1.1rem;
  line-height: 1.5;
}

/* ── Buttons ───────────────────────────────────────────────── */
.am-btn-primary {
  width: 100%;
  padding: 0.8rem 1rem;
  background: var(--sgad-primary);
  color: var(--sgad-on-primary);
  border: none;
  border-radius: var(--sgad-radius-full);
  font-size: 0.9375rem;
  font-weight: var(--sgad-btn-weight);
  cursor: pointer;
  font-family: var(--sgad-font);
  letter-spacing: 0.01em;
  transition: background 0.15s;
}

.am-btn-primary:hover {
  background: var(--sgad-tertiary);
  color: var(--sgad-ink);
}

.am-btn-primary:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.am-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0;
  color: #bbb;
  font-size: 0.8rem;
}

.am-divider::before,
.am-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #e8e5df;
}

.am-btn-google {
  width: 100%;
  padding: 0.7rem 1rem;
  background: #fff;
  color: #111;
  border: 1px solid var(--sgad-border);
  border-radius: var(--sgad-radius-full);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--sgad-font);
  transition: border-color 0.15s, background 0.15s;
}

.am-btn-google:hover {
  background: #f9f9f7;
  border-color: #aaa;
}

.am-btn-microsoft {
  width: 100%;
  padding: 0.7rem 1rem;
  margin-top: 0.5rem;
  background: #fff;
  color: #111;
  border: 1px solid var(--sgad-border);
  border-radius: var(--sgad-radius-full);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--sgad-font);
  transition: border-color 0.15s, background 0.15s;
}

.am-btn-microsoft:hover {
  background: #f3f6fb;
  border-color: #0078d4;
}

/* ── Error / success banner ────────────────────────────────── */
.am-error {
  background: #fff0f0;
  border: 1px solid #f5c0c0;
  color: #c00;
  border-radius: 4px;
  padding: 0.55rem 0.8rem;
  font-size: 0.825rem;
  margin-bottom: 0.85rem;
  display: none;
}

.am-error.visible {
  display: block;
}

.am-error.success {
  background: #f0faf0;
  border-color: #a8d5a8;
  color: #2e7d32;
}

/* ── Header Auth UI ────────────────────────────────────────── */
.sgad-auth-ui {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sgad-user-menu {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sgad-user-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: inherit;
  white-space: nowrap;
}

#login-btn-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
}

.am-login-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: 1px solid #d5d2cb;
  color: #111;
  padding: 0.5rem 0.8rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.15s;
  white-space: nowrap;
}

.am-login-btn:hover {
  border-color: #111;
  background: #f5f5f5;
}

.am-login-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ── Account dropdown ──────────────────────────────────────── */
.am-account-menu {
  position: relative;
}

.am-account-trigger {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--sgad-primary);
  border: 1px solid var(--sgad-primary);
  color: var(--sgad-on-primary);
  padding: 0.45rem 0.9rem;
  border-radius: var(--sgad-radius-full);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: var(--sgad-font);
  transition: border-color 0.15s, background 0.15s;
  white-space: nowrap;
}

.am-account-trigger:hover {
  background: color-mix(in srgb, var(--sgad-primary), #000 12%);
  border-color: color-mix(in srgb, var(--sgad-primary), #000 12%);
}

.am-chevron {
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.8);
  transition: transform 0.15s;
}

.am-account-trigger[aria-expanded="true"] .am-chevron {
  transform: rotate(180deg);
}

.am-account-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--sgad-surface);
  border: 1px solid var(--sgad-outline);
  border-radius: var(--sgad-radius-md);
  box-shadow: var(--sgad-elev-2);
  min-width: 180px;
  z-index: 10000;
  overflow: hidden;
}

.am-account-item {
  display: block;
  width: 100%;
  padding: 0.6rem 0.85rem;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: var(--sgad-w-strong);
  color: var(--sgad-on-surface);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--sgad-font);
  text-align: left;
  transition: background var(--sgad-ease), color var(--sgad-ease);
}

.am-account-item:hover {
  background: var(--sgad-primary);
  color: var(--sgad-on-primary);
}

.am-account-signout {
  border-top: 1px solid var(--sgad-outline);
  border-radius: 0 0 10px 10px;
  color: var(--sgad-danger);
  margin-top: 4px;
  padding-top: 0.7rem;
}

.am-account-signout:hover {
  background: var(--sgad-danger);
  color: #fff;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 520px) {
  .am-overlay {
    padding: 0.75rem 0.5rem 0.5rem;
  }

  .am-card {
    padding: 1.75rem 1.25rem 1.5rem;
  }
}

/* Dark mode: card text/dividers that were hardcoded light-on-dark.
   (Google/Microsoft buttons keep their white brand surface + dark text.) */
[data-theme="dark"] .am-logo-text,
[data-theme="dark"] .am-title,
[data-theme="dark"] .am-link { color: var(--sgad-ink); }
[data-theme="dark"] .am-switch,
[data-theme="dark"] .am-hint,
[data-theme="dark"] .am-forgot,
[data-theme="dark"] .am-close,
[data-theme="dark"] .am-divider { color: var(--sgad-muted); }
[data-theme="dark"] .am-close:hover { color: var(--sgad-ink); }
[data-theme="dark"] .am-divider::before,
[data-theme="dark"] .am-divider::after { background: var(--sgad-border); }
