/**
 * Екрани входу / реєстрації: фон, картка, розділювач «або», кнопка Google.
 * Глобальні токени — у tailwind.input.css; тут лише auth-оболонка.
 */

/* Стабільна ширина: при кліку (SMS, повідомлення, зміна мови) з’являється новий блок — без цього смуга прокрутки стрибає вигляд */
html {
  scrollbar-gutter: stable;
  overflow-y: scroll;
}

.auth-body {
  font-family: "DM Sans", Inter, "Segoe UI", system-ui, sans-serif;
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* Повноекранне фото (static/uploads/auth-bg-truck.jpg — копія брендового «картинка с фоном») + затемнення для читабельності карток */
.auth-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background-color: #0c1222;
}

.auth-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--auth-bg-image, url("/static/uploads/auth-bg-truck.jpg"));
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.auth-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(155deg, rgba(8, 12, 22, 0.9) 0%, rgba(15, 35, 62, 0.82) 45%, rgba(15, 23, 42, 0.78) 100%),
    radial-gradient(ellipse 100% 65% at 50% -20%, rgba(37, 99, 235, 0.2), transparent 52%),
    radial-gradient(ellipse 50% 45% at 100% 18%, rgba(59, 130, 246, 0.1), transparent 48%);
}

.auth-shell {
  position: relative;
  z-index: 1;
}

.auth-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
  padding-top: max(0.65rem, env(safe-area-inset-top));
  padding-right: max(0.85rem, env(safe-area-inset-right));
  padding-bottom: 0.5rem;
  padding-left: max(0.85rem, env(safe-area-inset-left));
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(12, 18, 34, 0.35);
  backdrop-filter: blur(10px);
}

.auth-topbar .topbar__brand {
  min-width: 0;
  flex: 1 1 auto;
  color: #f8fafc;
}

.auth-topbar .topbar__title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 640px) {
  .auth-topbar {
    flex-wrap: nowrap;
    padding: 1rem 1.35rem 0.5rem;
    padding-top: max(1rem, env(safe-area-inset-top));
    padding-right: max(1.35rem, env(safe-area-inset-right));
    padding-left: max(1.35rem, env(safe-area-inset-left));
  }
}

.auth-topbar .topbar__subtitle {
  color: rgba(226, 232, 240, 0.75);
}

.auth-topbar .topbar__logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 2.5rem;
  max-width: 11rem;
  height: 2.5rem;
  padding: 0 0.15rem;
  border-radius: 0.875rem;
  font-size: 1.1rem;
  box-shadow: none;
  background: transparent;
}

.auth-topbar .topbar__logo i {
  line-height: 1;
}

/* Монохромний логотип для темної шапки: білий варіант */
.auth-topbar-logo {
  display: block;
  height: 2.35rem;
  width: auto;
  max-width: 10.5rem;
  object-fit: contain;
  object-position: left center;
  filter: brightness(0) invert(1);
}

/* Повнокольорова іконка додатку (квадрат AT + дорога) */
.auth-brand-app {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Логотип на білій картці форми (логін / реєстрація — однаковий вигляд контейнера) */
.auth-card__brand {
  flex-shrink: 0;
  margin: 0 auto 1.25rem;
  width: 15rem;
  max-width: 100%;
  height: 5.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-card__brand-img {
  display: block;
  height: 5rem;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}

.auth-card__brand--tall {
  height: 5.75rem;
}

.auth-card__brand--accent {
  padding: 0.5rem 0.75rem;
  border-radius: 1rem;
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.06) 0%, rgba(37, 99, 235, 0.02) 100%);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.12);
}

.auth-card__brand--warm {
  padding: 0.5rem 0.75rem;
  border-radius: 1rem;
  background: linear-gradient(180deg, rgba(217, 119, 6, 0.08) 0%, rgba(217, 119, 6, 0.02) 100%);
  box-shadow: 0 0 0 1px rgba(217, 119, 6, 0.15);
}

.auth-hero__visual {
  display: flex;
  justify-content: center;
  margin-bottom: 1.25rem;
}

.auth-hero__brand {
  width: 7.5rem;
  height: 7.5rem;
  object-fit: contain;
  border-radius: 1.35rem;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.12),
    0 20px 50px -12px rgba(0, 0, 0, 0.45);
}

