/* Чат с ИИ-агентом. Цвета — переменные темы (theme.css), поэтому светлая и тёмная
   темы работают сами. Кнопка стоит над плавающим блоком .dp-float. */
.dp-chat-launch {
  position: fixed; right: 16px; bottom: 76px; z-index: 60;
  display: inline-flex; align-items: center; gap: 10px;
  padding: 12px 18px 12px 14px; border: 0; border-radius: 999px;
  background: var(--color-text); color: var(--color-bg);
  font: 600 14px/1 var(--font-body); cursor: pointer;
  box-shadow: var(--shadow-lg); transition: transform .15s ease;
}
.dp-chat-launch:hover { transform: translateY(-2px); }
.dp-chat-launch svg { width: 20px; height: 20px; flex: none; }
.dp-chat-launch .dp-chat-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #3ddc84;
  box-shadow: 0 0 0 0 rgba(61, 220, 132, .6); animation: dp-chat-pulse 2s infinite;
}
@keyframes dp-chat-pulse { 70% { box-shadow: 0 0 0 8px rgba(61, 220, 132, 0); } 100% { box-shadow: 0 0 0 0 rgba(61, 220, 132, 0); } }
body.dp-chat-open .dp-chat-launch, body.dp-cookie-open .dp-chat-launch { display: none; }

.dp-chat {
  position: fixed; right: 16px; bottom: 16px; z-index: 80;
  width: min(392px, calc(100vw - 24px)); height: min(600px, calc(100dvh - 32px));
  display: flex; flex-direction: column; overflow: hidden;
  border-radius: 22px; background: var(--color-bg); color: var(--color-text);
  border: 1px solid var(--color-divider); box-shadow: var(--shadow-lg);
  font-family: var(--font-body);
}
.dp-chat[hidden] { display: none; }
.dp-chat-head {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  background: var(--color-surface); border-bottom: 1px solid var(--color-divider);
}
.dp-chat-avatar {
  width: 38px; height: 38px; flex: none; border-radius: 50%;
  display: grid; place-items: center; background: var(--color-accent); color: #fff;
}
.dp-chat-avatar svg { width: 20px; height: 20px; }
.dp-chat-title { font: 700 14.5px/1.2 var(--font-body); }
.dp-chat-sub { font-size: 12px; opacity: .7; margin-top: 2px; }
.dp-chat-close {
  margin-left: auto; width: 34px; height: 34px; border: 0; border-radius: 50%;
  background: transparent; color: inherit; cursor: pointer; display: grid; place-items: center;
}
.dp-chat-close:hover { background: var(--color-divider); }
.dp-chat-close svg { width: 18px; height: 18px; }

.dp-chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.dp-chat-msg {
  max-width: 86%; padding: 10px 14px; border-radius: 16px;
  font-size: 14.5px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere;
}
.dp-chat-msg.is-agent { align-self: flex-start; background: var(--color-surface); border-bottom-left-radius: 6px; }
.dp-chat-msg.is-user { align-self: flex-end; background: var(--color-accent); color: #fff; border-bottom-right-radius: 6px; }
.dp-chat-msg.is-note { align-self: center; background: transparent; font-size: 12.5px; opacity: .7; text-align: center; padding: 2px 8px; }
.dp-chat-typing { display: inline-flex; gap: 4px; align-items: center; height: 18px; }
.dp-chat-typing i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .35; animation: dp-chat-blink 1.2s infinite; }
.dp-chat-typing i:nth-child(2) { animation-delay: .2s; }
.dp-chat-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes dp-chat-blink { 40% { opacity: 1; } }

.dp-chat-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 12px; }
.dp-chat-chips button {
  border: 1px solid var(--color-divider); background: var(--color-bg); color: inherit;
  border-radius: 999px; padding: 7px 12px; font: 500 13px/1.2 var(--font-body); cursor: pointer;
}
.dp-chat-chips button:hover { border-color: var(--color-accent); color: var(--color-accent); }

