/* polish.css — visual polish layer on top of Pico + app.css.
   Purely additive: tweaks shadows, transitions, focus rings, hover-lift,
   HTMX loading states, slightly larger badge typography for 50+ operators.
   Не использует !important. Откатить — убрать <link> из base.html. */

:root {
  --pl-shadow-card: 0 2px 8px rgba(15, 23, 42, 0.06),
                    0 4px 16px rgba(15, 23, 42, 0.04);
  --pl-shadow-card-hover: 0 6px 20px rgba(29, 79, 138, 0.10),
                          0 2px 6px rgba(15, 23, 42, 0.05);
  --pl-shadow-btn-hover: 0 4px 12px rgba(29, 79, 138, 0.18),
                         0 1px 2px rgba(15, 23, 42, 0.05);
  --pl-radius: 0.7rem;
  --pl-radius-sm: 0.45rem;
  --pl-transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --pl-focus-ring: 0 0 0 3px rgba(29, 79, 138, 0.18);
  --pl-brand: #1d4f8a;
  --pl-brand-soft: #eaf1fb;
}

/* ──────────────────────────────────────────────────────────
   КАРТОЧКИ / ПАНЕЛИ
   ────────────────────────────────────────────────────────── */
article {
  box-shadow: var(--pl-shadow-card);
  border-radius: var(--pl-radius);
  transition: var(--pl-transition);
}
article:hover {
  box-shadow: var(--pl-shadow-card-hover);
}

.kpi,
.oprosnik-card,
.gen-progress,
.verify-card,
.hero,
.pdf-frame {
  box-shadow: var(--pl-shadow-card);
  border-radius: var(--pl-radius);
  transition: var(--pl-transition);
}
.kpi:hover,
.oprosnik-card:hover {
  box-shadow: var(--pl-shadow-card-hover);
  transform: translateY(-1px);
}

/* Hero — крупнее и теплее */
.hero {
  padding: 1.6rem 1.8rem;
}
.hero h2 {
  font-size: clamp(1.25rem, 1rem + 1vw, 1.7rem);
  line-height: 1.25;
}

/* ──────────────────────────────────────────────────────────
   КНОПКИ И ССЫЛКИ-КНОПКИ
   ────────────────────────────────────────────────────────── */
button,
[role="button"],
input[type="submit"] {
  transition: var(--pl-transition);
  border-radius: var(--pl-radius-sm);
}
button:not(:disabled):hover,
[role="button"]:not([aria-disabled="true"]):hover,
input[type="submit"]:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: var(--pl-shadow-btn-hover);
}
button:not(:disabled):active,
[role="button"]:not([aria-disabled="true"]):active,
input[type="submit"]:not(:disabled):active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

/* Большая «главная» кнопка ─ ещё чуть выраженнее */
.btn-generate {
  border-radius: var(--pl-radius-sm);
  letter-spacing: 0.01em;
}
.btn-generate:not(:disabled):hover {
  box-shadow: 0 8px 22px rgba(29, 79, 138, 0.28),
              0 2px 6px rgba(15, 23, 42, 0.08);
}

/* ──────────────────────────────────────────────────────────
   ИНПУТЫ / СЕЛЕКТЫ
   ────────────────────────────────────────────────────────── */
input,
select,
textarea {
  transition: var(--pl-transition);
  border-radius: var(--pl-radius-sm);
}

/* Focus ring — единый для всех интерактивных элементов */
button:focus-visible,
[role="button"]:focus-visible,
input:focus,
select:focus,
textarea:focus,
a:focus-visible {
  box-shadow: var(--pl-focus-ring);
  outline: none;
}

/* ──────────────────────────────────────────────────────────
   БЕЙДЖИ — крупнее и контрастнее
   ────────────────────────────────────────────────────────── */
.badge {
  padding: 0.18rem 0.7rem;
  font-size: 0.82rem;
  letter-spacing: 0.01em;
  font-weight: 600;
}

/* ──────────────────────────────────────────────────────────
   НАВИГАЦИЯ
   ────────────────────────────────────────────────────────── */
