/* Модалка входа/регистрации — единый файл, общий для scw.az и
   panel.scw.az (раньше panel просто подключала весь style.css сайта
   ради этого небольшого куска — один гигантский файл на двоих). Меняете
   здесь — держите вторую копию (на другом origin) в синхроне вручную,
   отдельного build-шага между двумя сайтами нет. Самодостаточный: сам
   определяет нужные ему CSS-переменные (--bg/--text/--sub/... — те же
   имена, что использует style.css на scw.az и инлайн-стили в панели),
   не полагается на то, что их где-то ещё объявили. */

/* Этот файл — ЕДИНСТВЕННЫЙ, что грузят страницы входа/регистрации в
   панели (style.css сайта с общим box-sizing:border-box сюда не
   попадает). Без этого сброса инпуты с width:100% + padding + border
   считались по content-box и были на ~26px шире контейнера — именно
   это и "поля выходят за окно". */
*, *::before, *::after {
  box-sizing: border-box;
}

:root {
  --bg: #0d0b1e;
  --bord: rgba(255, 255, 255, 0.07);
  --text: #e8e5ff;
  --sub: rgba(232, 229, 255, 0.5);
  --dim: rgba(232, 229, 255, 0.28);
  --acc: #6c5fff;
  --acc2: #00c2ff;
  --sans: "DM Sans", system-ui, sans-serif;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f7f8fb;
  --bord: rgba(17, 24, 39, 0.08);
  --text: #151923;
  --sub: rgba(21, 25, 35, 0.64);
  --dim: rgba(21, 25, 35, 0.38);
  --acc: #5448ee;
  --acc2: #0099cc;
  color-scheme: light;
}

/* Панель загружает ТОЛЬКО этот файл на страницах входа/регистрации
   (не весь style.css сайта) — без этого правила фон брать неоткуда,
   был бы белый браузерный дефолт вместо тёмной темы. */
html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  margin: 0;
}

[hidden] {
  display: none !important;
}

.spam-trap {
  position: absolute !important;
  left: -10000px !important;
  top: auto !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  padding: 18px;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s ease, visibility 0.22s;
}

.auth-modal.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.auth-modal-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 16%, rgba(0, 194, 255, 0.13), transparent 28%),
    radial-gradient(circle at 18% 80%, rgba(108, 95, 255, 0.13), transparent 30%),
    rgba(3, 3, 10, 0.76);
  backdrop-filter: blur(18px) saturate(1.15);
  opacity: 0;
  transition: opacity 0.24s ease;
}

.auth-modal.open .auth-modal-backdrop {
  opacity: 1;
}

.auth-modal-panel {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: 40px minmax(0, 1fr);
  width: min(492px, calc(100vw - 28px));
  max-height: calc(100vh - 32px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.085), rgba(255, 255, 255, 0.035)),
    rgba(13, 11, 30, 0.86);
  backdrop-filter: blur(22px) saturate(1.15);
  box-shadow:
    0 30px 110px rgba(0, 0, 0, 0.55),
    0 1px 0 rgba(255, 255, 255, 0.08) inset,
    0 0 0 1px rgba(0, 0, 0, 0.28);
  opacity: 0;
  transform: translateY(12px) scale(0.975);
  transform-origin: 50% 46%;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease, filter 0.2s ease;
}

.auth-modal-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.16), transparent 34%),
    radial-gradient(circle at 88% 8%, rgba(0, 194, 255, 0.11), transparent 28%);
  opacity: 0.76;
}

.auth-modal.open .auth-modal-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.auth-modal.closing .auth-modal-panel {
  filter: blur(2px);
  transform: translateY(6px) scale(0.985);
}

.auth-modal-head {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.055);
  background: rgba(255, 255, 255, 0.025);
}

.auth-modal-close {
  width: 30px;
  height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.045);
  color: rgba(232, 229, 255, 0.72);
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
  transition: background 0.15s, color 0.15s, transform 0.15s;
}

.auth-modal-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  transform: scale(1.04);
}

.auth-modal-body {
  position: relative;
  z-index: 1;
  min-height: 0;
  padding: 18px;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 3px;
  margin-bottom: 14px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.045);
}

.auth-tab {
  position: relative;
  border: 0;
  border-radius: 8px;
  padding: 8px 10px;
  background: transparent;
  color: rgba(232, 229, 255, 0.54);
  font: 600 0.8rem var(--sans);
  cursor: pointer;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s, transform 0.18s;
}

.auth-tab:hover {
  color: rgba(232, 229, 255, 0.78);
  transform: translateY(-1px);
}

