/* ==========================================================================
   CRM LOGIN — экран входа под эталон crm-login.html
   Самодостаточный файл: шаблон page-templates/crm-login.php печатает свой
   <head> (без wp_head), поэтому стиль подключается <link> прямо в шаблоне.
   Палитра/типографика — та же, что в sales-crm.css (.sales-crm{--crm-*}).
   Литералы цвета допустимы ТОЛЬКО в блоке токенов ниже; далее — var().
   ========================================================================== */

/* Локальный Montserrat из темы — гарантированный офлайн-фолбэк.
   ВАЖНО: assets/fonts/Montserrat.ttf — статическая гарнитура одного начертания
   (в файле нет таблицы fvar), поэтому объявлять её как «100 900» нельзя:
   браузер начинает одинаково рисовать и 300, и 700. Держим её отдельным
   семейством, а «Montserrat» берём с весами 300/400/500/600 (см. <link> в
   шаблоне) — иначе заголовок эталона («Вход в» тонким, «рабочий кабинет»
   обычным) одной статической гарнитурой не воспроизводится. */
@font-face {
  font-family: "Montserrat Local";
  src: url("../fonts/Montserrat.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* --- Ink --- */
  --crm-ink-950: #23232F;
  --crm-ink-900: #2E2E3D;
  --crm-ink-700: #55556B;
  --crm-ink-500: #666679;
  --crm-ink-400: #6E6E85;

  /* --- Surfaces --- */
  --crm-canvas: #F5F7FC;
  --crm-white: #FFFFFF;
  --crm-card-bg: rgba(255, 255, 255, 0.72);
  --crm-card-border: rgba(255, 255, 255, 0.85);
  --crm-white-70: rgba(255, 255, 255, 0.70);
  --crm-white-92: rgba(255, 255, 255, 0.92);
  --crm-hair: rgba(70, 70, 120, 0.07);

  /* --- Пастельный фон (как в дашборде) --- */
  --crm-grad-from: #F2F5FB;
  --crm-grad-mid: #EDF3FA;
  --crm-grad-to: #F7F1EE;
  --crm-glow-brand: rgba(10, 109, 209, 0.16);
  --crm-glow-sky: rgba(63, 184, 206, 0.16);
  --crm-glow-peach: rgba(240, 161, 132, 0.20);

  /* --- Brand --- */
  --crm-brand: #0A6DD1;
  --crm-brand-hi: #2F86DE;
  --crm-brand-deep: #08569F;
  --crm-brand-soft: rgba(10, 109, 209, 0.14);
  --crm-brand-shadow: rgba(10, 109, 209, 0.85);
  --crm-brand-shadow-hover: rgba(10, 109, 209, 0.95);
  --crm-mark-shadow: rgba(10, 109, 209, 0.80);

  /* --- Error --- */
  --crm-err-ink: #AE3B50;
  --crm-err-soft: rgba(238, 123, 140, 0.16);

  /* --- Поля --- */
  --crm-field-line: rgba(70, 70, 120, 0.16);
  --crm-field-line-hover: rgba(70, 70, 120, 0.26);
  --crm-remember-line: rgba(70, 70, 120, 0.22);

  /* --- Типографика --- */
  --crm-display: "Montserrat", "Montserrat Local", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --crm-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --crm-mono: "JetBrains Mono", ui-monospace, monospace;

  /* --- Motion --- */
  --crm-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --crm-out-expo: cubic-bezier(0.16, 1, 0.3, 1);

  /* --- Radius --- */
  --crm-r-field: 14px;
  --crm-r-card: 26px;
  --crm-r-mark: 14px;

  /* --- Elevation --- */
  --crm-shadow-card: 0 2px 8px rgba(10, 60, 130, 0.05), 0 30px 60px -30px rgba(10, 80, 170, 0.34);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--crm-body);
  font-size: 14.5px;
  color: var(--crm-ink-700);
  line-height: 1.55;
  background: var(--crm-canvas);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  position: relative;
}

/* Пастельный фон — как в дашборде */
.crm-auth-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(52% 44% at 8% 4%, var(--crm-glow-brand) 0%, transparent 60%),
    radial-gradient(46% 40% at 96% 10%, var(--crm-glow-sky) 0%, transparent 58%),
    radial-gradient(44% 40% at 88% 96%, var(--crm-glow-peach) 0%, transparent 60%),
    linear-gradient(160deg, var(--crm-grad-from) 0%, var(--crm-grad-mid) 52%, var(--crm-grad-to) 100%);
}

