/* ============================================================
   BDKazak — шторка «Ассистент» (волна 2 аудита UI, 26.09.2026).
   План: Plans/ui_wave2_2026-09-26/plan.md.

   Перенесено из встроенного <style> в
   apps/assistant/templates/assistant/_panel.html — сторож
   apps/core/tests/test_ui_typography_guard.py запрещает <style> в
   вычищенных шаблонах. Отдельный модульный файл, а не раздел
   ui_partials.css: apps/assistant — самостоятельное приложение со
   своей разметкой на КАЖДОЙ странице (шторка в base.html), и файл
   параллельно правит второй исполнитель волны — отдельный модуль
   снимает риск коллизии на одном файле. Подключается из base.html
   последним из проектных CSS, версия — как у соседних файлов.

   Кегли — только var(--bdk-fs-*): 11→12 (xs), 15→14 (без суффикса),
   17→16 (lg), 20 без изменений (title), 13 и 22 — ровно посередине
   между двумя ступенями шкалы, округлены вниз (13→12, 22→20) вслед
   за прецедентом самой шкалы (site.css: проба 15→14 при том же
   расстоянии до 16). Вид и поведение панели не менялись. */

:root {
  --asst-accent:    var(--ios-accent, #007aff);
  --asst-bg:        var(--ios-bg-sheet, #ffffff);
  --asst-separator: var(--ios-separator, rgba(60,60,67,0.12));
  --asst-shadow:    -4px 0 24px rgba(0,0,0,0.12);
  --asst-width:     360px;
  --asst-anim-in:   cubic-bezier(0.32, 0.72, 0, 1);
  --asst-anim-out:  cubic-bezier(0.4, 0, 1, 1);
  --asst-font:      -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
}

/* FAB ассистента скрыт: единая FAB-кнопка в base.html (UX-редизайн W1-6,
   «не более одной плавающей кнопки»). Панель открывается по событию
   «bdk-open-assistant». */
#assistant-fab {
  display: none !important;
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--asst-accent);
  border: none;
  color: #fff;
  font-size: var(--bdk-fs-title);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1048;
  box-shadow: 0 4px 16px rgba(0,122,255,0.35);
  transition: transform 120ms ease, box-shadow 120ms ease;
  -webkit-tap-highlight-color: transparent;
}
#assistant-fab:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 20px rgba(0,122,255,0.45);
}
#assistant-fab:active { transform: scale(0.94); }

/* ── Десктоп: боковая панель ──────────────────────────────────────── */
#assistant-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: var(--asst-width);
  background: var(--asst-bg);
  box-shadow: var(--asst-shadow);
  z-index: 1047;
  display: flex;
  flex-direction: column;
  font-family: var(--asst-font);
  transform: translateX(100%);
  transition: transform 400ms var(--asst-anim-in);
}
#assistant-panel.is-open {
  transform: translateX(0);
}

/* ── Шапка панели ─────────────────────────────────────────────────── */
.asst-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--asst-separator);
  min-height: 56px;
}
.asst-header__title {
  font-size: var(--bdk-fs-lg);
  font-weight: 500;
  letter-spacing: 0;
  color: #1c1c1e;
  margin: 0;
}
.asst-header__close {
  background: none;
  border: none;
  padding: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--asst-accent);
  font-size: var(--bdk-fs-lg);
  font-weight: 400;
  cursor: pointer;
  border-radius: var(--bdk-radius, 12px);
  -webkit-tap-highlight-color: transparent;
  transition: opacity 120ms linear;
}
.asst-header__close:hover { opacity: 0.7; }

/* ── Список сообщений ─────────────────────────────────────────────── */
#assistant-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.assistant-msg {
  max-width: 88%;
  word-break: break-word;
}
.assistant-msg--user {
  align-self: flex-end;
}
.assistant-msg--assistant {
  align-self: flex-start;
}
.assistant-msg__body {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: var(--bdk-fs);
  line-height: 20px;
}
.assistant-msg--user .assistant-msg__body {
  background: var(--asst-accent);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.assistant-msg--assistant .assistant-msg__body {
  background: rgba(120,120,128,0.12);
  color: #1c1c1e;
  border-bottom-left-radius: 6px;
}
.assistant-msg__meta {
  margin-top: 4px;
  padding-left: 4px;
}
.assistant-msg__badge {
  font-size: var(--bdk-fs-xs);
  background: rgba(0,122,255,0.12);
  color: var(--asst-accent);
  border-radius: 6px;
  padding: 2px 6px;
}

/* ── Пустое состояние ─────────────────────────────────────────────── */
.asst-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #6b6b70;
  font-size: var(--bdk-fs);
  padding: 24px;
}