.auth-tab.active {
  background: rgba(255, 255, 255, 0.11);
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16), 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
}

/* Вкладка остаётся кликабельной (не .is-disabled — тот ставит
   pointer-events:none) — клик по ней должен показывать сообщение
   "регистрация закрыта", а не просто ничего не делать. */
.auth-tab-closed {
  color: rgba(232, 229, 255, 0.32);
}

.close-reg {
  color: rgb(169, 60, 106);
  font-size: 1.2rem;
  line-height: 1.5;
  text-align: center;
  padding: 123px 4px;
  font-weight: bold;
}

.auth-copy h2 {
  font-family: var(--sans);
  font-size: 1.42rem;
  font-weight: 600;
  line-height: 1.12;
  margin-bottom: 5px;
  color: var(--text);
}

.auth-copy p {
  color: rgba(232, 229, 255, 0.52);
  font-size: 0.82rem;
  line-height: 1.42;
  margin-bottom: 12px;
}

.auth-form {
  display: none;
  flex-direction: column;
  gap: 11px;
}

.auth-form.active {
  display: flex;
  animation: authFormIn 0.22s ease both;
}

@keyframes authFormIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-form label {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: rgba(232, 229, 255, 0.68);
  font-size: 0.73rem;
  font-weight: 500;
  transition: color 0.16s;
}

.auth-form label:focus-within {
  color: rgba(232, 229, 255, 0.82);
}

/* Подсказка под полями Имя/Фамилия/Email при регистрации (panel/auth.js,
   функция H()) — добавляется отдельным <span> внутрь span-заголовка
   лейбла, но своего стиля не имело вообще: рендерилась обычным текстом
   того же цвета вплотную к заголовку ("Имя✓ Корректно" одной слипшейся
   строкой). display:block переносит её на свою строку даже будучи
   вложенной в инлайновый span заголовка — так ведут себя все основные
   браузеры. */
.field-hint {
  display: inline;
  margin-left: 7px;
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--sub);
}

.field-hint.error {
  color: #ef4444;
}

.field-hint.success {
  color: #22c55e;
}

.hint-icon {
  display: inline-block;
  margin-right: 2px;
  font-style: normal;
}

/* Поле пароля при регистрации — не просто title+input, а 5 элементов
   в одном label (title, инпут+кнопки, метр, текст силы, сетка правил).
   Единый gap:5px от .auth-form label тут выглядел так, будто сетка
   правил прилеплена прямо к заголовку "Пароль" — отдельный больший
   отступ именно для этого составного поля. */
.auth-password-field {
  gap: 8px;
}

.auth-password-rules {
  margin-top: 2px;
}

.auth-form input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  padding: 10px 12px;
  font: 0.88rem var(--sans);
  outline: none;
  transition: border-color 0.16s, background 0.16s, box-shadow 0.16s;
}

.auth-form input::placeholder {
  color: rgba(232, 229, 255, 0.28);
}

.auth-form input:focus {
  border-color: rgba(0, 194, 255, 0.45);
  background: rgba(255, 255, 255, 0.065);
  caret-color: #00c2ff;
  box-shadow: 0 0 0 3px rgba(0, 194, 255, 0.09), 0 10px 30px rgba(0, 0, 0, 0.12);
}

/* Три элемента в ряд: поле пароля (растягивается), кнопка-глаз
   (показать/скрыть, компактная), кнопка "Сгенерировать". Раньше на
   panel.scw.az здесь была CSS-сетка на 2 колонки при 3 элементах в
   разметке — третий элемент просто съезжал на отдельную строку. */
.auth-password-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.auth-password-wrap input {
  flex: 1 1 auto;
  min-width: 0;
}

.auth-password-toggle {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--sub);
  cursor: pointer;
  transition: background 0.16s, color 0.16s, border-color 0.16s;
}

.auth-password-toggle:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
}

.auth-password-toggle svg {
  width: 17px;
  height: 17px;
}

.auth-password-generate {
  min-height: 40px;
  border: 1px solid rgba(108, 95, 255, 0.28);
  border-radius: 10px;
  background: rgba(108, 95, 255, 0.13);
  color: var(--text);
  cursor: pointer;
  padding: 0 10px;
  font: 700 0.72rem var(--sans);
  white-space: nowrap;
  transition: background 0.16s, border-color 0.16s, transform 0.16s;
}

.auth-password-generate:hover {
  background: rgba(108, 95, 255, 0.2);
  border-color: rgba(108, 95, 255, 0.46);
  transform: translateY(-1px);
}

.auth-password-meter {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  margin-top: 4px;
}