.crm-auth {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ===================== БРЕНД ===================== */
.crm-auth-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 22px;
}

.crm-auth-brand__mark {
  width: 46px;
  height: 46px;
  flex: none;
  color: var(--crm-white);
  border-radius: var(--crm-r-mark);
  background: linear-gradient(150deg, var(--crm-brand-hi) 0%, var(--crm-brand-deep) 100%);
  display: grid;
  place-items: center;
  box-shadow: 0 10px 24px -10px var(--crm-mark-shadow);
}

.crm-auth-brand__mark svg { width: 25px; height: 25px; }

.crm-auth-brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.crm-auth-brand__text b {
  font-family: var(--crm-display);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--crm-ink-950);
}

.crm-auth-brand__text span { font-size: 11.5px; color: var(--crm-ink-400); }

/* ===================== КАРТОЧКА ===================== */
.crm-auth-card {
  width: 100%;
  background: var(--crm-card-bg);
  border: 1px solid var(--crm-card-border);
  border-radius: var(--crm-r-card);
  padding: 30px 28px 26px;
  box-shadow: var(--crm-shadow-card);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  animation: crmAuthCardIn 0.7s var(--crm-out-expo);
}

@keyframes crmAuthCardIn {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: none; }
}

.crm-auth-head { margin-bottom: 22px; }

.crm-auth-head h1 {
  font-family: var(--crm-display);
  font-size: 26px;
  font-weight: 300;
  letter-spacing: -0.02em;
  color: var(--crm-ink-950);
  line-height: 1.15;
  margin-bottom: 7px;
}

.crm-auth-head h1 b { font-weight: 500; }

.crm-auth-head p { font-size: 13px; color: var(--crm-ink-400); }

/* ===================== АЛЕРТ ===================== */
.crm-auth-alert {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 12px 14px;
  border-radius: 13px;
  background: var(--crm-err-soft);
  color: var(--crm-err-ink);
  font-size: 12.5px;
  line-height: 1.45;
  margin-bottom: 18px;
  animation: crmAuthShake 0.4s var(--crm-ease);
}

.crm-auth-alert svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }

@keyframes crmAuthShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ===================== ПОЛЯ ===================== */
.crm-auth-fields { display: flex; flex-direction: column; gap: 15px; }

.crm-auth-field { display: flex; flex-direction: column; gap: 7px; }

.crm-auth-field label { font-size: 12px; font-weight: 500; color: var(--crm-ink-500); }

.crm-auth-control { position: relative; display: flex; align-items: center; }

.crm-auth-control__icon {
  position: absolute;
  left: 15px;
  color: var(--crm-ink-400);
  display: grid;
  place-items: center;
  pointer-events: none;
}

.crm-auth-control__icon svg { width: 16px; height: 16px; }

.crm-auth-input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--crm-field-line);
  border-radius: var(--crm-r-field);
  background: var(--crm-white-92);
  padding: 0 15px 0 43px;
  font: inherit;
  font-size: 14px;
  color: var(--crm-ink-950);
  transition: border-color 0.25s var(--crm-ease), box-shadow 0.3s var(--crm-ease), background 0.25s var(--crm-ease);
}

.crm-auth-input::placeholder { color: var(--crm-ink-400); }

.crm-auth-input:hover {
  background: var(--crm-white);
  border-color: var(--crm-field-line-hover);
}

.crm-auth-input:focus {
  outline: none;
  background: var(--crm-white);
  border-color: var(--crm-brand);
  box-shadow: 0 0 0 4px var(--crm-brand-soft);
}

.crm-auth-control--pass .crm-auth-input { padding-right: 46px; }

.crm-auth-toggle-pass {
  position: absolute;
  right: 8px;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 10px;
  background: none;
  color: var(--crm-ink-400);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.25s var(--crm-ease), color 0.25s var(--crm-ease);
}

.crm-auth-toggle-pass:hover { background: var(--crm-brand-soft); color: var(--crm-brand-deep); }

.crm-auth-toggle-pass svg { width: 16px; height: 16px; }

