/* R-ONE Market — sign-in card. One component for the modal over the current
 * page (#m-auth-dialog) and the /m/account/login fallback page. Colours come
 * from the shared --m-* tokens: a white card in the light theme (default),
 * a navy card in the dark theme. No marketing blocks, no decoration. */

/* Modal shell */
.m-auth-dialog {
  width: min(460px, calc(100% - 32px)); max-width: none; max-height: calc(100dvh - 32px);
  margin: auto; padding: 0; border: 0; border-radius: 20px; overflow: auto;
  background: transparent; color: var(--m-text);
}
.m-auth-dialog::backdrop { background: rgba(6, 14, 28, .55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.m-auth-dialog[open] { animation: m-auth-in .18s ease-out; }
@keyframes m-auth-in { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
html.m-auth-open { overflow: hidden; }

/* Card */
.m-auth-card {
  position: relative; padding: 28px 28px 22px; border-radius: 20px;
  background: #0d1a31; border: 1px solid rgba(94, 137, 191, .28);
  box-shadow: 0 24px 60px -28px rgba(0, 0, 0, .75);
  color: var(--m-text); font-family: inherit;
}
html[data-theme="light"] .m-auth-card {
  background: #fff; border-color: rgba(20, 60, 110, .12);
  box-shadow: 0 24px 60px -30px rgba(15, 40, 80, .45), 0 2px 6px rgba(15, 40, 80, .06);
}

.m-auth-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.m-auth-head h2 { margin: 0; font-size: 1.3rem; line-height: 1.25; letter-spacing: -.01em; color: var(--m-text); }
.m-auth-close {
  flex: 0 0 36px; width: 36px; height: 36px; margin: -6px -8px 0 0; display: grid; place-items: center;
  border: 0; border-radius: 10px; background: transparent; color: var(--m-muted);
  font-family: inherit; font-size: 1.6rem; font-weight: 400; line-height: 1; cursor: pointer; text-decoration: none;
}
.m-auth-close:hover { background: rgba(127, 150, 180, .14); color: var(--m-text); }
.m-auth-close:focus-visible { outline: 2px solid var(--m-accent); outline-offset: 2px; }

.m-auth-context { margin: -6px 0 16px; color: var(--m-muted); font-size: .92rem; line-height: 1.45; }
.m-auth-context[hidden], .m-auth-view[hidden], .m-auth-alert[hidden], .m-auth-form[hidden] { display: none; }

.m-auth-alert {
  margin: 0 0 14px; padding: 10px 12px; border-radius: 10px; font-size: .88rem; font-weight: 600;
  background: rgba(255, 92, 92, .1); border: 1px solid rgba(255, 92, 92, .45); color: #ffb4b4;
}
html[data-theme="light"] .m-auth-alert { background: #fff1f1; border-color: rgba(220, 38, 38, .3); color: #b42318; }

/* Email */
.m-auth-form { display: grid; gap: 8px; }
.m-auth-form label { font-size: .86rem; font-weight: 700; color: var(--m-text); }
.m-auth-form input, .m-auth-form select {
  width: 100%; min-height: 48px; padding: 0 14px; border-radius: 12px; font: inherit; font-size: 1rem;
  background: rgba(255, 255, 255, .04); color: var(--m-text); border: 1px solid var(--m-border);
}
html[data-theme="light"] .m-auth-form input, html[data-theme="light"] .m-auth-form select { background: #fff; border-color: rgba(20, 60, 110, .22); }
.m-auth-form input:focus, .m-auth-form select:focus { outline: 0; border-color: var(--m-accent); box-shadow: 0 0 0 3px rgba(34, 211, 238, .22); }
.m-auth-primary {
  min-height: 48px; margin-top: 6px; border: 0; border-radius: 12px; cursor: pointer;
  font: inherit; font-size: 1rem; font-weight: 800; color: #04141f; background: var(--m-accent-gradient);
}
.m-auth-primary:hover { filter: brightness(1.05); }
.m-auth-primary:focus-visible { outline: 2px solid var(--m-accent); outline-offset: 2px; }
.m-auth-primary:disabled { opacity: .6; cursor: progress; }

/* Telegram — головний спосіб входу, коли налаштований */
.m-auth-telegram {
  display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; padding: 0 16px;
  border-radius: 12px; background: #229ed9; color: #fff; font: inherit; font-size: 1.02rem; font-weight: 800; text-decoration: none;
}
.m-auth-telegram:hover { background: #1c8cc2; }
.m-auth-telegram:focus-visible { outline: 2px solid var(--m-accent); outline-offset: 2px; }
.m-auth-telegram svg { width: 22px; height: 22px; flex: 0 0 22px; color: #fff; }
.m-auth-hint { margin: 8px 0 0; text-align: center; color: var(--m-muted); font-size: .84rem; }

/* Email + пароль: «Немає акаунта?» і «Забули пароль?» */
.m-auth-form-links { display: flex; justify-content: space-between; gap: 8px 14px; flex-wrap: wrap; margin-top: 4px; }

/* «або» */
.m-auth-divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--m-muted); font-size: .82rem; font-weight: 600; }
.m-auth-divider::before, .m-auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--m-border); }

/* Telegram / phone */
.m-auth-alt { display: grid; gap: 10px; }
.m-auth-secondary {
  display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; padding: 0 16px;
  border-radius: 12px; border: 1px solid var(--m-border); background: transparent; cursor: pointer;
  color: var(--m-text); font: inherit; font-size: .95rem; font-weight: 700; text-decoration: none; text-align: center;
}
html[data-theme="light"] .m-auth-secondary { border-color: rgba(20, 60, 110, .2); background: #fff; }
.m-auth-secondary:hover { border-color: var(--m-accent); background: rgba(34, 211, 238, .06); }
.m-auth-secondary:focus-visible { outline: 2px solid var(--m-accent); outline-offset: 2px; }
.m-auth-secondary svg { width: 20px; height: 20px; flex: 0 0 20px; color: var(--m-accent); }
.m-auth-secondary .m-auth-icon-telegram { color: #229ed9; }

/* Email sent */
.m-auth-sent { display: grid; gap: 6px; padding: 14px 16px; border-radius: 12px; background: rgba(34, 197, 94, .1); border: 1px solid rgba(34, 197, 94, .4); }
.m-auth-sent strong { color: #86efac; }
.m-auth-sent p { margin: 0; color: var(--m-muted); font-size: .92rem; line-height: 1.5; }
html[data-theme="light"] .m-auth-sent { background: #effbf3; border-color: rgba(22, 163, 74, .3); }
html[data-theme="light"] .m-auth-sent strong { color: #15803d; }

/* Phone */
.m-auth-phone-row { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 8px; }
.m-auth-code { letter-spacing: .5em; text-align: center; font-weight: 700; font-size: 1.25rem !important; }
.m-auth-sent-to { font-weight: 600; color: var(--m-muted); }
.m-auth-code-actions { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.m-auth-link {
  justify-self: start; padding: 0; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: .88rem; font-weight: 700; color: var(--m-accent); text-decoration: none;
}
.m-auth-link:disabled { color: var(--m-muted); cursor: default; }
.m-auth-back { margin-top: 14px; }

.m-auth-legal { margin: 20px 0 0; color: var(--m-muted); font-size: .78rem; line-height: 1.5; text-align: center; }
.m-auth-legal a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.m-auth-legal a:hover { color: var(--m-text); }

/* Fallback page: just the card, centred under the header. */
.m-auth-fallback { display: flex; justify-content: center; padding-top: clamp(24px, 8vh, 72px); padding-bottom: 48px; }
.m-auth-fallback .m-auth-card { width: min(460px, 100%); }

/* Inquiry form: optional sign-in hint (listing page). */
.m-inquiry-signin { margin: -8px 0 14px; color: var(--m-muted); font-size: .88rem; }
.m-inquiry-signin a { color: var(--m-accent); font-weight: 700; }

/* Mobile: the modal becomes a full-width sheet with safe margins. */
@media (max-width: 640px) {
  .m-auth-dialog {
    width: calc(100% - 24px); max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    margin: auto auto calc(12px + env(safe-area-inset-bottom));
  }
  .m-auth-dialog[open] { animation-name: m-auth-sheet-in; }
  .m-auth-card { padding: 22px 18px 18px; }
  .m-auth-head h2 { font-size: 1.18rem; }
  .m-auth-fallback { padding-top: 16px; }
}
@keyframes m-auth-sheet-in { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .m-auth-dialog[open] { animation: none; } }