.auth-password-meter span {
  height: 5px;
  border-radius: 999px;
  background: rgba(232, 229, 255, 0.14);
  transition: background 0.18s, box-shadow 0.18s;
}

.auth-password-meter[data-score="1"] span:nth-child(-n + 1) { background: #ef4444; }
.auth-password-meter[data-score="2"] span:nth-child(-n + 2) { background: #f59e0b; }
.auth-password-meter[data-score="3"] span:nth-child(-n + 3) { background: #a3e635; }
.auth-password-meter[data-score="4"] span:nth-child(-n + 4) {
  background: #22c55e;
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.32);
}

.auth-password-strength {
  color: rgba(232, 229, 255, 0.54);
  font-size: 0.7rem;
  line-height: 1.35;
}

.auth-password-rules {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px 10px;
  color: rgba(232, 229, 255, 0.46);
  font-size: 0.66rem;
  line-height: 1.3;
}

.auth-password-rules span {
  position: relative;
  padding-left: 13px;
  transition: color 0.16s;
}

.auth-password-rules span::before {
  content: "";
  position: absolute;
  top: 0.45em;
  left: 0;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(232, 229, 255, 0.24);
  transition: background 0.16s;
}

/* .is-met (зелёный, требование выполнено) и .is-error (красный, начали
   печатать, но требование ещё не выполнено) — раньше на сайте была
   только is-met, is-error нигде не была описана, хотя JS панели её уже
   расставлял: подсветка "печатаю — красное, дошёл до нормы — зелёное"
   не работала именно из-за отсутствия этого правила. */
.auth-password-rules span.is-met {
  color: #22c55e;
}

.auth-password-rules span.is-met::before {
  background: #22c55e;
}

.auth-password-rules span.is-error {
  color: #ef4444;
}

.auth-password-rules span.is-error::before {
  background: #ef4444;
}

.auth-submit {
  position: relative;
  overflow: hidden;
  width: 100%;
  margin-top: 10px;
  border: 0;
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0)),
    linear-gradient(135deg, #6c5fff, #00aee8);
  color: #fff;
  padding: 12px 14px;
  font: 700 0.88rem var(--sans);
  cursor: pointer;
  box-shadow: 0 12px 32px rgba(0, 194, 255, 0.18), 0 1px 0 rgba(255, 255, 255, 0.18) inset;
  transition: transform 0.16s, box-shadow 0.16s, opacity 0.16s;
}

.auth-submit::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transform: translateX(-120%);
  transition: transform 0.55s ease;
}

.auth-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 40px rgba(0, 194, 255, 0.22), 0 1px 0 rgba(255, 255, 255, 0.22) inset;
}

.auth-submit:hover::before {
  transform: translateX(120%);
}

.auth-submit:active {
  transform: translateY(0);
}

.auth-submit:disabled {
  cursor: wait;
  opacity: 0.65;
}

.auth-forgot-link {
  width: max-content;
  justify-self: center;
  margin: 2px auto 0;
  color: var(--sub);
  font: 600 0.78rem var(--sans);
  text-decoration: none;
  transition: color 0.15s;
}

.auth-forgot-link:hover {
  color: var(--text);
}

/* Серверные Flask-флешки (CSRF-ошибка, неверный пароль и т.п.) попадают
   сюда голым текстом через {{ messages[0] }} — классы .error/.success
   им не присваиваются (это только JS для сообщений от fetch-запросов),
   поэтому у самого .auth-message должен быть читаемый вид по
   умолчанию, а не только у модификаторов. Раньше без явного цвета текст
   был чёрным по чёрному. */
/* Пока форма грузится с panel.scw.az (fetch в app.js: scw.az сам
   разметку у себя больше не хранит) или если сеть подвела — вместо
   пустой модалки короткое состояние загрузки/ошибки с повтором. На
   panel.scw.az этих классов никогда не увидят — форма там рендерится
   сразу вместе со страницей, без fetch. */
.auth-modal-loading,
.auth-modal-error {
  padding: 40px 8px;
  text-align: center;
  font-size: 0.86rem;
  color: var(--sub);
}

.auth-modal-error [data-auth-retry] {
  margin-top: 10px;
  display: inline-block;
  padding: 7px 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font: 600 0.8rem var(--sans);
  cursor: pointer;
}

.auth-modal-error [data-auth-retry]:hover {
  background: rgba(255, 255, 255, 0.09);
}

.auth-message {
  display: none;
  margin-bottom: 10px;
  border: 1px solid rgba(248, 113, 113, 0.18);
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 0.78rem;
  line-height: 1.5;
  background: rgba(127, 29, 29, 0.24);
  color: #fecaca;
  backdrop-filter: blur(10px);
}