/* ── Форма ввода ──────────────────────────────────────────────────── */
.asst-form {
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--asst-separator);
  background: var(--asst-bg);
}
.asst-form__row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.asst-form__textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--asst-separator);
  border-radius: var(--bdk-radius, 12px);
  padding: 10px 14px;
  font-size: var(--bdk-fs);
  font-family: var(--asst-font);
  line-height: 20px;
  color: #1c1c1e;
  background: #f2f2f7;
  outline: none;
  transition: border-color 120ms linear;
  min-height: 44px;
  max-height: 120px;
  overflow-y: auto;
}
.asst-form__textarea:focus {
  border-color: var(--asst-accent);
}
.asst-form__submit {
  height: 50px;
  min-width: 50px;
  border-radius: var(--bdk-radius, 12px);
  background: var(--asst-accent);
  border: none;
  color: #fff;
  font-size: var(--bdk-fs-title);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 120ms linear;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.asst-form__submit:disabled { opacity: 0.5; cursor: default; }
.asst-form__submit:not(:disabled):hover { opacity: 0.85; }

/* ── Дисклеймер ───────────────────────────────────────────────────── */
.asst-disclaimer {
  text-align: center;
  font-size: var(--bdk-fs-xs);
  color: #6b6b70;
  padding: 0 16px 8px;
}

/* ── Индикатор отправки ───────────────────────────────────────────── */
#assistant-sending {
  display: none;
  font-size: var(--bdk-fs-xs);
  color: var(--asst-accent);
  padding: 4px 0;
}
.htmx-request #assistant-sending { display: block; }

/* ── Mobile: iOS-sheet снизу (<992px) ────────────────────────────── */
@media (max-width: 991.98px) {
  #assistant-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    max-height: 90vh;
    max-height: 90dvh;
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -0.5px 0 rgba(0,0,0,0.08), 0 -16px 48px rgba(0,0,0,0.18);
    transform: translateY(100%);
  }
  #assistant-panel.is-open {
    transform: translateY(0);
  }
  /* Грабер сверху */
  #assistant-panel::before {
    content: "";
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 5px;
    border-radius: 2.5px;
    background: rgba(60,60,67,0.30);
    pointer-events: none;
  }
  .asst-header {
    padding-top: 22px;
  }
}

/* ── Backdrop (mobile) ────────────────────────────────────────────── */
#assistant-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1046;
}
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  #assistant-backdrop {
    background: rgba(0,0,0,0.25);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
            backdrop-filter: blur(12px) saturate(180%);
  }
}
#assistant-backdrop.is-open { display: block; }

@media (min-width: 992px) {
  #assistant-backdrop { display: none !important; }
}

/* ── Reduced motion ───────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  #assistant-panel,
  #assistant-panel.is-open {
    transition: none;
  }
}

/* ── FAB «Сообщить о проблеме» — базовое позиционирование и анимация ─ */
.bdk-feedback-fab {
  right: 24px;
  transition: right 400ms cubic-bezier(0.32, 0.72, 0, 1);
}

/* ── Сдвиг FAB «Сообщить о проблеме» когда панель ассистента открыта ─
   На десктопе панель выезжает справа (360px). Мегафон позиционируется
   right:24px и перекрывает кнопку «Отправить» внутри панели.
   Решение: сдвигаем мегафон левее на ширину панели + зазор 8px.
   На мобильном (<992px) панель — sheet снизу, мегафон там не мешает. */
@media (min-width: 992px) {
  body.assistant-panel-open .bdk-feedback-fab {
    right: calc(var(--asst-width, 360px) + 16px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .bdk-feedback-fab {
    transition: none;
  }
}