.auth-oauth__icon-img {
  display: block;
  width: 3rem;
  height: 3rem;
  margin: 0 auto 1rem;
  object-fit: contain;
  border-radius: 0.875rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.auth-lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.auth-lang-btn i {
  opacity: 0.9;
  font-size: 1rem;
}

.auth-topbar .button--secondary {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #f1f5f9;
}

.auth-topbar .button--secondary:hover {
  background: rgba(255, 255, 255, 0.14);
}

.auth-content {
  max-width: 26rem;
  padding-top: 1.5rem;
  padding-bottom: 2.5rem;
}

.auth-card {
  width: 100%;
  border-radius: 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.97);
  box-shadow:
    0 4px 6px -1px rgba(15, 23, 42, 0.08),
    0 24px 48px -12px rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(12px);
  padding: 1.35rem 1.25rem;
}

@media (min-width: 640px) {
  .auth-card {
    border-radius: 1.5rem;
    padding: 1.75rem;
  }
}

.auth-card__head {
  text-align: center;
  margin-bottom: 0.25rem;
}

/* Логін / реєстрація: однакова сітка картки (підказка + посилання внизу) */
.auth-card--otp .auth-card__lead {
  min-height: 2.75rem;
}

.auth-page-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #0f172a;
  line-height: 1.2;
}

.auth-card__lead {
  margin: 0.65rem 0 0;
  font-size: 0.9rem;
  line-height: 1.45;
}

.auth-field {
  margin-top: 1rem;
}

.auth-field__label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.auth-field__label i {
  color: #64748b;
  font-size: 0.85rem;
}

.auth-input-wrap {
  position: relative;
  margin-top: 0.35rem;
}

.auth-input-wrap__icon {
  position: absolute;
  left: 0.95rem;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  font-size: 1rem;
  pointer-events: none;
  z-index: 1;
}

.auth-card .input.auth-input--icon {
  padding-left: 2.65rem;
}

.auth-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
}

.auth-btn i {
  font-size: 0.95rem;
}

.auth-btn--primary i {
  font-size: 0.9rem;
}

.auth-card .button--primary.auth-btn--primary {
  min-height: 3rem;
  border-radius: 1rem;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow:
    0 4px 14px -3px rgba(37, 99, 235, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.12) inset;
}

.auth-card .button--primary.auth-btn--primary:hover {
  box-shadow:
    0 6px 20px -4px rgba(37, 99, 235, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.15) inset;
}

/* Під час запиту OTP браузерний :disabled сірий — виглядає як «злетіли стилі» */
.auth-card .button:disabled {
  opacity: 0.88;
  cursor: not-allowed;
  transform: none;
}

.auth-card .button--primary.auth-btn--primary:disabled {
  background-color: #2563eb;
  color: #fff;
}

.auth-card .button--secondary:disabled {
  background-color: #fff;
  color: #0f172a;
  border-color: #e2e8f0;
}

.auth-alert__row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.auth-alert__icon {
  margin-top: 0.1rem;
  flex-shrink: 0;
}

.auth-alert__icon--error {
  color: #dc2626;
}

.auth-alert__icon--info {
  color: #2563eb;
}

.auth-links {
  margin-top: 1.5rem;
  padding-top: 0.25rem;
  /* На логіні два рядки посилань, на реєстрації — один; вирівнюємо висоту блоку */
  min-height: 5.75rem;
}

.auth-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  color: #2563eb;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.15s ease;
}

.auth-link:hover {
  color: #1d4ed8;
  text-decoration: underline;
}

.auth-link i {
  font-size: 0.85rem;
  opacity: 0.9;
}

.auth-hero {
  text-align: center;
  padding: 0.5rem 0 1rem;
}

.auth-hero__badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.85rem;
  margin-bottom: 1rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.95);
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.auth-hero__badge i {
  font-size: 0.85rem;
  opacity: 0.95;
}

.auth-hero__title {
  margin: 0;
  font-size: clamp(1.35rem, 4.5vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  color: #f8fafc;
  line-height: 1.2;
}

.auth-hero__subtitle {
  margin: 0.75rem 0 0;
  font-size: 0.95rem;
  line-height: 1.5;
  color: rgba(226, 232, 240, 0.85);
  max-width: 22rem;
  margin-left: auto;
  margin-right: auto;
}

.auth-hero__actions {
  margin-top: 1.75rem;
  display: grid;
  gap: 0.75rem;
}

.auth-hero__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  text-decoration: none;
}

.auth-hero__btn i {
  font-size: 1rem;
}

.auth-hero__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.auth-hero .button--primary {
  min-height: 3rem;
  border-radius: 1rem;
  font-size: 1rem;
  box-shadow: 0 10px 28px -6px rgba(37, 99, 235, 0.55);
}

.auth-hero__btn-secondary {
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.1);
  color: #f8fafc;
}

.auth-hero__btn-secondary:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.45);
}

.auth-hero .muted {
  color: rgba(226, 232, 240, 0.75);
}

.auth-hero .link-subtle {
  color: #bfdbfe;
}