.app-nav {
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04),
              0 4px 12px rgba(15, 23, 42, 0.03);
}
.app-nav a {
  border-radius: var(--pl-radius-sm);
  padding-inline: 0.35rem;
  transition: var(--pl-transition);
}
.app-nav a:hover {
  background: var(--pl-brand-soft);
}
.app-nav [aria-current="page"] {
  background: var(--pl-brand-soft);
}
.app-nav a.nav-pdf {
  background: linear-gradient(135deg, #fff3d6 0%, #ffe7a8 100%);
  color: #5b3b00;
  font-weight: 600;
  border: 1px solid #f0c674;
  box-shadow: 0 1px 2px rgba(155, 110, 0, 0.18);
}
.app-nav a.nav-pdf:hover {
  background: linear-gradient(135deg, #ffe7a8 0%, #f7d273 100%);
  transform: translateY(-1px);
}

/* ──────────────────────────────────────────────────────────
   ТАБЛИЦЫ — чуть бо́льший воздух
   ────────────────────────────────────────────────────────── */
table.tight th,
table.tight td {
  padding: 0.55rem 0.7rem;
}
.overflow-auto {
  border-radius: var(--pl-radius-sm);
}

/* ──────────────────────────────────────────────────────────
   HTMX LOADING STATES
   ────────────────────────────────────────────────────────── */

/* Глобальный fixed индикатор справа-снизу пока на странице есть hx-request */
body.htmx-request::after {
  content: "Загружаем…";
  position: fixed;
  bottom: 1.1rem;
  right: 1.1rem;
  padding: 0.5rem 0.9rem 0.5rem 2.2rem;
  background: var(--pl-brand);
  color: #fff;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  box-shadow: 0 6px 18px rgba(29, 79, 138, 0.25);
  z-index: 900;
  pointer-events: none;
  animation: pl-fade-in 180ms ease;
}
body.htmx-request::before {
  content: "";
  position: fixed;
  bottom: 1.35rem;
  right: 9.1rem; /* положение в пилле */
  width: 0.85rem;
  height: 0.85rem;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  z-index: 901;
  pointer-events: none;
  animation: pl-spin 700ms linear infinite;
}

@keyframes pl-spin {
  to { transform: rotate(360deg); }
}
@keyframes pl-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Форма во время отправки — приглушаем + блокируем повторный submit */
form.htmx-request {
  opacity: 0.7;
  pointer-events: none;
  position: relative;
}

/* Скелетон-пульс для карточки опросника (пока грузится preview) */
.oprosnik-skeleton {
  position: relative;
  overflow: hidden;
}
.oprosnik-skeleton::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    100deg,
    rgba(0,0,0,0) 30%,
    rgba(29, 79, 138, 0.06) 50%,
    rgba(0,0,0,0) 70%
  );
  animation: pl-skeleton 1.4s ease-in-out infinite;
}
@keyframes pl-skeleton {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* HTMX swap fade — плавно меняем содержимое после ответа */
[hx-swap]:not(.htmx-request) {
  transition: opacity 180ms ease;
}
.htmx-swapping {
  opacity: 0;
}
.htmx-settling {
  opacity: 1;
}

/* ──────────────────────────────────────────────────────────
   ДЕТАЛИ / FIELDSETS
   ────────────────────────────────────────────────────────── */
fieldset {
  border: 1px solid var(--pico-muted-border-color, #e0e3e8);
  border-radius: var(--pl-radius);
  padding: 0.9rem 1.1rem 1.05rem;
  margin-bottom: 1rem;
  background: #fff;
  box-shadow: var(--pl-shadow-card);
}
fieldset legend {
  font-weight: 600;
  color: var(--pl-brand);
  padding-inline: 0.4rem;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
  text-transform: none;
}

details {
  border-radius: var(--pl-radius-sm);
}
details[open] {
  padding-bottom: 0.4rem;
}

/* ──────────────────────────────────────────────────────────
   МОДАЛКА (dialog)
   ────────────────────────────────────────────────────────── */
dialog[open] {
  backdrop-filter: blur(2px);
}
dialog article {
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.18),
              0 4px 12px rgba(15, 23, 42, 0.08);
  border-radius: 0.85rem;
}

/* ──────────────────────────────────────────────────────────
   АДАПТИВ — мобильный
   ────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .hero {
    flex-direction: column;
    align-items: stretch;
    padding: 1.1rem 1.2rem;
  }
  .section-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
  }
  .actions-row {
    gap: 0.4rem;
  }
  body.htmx-request::after { font-size: 0.78rem; padding-left: 2rem; }
}

/* ──────────────────────────────────────────────────────────
   МИКРО-ПОЛИРОВКА
   ────────────────────────────────────────────────────────── */
code {
  background: var(--pl-brand-soft);
  color: var(--pl-brand);
  padding: 0.05rem 0.4rem;
  border-radius: 0.3rem;
  font-size: 0.92em;
}

.crumbs {
  font-size: 0.88rem;
}
.crumbs a {
  border-bottom: 1px dotted transparent;
  transition: var(--pl-transition);
}
.crumbs a:hover {
  color: var(--pl-brand);
  border-bottom-color: var(--pl-brand);
}

.toms-list li {
  padding-block: 0.65rem;
}

/* Чтобы кнопка «Скачать» в списке томов не "прыгала" */
.toms-list li > span:first-child {
  min-width: 0;
  flex: 1 1 auto;
}
