/* =========================================================
   SONIMARTO AUTH — SHARED PAGE + INDEX MODAL
   Compact, site-consistent and protected from legacy styles.
   ========================================================= */

:root {
  --auth-ink: #0b1430;
  --auth-text: #263044;
  --auth-muted: #68758d;
  --auth-soft: #f5f7fb;
  --auth-border: #dce4f0;
  --auth-blue: #1358ff;
  --auth-blue-hover: #0f4ee8;
}

[hidden],
.hidden {
  display: none !important;
}

.auth-card,
.auth-card *,
#auth-modal-overlay,
#auth-modal-overlay * {
  box-sizing: border-box;
}

/* -------------------- Dedicated auth page -------------------- */
.auth-container {
  min-height: calc(100vh - 74px);
  padding: 28px 24px 64px;
  background: var(--auth-soft, #f5f7fc);
  color: var(--auth-ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.auth-wrapper {
  width: min(620px, 100%);
  margin: 0 auto;
}

.auth-branding {
  margin: 0 auto 30px;
  text-align: center;
}

.auth-branding h1 {
  margin: 0;
  color: var(--auth-ink);
  font-size: clamp(30px, 4.2vw, 38px);
  line-height: 1.08;
  font-weight: 800;
  letter-spacing: -0.045em;
}

.auth-branding .highlight { color: var(--auth-blue); }

.auth-tagline {
  max-width: 570px;
  margin: 14px auto 0;
  color: var(--auth-muted);
  font-size: 16px;
  line-height: 1.55;
}

/* -------------------- Shared card -------------------- */
.auth-card-container {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}

.auth-card {
  position: relative;
  width: 100%;
  padding: 30px;
  border: 1px solid var(--auth-border);
  border-radius: 20px;
  background: var(--bg-white);
  color: var(--auth-ink);
  box-shadow: 0 18px 44px rgba(24, 46, 87, 0.09);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.auth-card h2 {
  margin: 0 44px 22px;
  color: var(--auth-ink);
  font-size: 24px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.035em;
  text-align: center;
}

/* Google authentication */
.social-auth-grid {
  display: grid;
  grid-template-columns: 1fr;
  width: 100%;
}

.social-auth-btn {
  width: 100%;
  min-width: 0;
  height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 18px;
  border: 1px solid var(--auth-border);
  border-radius: 12px;
  background: var(--bg-white);
  color: var(--auth-ink);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: transform .16s ease, border-color .16s ease, background .16s ease, box-shadow .16s ease;
}

.social-auth-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--border-strong, #bdc9dc);
  background: var(--surface-alt, #f9fbff);
  box-shadow: 0 7px 18px rgba(24, 46, 87, .07);
}

.social-auth-btn .provider-icon { flex: 0 0 auto; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 22px 0;
  color: var(--text-muted, #8b98ad);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--auth-border);
}

.auth-field {
  display: block;
  margin-bottom: 15px;
  color: var(--auth-text);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
}

.auth-field input {
  display: block;
  width: 100%;
  height: 50px;
  margin-top: 6px;
  padding: 0 14px;
  border: 1px solid var(--auth-border);
  border-radius: 11px;
  background: var(--bg-white);
  color: var(--auth-ink);
  font-family: inherit;
  font-size: 14px;
  font-weight: 550;
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.auth-field input::placeholder { color: var(--text-muted, #95a3b8); opacity: 1; }
.auth-field input:hover { border-color: var(--border-strong, #c6d0df); }
.auth-field input:focus {
  border-color: var(--auth-blue);
  box-shadow: 0 0 0 3px rgba(19, 88, 255, .1);
}

.auth-submit {
  width: 100%;
  min-height: 52px;
  margin-top: 2px;
  padding: 13px 18px;
  border: 1px solid var(--auth-blue);
  border-radius: 11px;
  background: linear-gradient(180deg, var(--primary, #2468ff) 0%, var(--auth-blue) 100%);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 750;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: 0 9px 20px rgba(19, 88, 255, .2);
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}

.auth-submit:hover:not(:disabled) {
  transform: translateY(-1px);
  background: linear-gradient(180deg, var(--primary, #3072ff) 0%, var(--auth-blue-hover) 100%);
  box-shadow: 0 12px 24px rgba(19, 88, 255, .24);
}

.auth-submit:disabled,
.social-auth-btn:disabled,
.auth-resend:disabled {
  cursor: not-allowed;
  opacity: .62;
  transform: none;
}

.auth-message {
  min-height: 0;
  margin: 10px 0 0;
  color: var(--danger, #d94141);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
  text-align: center;
}
.auth-message:empty { display: none; }
.auth-message.success { color: var(--success, #18825f); }
.auth-message.error { color: var(--danger, #d94141); }

.auth-switch {
  margin: 26px 0 0;
  color: var(--auth-muted);
  font-size: 14px;
  line-height: 1.45;
  text-align: center;
}

.auth-switch a {
  color: var(--auth-blue);
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
}
.auth-switch a:hover { text-decoration: underline; }

.social-auth-btn:focus-visible,
.auth-submit:focus-visible,
.auth-resend:focus-visible,
.auth-switch a:focus-visible,
.auth-close:focus-visible,
.auth-field input:focus-visible {
  outline: 3px solid rgba(19, 88, 255, .18);
  outline-offset: 2px;
}

/* Verification cards */
.verification-icon { display: flex; justify-content: center; margin: 0 0 18px; }
.verification-text,
.verification-subtitle {
  margin: 0;
  color: var(--auth-muted);
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
}
.verification-text strong { color: var(--auth-text); overflow-wrap: anywhere; }
.verification-actions { display: grid; gap: 10px; margin-top: 22px; }
.auth-resend {
  width: 100%;
  min-height: 46px;
  padding: 11px 16px;
  border: 1px solid var(--auth-border);
  border-radius: 11px;
  background: var(--bg-white);
  color: var(--auth-blue);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.auth-resend:hover { border-color: var(--border-strong, #bdc9dc); background: var(--surface-alt, #f8faff); }

/* -------------------- Index modal -------------------- */
#auth-modal-overlay.auth-modal-overlay {
  position: fixed !important;
  inset: 0 !important;
  z-index: 10000 !important;
  width: 100% !important;
  height: 100% !important;
  display: grid !important;
  place-items: center !important;
  overflow: hidden !important;
  padding: 16px !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  transform: none !important;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
}

#auth-modal-overlay.auth-modal-overlay[hidden] { display: none !important; }

/* The fixed backdrop owns the blur. It therefore still covers the complete
   viewport when a tall card scrolls inside the dialog. */
#auth-modal-overlay .auth-modal-backdrop {
  position: fixed !important;
  inset: 0 !important;
  z-index: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  border: 0 !important;
  background: rgba(11, 20, 48, .46) !important;
  -webkit-backdrop-filter: blur(9px) saturate(.92) !important;
  backdrop-filter: blur(9px) saturate(.92) !important;
}

#auth-modal-overlay .auth-modal-dialog {
  position: relative !important;
  z-index: 1 !important;
  width: min(440px, calc(100vw - 32px)) !important;
  max-width: 440px !important;
  max-height: calc(100vh - 32px) !important;
  max-height: calc(100dvh - 32px) !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 1px solid var(--auth-border) !important;
  border-radius: 20px !important;
  background: var(--bg-white) !important;
  box-shadow: 0 26px 80px rgba(7, 19, 47, .24) !important;
  overflow: hidden !important;
  color: var(--auth-ink) !important;
  opacity: 1 !important;
  transform: none !important;
}

#auth-modal-overlay .auth-card-container {
  width: 100% !important;
  max-width: none !important;
  max-height: calc(100vh - 32px) !important;
  max-height: calc(100dvh - 32px) !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior: contain !important;
  scrollbar-gutter: stable !important;
  background: var(--bg-white) !important;
}

#auth-modal-overlay .auth-card {
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
  height: auto !important;
  margin: 0 !important;
  padding: 30px !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: var(--bg-white) !important;
  color: var(--auth-ink) !important;
  box-shadow: none !important;
  opacity: 1 !important;
  transform: none !important;
}

#auth-modal-overlay .auth-card h2 { color: var(--auth-ink) !important; }
#auth-modal-overlay .auth-field { color: var(--auth-text) !important; }
#auth-modal-overlay .social-auth-btn,
#auth-modal-overlay .auth-field input,
#auth-modal-overlay .auth-resend { background: var(--bg-white) !important; }
#auth-modal-overlay .social-auth-btn { border-color: var(--auth-border) !important; }
#auth-modal-overlay .auth-field input { color: var(--auth-ink) !important; border-color: var(--auth-border) !important; }
#auth-modal-overlay .auth-divider { color: var(--text-muted, #8b98ad) !important; }
#auth-modal-overlay .auth-divider::before,
#auth-modal-overlay .auth-divider::after { background: var(--auth-border) !important; }
#auth-modal-overlay .auth-switch { color: var(--auth-muted) !important; }

#auth-modal-overlay .auth-close {
  position: absolute !important;
  top: 12px !important;
  right: 12px !important;
  z-index: 5 !important;
  width: 34px !important;
  height: 34px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 0 2px !important;
  border: 1px solid var(--auth-border) !important;
  border-radius: 50% !important;
  background: var(--overlay, rgba(255,255,255,.96)) !important;
  color: var(--auth-muted) !important;
  font-family: inherit !important;
  font-size: 22px !important;
  line-height: 1 !important;
  cursor: pointer !important;
  box-shadow: 0 5px 15px rgba(7, 19, 47, .1) !important;
  transform: none !important;
}
#auth-modal-overlay .auth-close:hover { background: var(--auth-soft) !important; color: var(--auth-ink) !important; }

body.auth-modal-open { overflow: hidden !important; }

/* -------------------- Navbar auth button -------------------- */
.auth-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 42px;
  padding: 0 22px;
  border: 1px solid var(--auth-blue);
  border-radius: 12px;
  background: linear-gradient(180deg, var(--primary-light) 0%, var(--auth-blue) 100%);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 650;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(19, 88, 255, .18);
}
.auth-btn svg { width: 18px; height: 18px; flex-shrink: 0; color: currentColor; }
.auth-btn-text { white-space: nowrap; }
.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  font-size: 12px;
  font-weight: 800;
}

/* -------------------- Toast / spinner -------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 11000;
  max-width: calc(100vw - 48px);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px 12px 14px;
  border: 1px solid var(--premium-border);
  border-left: 4px solid var(--premium-green);
  border-radius: 14px;
  background: linear-gradient(180deg, var(--bg-white, #ffffff) 0%, var(--bg-page, #fbfcff) 100%);
  color: var(--auth-ink);
  font: 600 14px/1.45 "Inter", sans-serif;
  text-align: left;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(20px);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  transition: opacity .25s ease, transform .25s ease;
  /* Above every popup (auth modal overlay is 10000) so toasts stay visible. */
  z-index: 120000;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.spinner {
  width: 32px;
  height: 32px;
  margin: 0 auto;
  border: 3px solid var(--border);
  border-top-color: var(--auth-blue);
  border-radius: 50%;
  animation: auth-spin .8s linear infinite;
}
@keyframes auth-spin { to { transform: rotate(360deg); } }

@media (max-width: 600px) {
  .auth-container { padding: 22px 14px 48px; }
  .auth-branding { margin-bottom: 24px; }
  .auth-tagline { font-size: 14px; }
  .auth-card { padding: 24px 20px; border-radius: 17px; }
  .auth-card h2 { margin-bottom: 20px; font-size: 22px; }
  .social-auth-btn { height: 50px; padding: 0 14px; font-size: 13px; }
  .social-auth-btn .provider-icon { width: 18px; height: 18px; }
  .auth-divider { margin: 19px 0; }
  .auth-switch { margin-top: 22px; }

  #auth-modal-overlay.auth-modal-overlay { padding: 10px !important; }
  #auth-modal-overlay .auth-modal-dialog {
    width: min(100%, calc(100vw - 20px)) !important;
    max-height: calc(100dvh - 20px) !important;
    border-radius: 17px !important;
  }
  #auth-modal-overlay .auth-card-container { max-height: calc(100dvh - 20px) !important; }
  #auth-modal-overlay .auth-card { padding: 24px 20px !important; }
}


@media (prefers-reduced-motion: reduce) {
  .social-auth-btn,
  .auth-submit,
  .toast { transition: none; }
}