.auth-hero .link-subtle:hover {
  color: #dbeafe;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.35rem 0 0.25rem;
  color: #64748b;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(148, 163, 184, 0.75), transparent);
}

.button--google,
.auth-btn--google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  min-height: 3rem;
  border-radius: 1rem;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #334155;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  transition:
    box-shadow 0.15s ease,
    border-color 0.15s ease,
    background 0.15s ease;
}

.button--google:hover,
.auth-btn--google:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.auth-btn--google .fa-google {
  font-size: 1.2rem;
  color: #4285f4;
}

.auth-oauth {
  text-align: center;
  padding: 1.5rem 0.5rem 2rem;
}

.auth-oauth__text {
  font-size: 0.95rem;
}

.auth-spinner {
  width: 2.5rem;
  height: 2.5rem;
  margin: 0 auto 1.25rem;
  border-radius: 50%;
  border: 3px solid #e2e8f0;
  border-top-color: #2563eb;
  animation: auth-spin 0.75s linear infinite;
}

@keyframes auth-spin {
  to {
    transform: rotate(360deg);
  }
}

.auth-oauth .muted {
  font-size: 0.95rem;
}

.auth-card .auth-error,
.auth-card .auth-info {
  border-radius: 0.875rem;
}

.auth-card .label {
  font-weight: 600;
  color: #475569;
}

.auth-card .link-subtle {
  color: #2563eb;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.15s ease;
}

.auth-card .link-subtle:hover {
  color: #1d4ed8;
  text-decoration: underline;
}

/* ── Recovery code modal ── */
.auth-recovery-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  padding: 1rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.auth-recovery-modal {
  max-width: 420px;
  width: 100%;
  padding: 2rem 1.5rem;
  text-align: center;
  border-radius: 1rem;
  background: #fff;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  margin: auto;
}

.auth-recovery-modal h2 {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: #1e293b;
}

.auth-recovery-modal p {
  margin: 0 0 1.25rem;
  font-size: 0.875rem;
  color: #64748b;
  line-height: 1.5;
}

.auth-recovery-code {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.25em;
  font-family: "Courier New", Courier, monospace;
  background: #f1f5f9;
  border: 2px dashed #94a3b8;
  border-radius: 0.75rem;
  color: #0f172a;
  user-select: all;
  word-break: break-all;
  max-width: 100%;
  box-sizing: border-box;
}

.auth-recovery-verify {
  text-align: left;
  margin-top: 1rem;
}

.auth-recovery-verify .label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #475569;
}

.auth-recovery-confirm-input {
  text-align: center;
  font-size: 1.25rem;
  letter-spacing: 0.2em;
  font-family: "Courier New", Courier, monospace;
  font-weight: 600;
  width: 100%;
  box-sizing: border-box;
}

.auth-recovery-mismatch {
  color: #ef4444;
  font-weight: 500;
  text-align: center;
}

/* ── Mobile: < 480px ── */
@media (max-width: 480px) {
  .auth-recovery-overlay {
    padding: 0.5rem;
    align-items: flex-start;
    padding-top: 2rem;
  }

  .auth-recovery-modal {
    padding: 1.25rem 1rem;
    border-radius: 0.75rem;
    max-width: 100%;
  }

  .auth-recovery-modal h2 {
    font-size: 1.125rem;
  }

  .auth-recovery-code {
    font-size: 1.5rem;
    padding: 0.5rem 1rem;
    letter-spacing: 0.15em;
  }

  .auth-recovery-confirm-input {
    font-size: 1.125rem;
  }
}

/* ── Landscape phone ── */
@media (max-height: 500px) {
  .auth-recovery-overlay {
    align-items: flex-start;
    padding-top: 0.5rem;
  }

  .auth-recovery-modal {
    padding: 1rem;
  }

  .auth-recovery-modal p {
    margin-bottom: 0.75rem;
  }
}

/* Публічні юридичні сторінки (auth layout): ширший текст, футер посилань */
.auth-body[data-page^="legal_"] .auth-content {
  max-width: min(42rem, 100%);
}

.auth-card__head--legal {
  text-align: left;
}

.auth-legal-prose {
  margin-top: 1rem;
  color: #334155;
  font-size: 0.9rem;
  line-height: 1.55;
}

.auth-legal-prose__h2 {
  margin: 1.25rem 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #0f172a;
}

.auth-legal-prose__h2:first-child {
  margin-top: 0;
}

.auth-legal-prose__p {
  color: #475569;
}

.auth-legal-dl dt {
  margin-top: 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
}

.auth-legal-dl dd {
  margin: 0.2rem 0 0;
  color: #0f172a;
}

.auth-legal-dl__multiline {
  white-space: normal;
}