.dp-chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--color-divider); }
.dp-chat-form textarea {
  flex: 1; resize: none; min-height: 44px; max-height: 120px; padding: 11px 14px;
  border: 1px solid var(--color-divider); border-radius: 14px;
  background: var(--color-bg); color: inherit; font: 14.5px/1.4 var(--font-body);
}
/* Поле само растёт по тексту (до 120px), системная полоса прокрутки не нужна:
   в тёмной теме она белая и ломает скруглённый угол */
.dp-chat-form textarea { box-sizing: border-box; overflow-y: auto; scrollbar-width: none; }
.dp-chat-form textarea::-webkit-scrollbar { display: none; }
.dp-chat-log { scrollbar-width: thin; scrollbar-color: var(--color-divider) transparent; }
.dp-chat-form textarea:focus { outline: 2px solid var(--color-accent); outline-offset: -1px; border-color: transparent; }
.dp-chat-send {
  width: 44px; height: 44px; flex: none; border: 0; border-radius: 14px;
  background: var(--color-accent); color: #fff; cursor: pointer; display: grid; place-items: center;
}
.dp-chat-send:disabled { opacity: .45; cursor: default; }
.dp-chat-send svg { width: 19px; height: 19px; }
.dp-chat-foot { padding: 0 16px 12px; font-size: 11.5px; line-height: 1.4; opacity: .62; }
.dp-chat-foot a { color: inherit; }

@media (max-width: 640px) {
  .dp-chat { right: 0; bottom: 0; width: 100vw; height: 100dvh; border-radius: 0; border: 0; }
  .dp-chat-launch span.dp-chat-label { display: none; }
  .dp-chat-launch { padding: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .dp-chat-launch, .dp-chat-dot, .dp-chat-typing i { animation: none !important; transition: none; }
}

/* ─ Карточка агента в шапке главной — встроенный чат (data-agent-inline): тот же разговор,
     что и в плавающем окне. Лента растёт до предела и дальше прокручивается внутри карточки ─ */
.dp-hero-log { flex: none; padding: 0 4px 0 0; max-height: 300px; min-height: 0; }
.dp-hero-log .dp-chat-msg { max-width: 88%; font-size: 14px; line-height: 1.45; padding: 12px 16px; border-radius: 20px; }
.dp-hero-log .dp-chat-msg.is-agent { background: var(--color-accent); color: #fff; border-bottom-left-radius: 6px; }
.dp-hero-log .dp-chat-msg.is-user { background: var(--color-surface); color: inherit; border-bottom-right-radius: 6px; }
.dp-hero-log .dp-chat-msg.is-note { padding: 2px 8px; font-size: 12.5px; }
.dp-hero-chips { padding: 0; }
.dp-hero-chips:empty { display: none; }
.dp-hero-chips button {
  padding: 7px 14px; background: transparent; font: 500 13px/1.3 var(--font-body);
  transition: border-color .15s ease, color .15s ease;
}
.dp-hero-chips button:focus-visible { border-color: var(--color-accent); color: var(--color-accent); }
.dp-hero-form { display: flex; gap: 8px; margin: 0; }
.dp-hero-form input {
  flex: 1; min-width: 0; height: 44px; padding: 0 16px; box-sizing: border-box;
  border: 1px solid var(--color-divider); border-radius: 999px;
  background: var(--color-bg); color: inherit; font: 14px/1 var(--font-body);
}
.dp-hero-form input:focus { outline: 2px solid var(--color-accent); outline-offset: -1px; border-color: transparent; }
.dp-hero-form button {
  width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%;
  background: var(--color-accent); color: #fff; cursor: pointer; display: grid; place-items: center;
}
.dp-hero-form button:hover { background: var(--color-accent-600); }
.dp-hero-live { box-shadow: 0 0 0 0 rgba(61, 220, 132, .6); animation: dp-chat-pulse 2s infinite; }
@media (prefers-reduced-motion: reduce) { .dp-hero-live { animation: none; } }