.auth-message:not(:empty) {
  display: block;
}

.auth-message.error {
  border-color: rgba(248, 113, 113, 0.18);
  background: rgba(127, 29, 29, 0.24);
  color: #fecaca;
}

.auth-message.success {
  border-color: rgba(52, 211, 153, 0.16);
  background: rgba(6, 78, 59, 0.24);
  color: #a7f3d0;
}

.auth-message.loading {
  border-color: rgba(0, 194, 255, 0.14);
  background: rgba(14, 116, 144, 0.18);
  color: rgba(232, 229, 255, 0.7);
}

body.auth-modal-open {
  overflow: hidden;
}

@media (max-height: 680px) {
  .auth-modal-body { padding: 12px 16px; }
  .auth-copy h2 { font-size: 1.26rem; }
  .auth-copy p { display: none; }
}

@media (max-width: 760px) {
  .auth-modal { padding: 10px; }
  .auth-modal-panel { width: min(100%, 492px); max-height: calc(100vh - 20px); border-radius: 18px; }
  .auth-copy h2 { font-size: 1.34rem; }
}

@media (max-width: 520px) {
  .auth-password-wrap { flex-wrap: wrap; }
  .auth-password-wrap input { flex-basis: 100%; }
  .auth-password-rules { grid-template-columns: 1fr; }
  .auth-password-generate { flex: 1 1 auto; }
}

@media (max-width: 420px) {
  .auth-modal { padding: 0; align-items: stretch; }
  .auth-modal-panel { width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; border: 0; }
  .auth-modal-body { padding: 16px; }
}

[data-theme="light"] .auth-modal-backdrop {
  background:
    radial-gradient(circle at 50% 16%, rgba(0, 153, 204, 0.13), transparent 28%),
    radial-gradient(circle at 18% 80%, rgba(84, 72, 238, 0.12), transparent 30%),
    rgba(247, 248, 251, 0.78);
}

[data-theme="light"] .auth-modal-panel {
  border-color: rgba(17, 24, 39, 0.1);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(245, 247, 251, 0.86)), #fff;
  box-shadow: 0 28px 80px rgba(17, 24, 39, 0.16), 0 1px 0 rgba(255, 255, 255, 0.8) inset;
}

[data-theme="light"] .auth-modal-panel::before {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.7), transparent 34%),
    radial-gradient(circle at 88% 8%, rgba(0, 153, 204, 0.08), transparent 28%);
}

[data-theme="light"] .auth-modal-head {
  border-bottom-color: rgba(17, 24, 39, 0.08);
  background: rgba(17, 24, 39, 0.025);
}

[data-theme="light"] .auth-modal-close {
  border-color: rgba(17, 24, 39, 0.08);
  background: rgba(17, 24, 39, 0.04);
  color: var(--sub);
}

[data-theme="light"] .auth-modal-close:hover {
  background: rgba(17, 24, 39, 0.07);
  color: var(--text);
}

[data-theme="light"] .auth-tabs {
  border-color: rgba(17, 24, 39, 0.08);
  background: rgba(17, 24, 39, 0.04);
}

[data-theme="light"] .auth-tab { color: var(--sub); }
[data-theme="light"] .auth-tab:hover { color: var(--text); }

[data-theme="light"] .auth-tab.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 8px 20px rgba(17, 24, 39, 0.08), 0 0 0 1px rgba(17, 24, 39, 0.06) inset;
}

[data-theme="light"] .auth-copy p,
[data-theme="light"] .auth-form label,
[data-theme="light"] .auth-form label:focus-within {
  color: var(--sub);
}

[data-theme="light"] .auth-form input {
  border-color: rgba(17, 24, 39, 0.11);
  background: #fff;
  color: var(--text);
}

[data-theme="light"] .auth-form input::placeholder {
  color: var(--dim);
}

[data-theme="light"] .auth-form input:focus {
  background: #fff;
  box-shadow: 0 0 0 3px rgba(0, 153, 204, 0.1), 0 10px 26px rgba(17, 24, 39, 0.08);
}

[data-theme="light"] .auth-message.error {
  border-color: rgba(220, 38, 38, 0.16);
  background: #fff1f2;
  color: #b91c1c;
}

[data-theme="light"] .auth-message.success {
  border-color: rgba(22, 163, 74, 0.16);
  background: #f0fdf4;
  color: #15803d;
}

[data-theme="light"] .auth-message.loading {
  border-color: rgba(0, 153, 204, 0.16);
  background: #f0f9ff;
  color: var(--sub);
}