.auth-legal-docs li,
.auth-legal-contacts li {
  margin-top: 0.35rem;
}

.auth-legal-footer {
  max-width: min(42rem, 100%);
  margin: 0 auto;
  padding: 0 0.5rem 1.75rem;
}

.auth-legal-footer__nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.25rem 0.35rem;
  font-size: 0.75rem;
  line-height: 1.4;
  color: rgba(226, 232, 240, 0.85);
  text-align: center;
}

.auth-legal-footer__link {
  color: rgba(191, 219, 254, 0.95);
  text-decoration: none;
  font-weight: 500;
}

.auth-legal-footer__link:hover {
  color: #fff;
  text-decoration: underline;
}

.auth-legal-footer__sep {
  opacity: 0.45;
  user-select: none;
}

.auth-legal-consent__label {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1.45;
  color: #334155;
}

.auth-legal-consent__input {
  margin-top: 0.2rem;
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  accent-color: #2563eb;
}

.auth-legal-consent__text .link-subtle {
  color: #1d4ed8;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.auth-hero__legal-hint {
  margin-top: 1rem;
  color: rgba(226, 232, 240, 0.88);
}

.auth-hero__legal-hint .link-subtle {
  color: rgba(191, 219, 254, 0.98);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.auth-hero__legal-hint .link-subtle:hover {
  color: #fff;
}

/*
 * Темна тема (localStorage → body.theme-dark): layout auth, у т.ч. /legal/*.
 * Класи dark:* у розмітці залежать від prefers-color-scheme, а не від перемикача в додатку.
 */
body.auth-body.theme-dark .auth-card {
  background: rgba(30, 41, 59, 0.94);
  border-color: rgba(100, 116, 139, 0.4);
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.28),
    0 24px 48px -12px rgba(0, 0, 0, 0.5);
}

body.auth-body.theme-dark .auth-page-title {
  color: #f8fafc;
}

body.auth-body.theme-dark .auth-card__lead,
body.auth-body.theme-dark .auth-card .muted {
  color: #94a3b8;
}

body.auth-body.theme-dark .auth-legal-prose {
  color: #cbd5e1;
}

body.auth-body.theme-dark .auth-legal-prose__h2 {
  color: #f1f5f9;
}

body.auth-body.theme-dark .auth-legal-prose__p {
  color: #e2e8f0;
}

body.auth-body.theme-dark .auth-legal-dl dt {
  color: #94a3b8;
}

body.auth-body.theme-dark .auth-legal-dl dd {
  color: #f1f5f9;
}

body.auth-body.theme-dark .auth-card .link-subtle {
  color: #93c5fd;
}

body.auth-body.theme-dark .auth-card .link-subtle:hover {
  color: #bfdbfe;
}

body.auth-body.theme-dark .auth-link {
  color: #93c5fd;
}

body.auth-body.theme-dark .auth-link:hover {
  color: #bfdbfe;
}

body.auth-body.theme-dark .auth-card .label {
  color: #cbd5e1;
}

body.auth-body.theme-dark .auth-card .button--secondary {
  border-color: rgb(71 85 105);
  background: rgb(51 65 85);
  color: #f1f5f9;
}

body.auth-body.theme-dark .auth-card .button--secondary:hover {
  border-color: rgb(100 116 139);
  background: rgb(71 85 105);
}

body.auth-body.theme-dark .auth-topbar .button--secondary {
  border-color: rgba(148, 163, 184, 0.45);
  background: rgba(15, 23, 42, 0.55);
  color: #e2e8f0;
}

body.auth-body.theme-dark .auth-topbar .button--secondary:hover {
  border-color: rgba(148, 163, 184, 0.6);
  background: rgba(30, 41, 59, 0.75);
}

/* У шаблонах є text-slate-900 / dark:text-slate-100; dark: не прив’язаний до body.theme-dark */
body.auth-body.theme-dark .auth-card .text-slate-900,
body.auth-body.theme-dark .auth-card .text-slate-800,
body.auth-body.theme-dark .auth-card .text-slate-700 {
  color: #e2e8f0 !important;
}

body.auth-body.theme-dark .auth-divider {
  color: #94a3b8;
}

body.auth-body.theme-dark .auth-divider::before,
body.auth-body.theme-dark .auth-divider::after {
  background: linear-gradient(90deg, transparent, rgba(148, 163, 184, 0.45), transparent);
}

body.auth-body.theme-dark .auth-legal-consent__label {
  color: #cbd5e1;
}

body.auth-body.theme-dark .auth-legal-consent__text .link-subtle {
  color: #93c5fd;
}

body.auth-body.theme-dark .auth-spinner {
  border-color: rgb(71 85 105);
  border-top-color: #60a5fa;
}