/* ===================== ЧЕКБОКС + ССЫЛКА ===================== */
.crm-auth-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 20px;
}

.crm-auth-remember {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  color: var(--crm-ink-500);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.crm-auth-remember input { position: absolute; opacity: 0; width: 0; height: 0; }

.crm-auth-remember__box {
  width: 19px;
  height: 19px;
  flex: none;
  border-radius: 6px;
  border: 1.5px solid var(--crm-remember-line);
  background: var(--crm-white-70);
  display: grid;
  place-items: center;
  transition: background 0.25s var(--crm-ease), border-color 0.25s var(--crm-ease);
}

.crm-auth-remember__box svg {
  width: 12px;
  height: 12px;
  color: var(--crm-white);
  opacity: 0;
  transition: opacity 0.2s var(--crm-ease);
}

.crm-auth-remember input:checked + .crm-auth-remember__box {
  background: var(--crm-brand);
  border-color: var(--crm-brand);
}

.crm-auth-remember input:checked + .crm-auth-remember__box svg { opacity: 1; }

.crm-auth-remember input:focus-visible + .crm-auth-remember__box {
  box-shadow: 0 0 0 4px var(--crm-brand-soft);
}

.crm-auth-forgot {
  font-size: 12.5px;
  color: var(--crm-brand);
  text-decoration: none;
  font-weight: 500;
}

.crm-auth-forgot:hover { color: var(--crm-brand-deep); text-decoration: underline; }

/* ===================== КНОПКА ===================== */
.crm-auth-submit {
  width: 100%;
  height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: none;
  border-radius: var(--crm-r-field);
  cursor: pointer;
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--crm-white);
  background: linear-gradient(150deg, var(--crm-brand-hi) 0%, var(--crm-brand) 55%, var(--crm-brand-deep) 100%);
  box-shadow: 0 12px 28px -12px var(--crm-brand-shadow);
  transition: transform 0.25s var(--crm-ease), box-shadow 0.3s var(--crm-ease), filter 0.25s var(--crm-ease);
  -webkit-tap-highlight-color: transparent;
}

.crm-auth-submit svg { width: 16px; height: 16px; transition: transform 0.3s var(--crm-ease); }

.crm-auth-submit:hover {
  filter: saturate(1.1) brightness(1.03);
  box-shadow: 0 16px 34px -12px var(--crm-brand-shadow-hover);
}

.crm-auth-submit:hover svg { transform: translateX(3px); }

.crm-auth-submit:active { transform: translateY(1px) scale(0.995); }

.crm-auth-submit:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--crm-brand-soft), 0 12px 28px -12px var(--crm-brand-shadow);
}

/* ===================== РАЗДЕЛИТЕЛЬ ===================== */
.crm-auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0 16px;
  font-family: var(--crm-mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--crm-ink-400);
}

.crm-auth-divider::before,
.crm-auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--crm-hair);
}

.crm-auth-help {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--crm-ink-400);
}

.crm-auth-help a { color: var(--crm-ink-900); font-weight: 500; text-decoration: none; }

.crm-auth-help a:hover { color: var(--crm-brand-deep); text-decoration: underline; }

/* ===================== ПОДВАЛ ===================== */
.crm-auth-foot {
  margin-top: 20px;
  font-size: 12.5px;
  color: var(--crm-ink-400);
}

.crm-auth-foot a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--crm-ink-900);
  font-weight: 500;
  text-decoration: none;
}

.crm-auth-foot a:hover { color: var(--crm-brand-deep); }

.crm-auth-foot svg { width: 14px; height: 14px; }

.crm-auth-legal {
  margin-top: 26px;
  text-align: center;
  font-family: var(--crm-mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--crm-ink-400);
  opacity: 0.8;
}

/* ===================== АДАПТИВ ===================== */
@media (max-width: 480px) {
  body { padding: 18px 14px; }
  .crm-auth-brand { margin-bottom: 18px; }
  .crm-auth-card { padding: 24px 20px 22px; border-radius: 22px; }
  .crm-auth-head h1 { font-size: 22px; }
  .crm-auth-legal { margin-top: 20px; }
}

/* При нехватке высоты центрирование сохраняется, но верх не обрезается */
@media (max-height: 720px) {
  body { align-items: flex-start; }
  .crm-auth { margin: auto 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
