/* === Мессенджер «Дом краски» (замена JivoSite) === */
/* Техотдел. Брендовые цвета сайта: #c8102e (красный), фон #fff */

#dk-messenger {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 99999;
  font-family: 'Golos Text', 'Segoe UI', Arial, sans-serif;
  font-size: 15px;
  color: #222;
}

/* --- Кнопка запуска --- */
.dk-msgr-btn {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: #c8102e;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(200, 16, 46, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
}
.dk-msgr-btn:hover { transform: scale(1.07); box-shadow: 0 8px 26px rgba(200, 16, 46, 0.55); }
.dk-msgr-btn svg { width: 30px; height: 30px; fill: #fff; }
.dk-msgr-btn.dk-msgr-open svg { display: none; }
.dk-msgr-btn .dk-msgr-x {
  display: none;
  color: #fff;
  font-size: 26px;
  line-height: 1;
  font-weight: 300;
}
.dk-msgr-btn.dk-msgr-open .dk-msgr-x { display: block; }

/* --- Бейдж непрочитанных --- */
.dk-msgr-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 22px;
  height: 22px;
  border-radius: 11px;
  background: #222;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  border: 2px solid #fff;
}
.dk-msgr-badge.dk-show { display: flex; }

/* --- Панель чата --- */
.dk-msgr-panel {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: 372px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 110px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 18px 60px rgba(20, 20, 30, 0.35);
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.dk-msgr-panel.dk-show { display: flex; }

/* --- Шапка --- */
.dk-msgr-header {
  background: #c8102e;
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
}
.dk-msgr-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.dk-msgr-avatar svg { width: 22px; height: 22px; fill: #fff; }
.dk-msgr-title { font-weight: 700; font-size: 16px; }
.dk-msgr-status { font-size: 12.5px; opacity: 0.92; display: flex; align-items: center; gap: 6px; }
.dk-msgr-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  flex: none;
}
.dk-msgr-dot.off { background: #fbbf24; }
.dk-msgr-close {
  margin-left: auto;
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.85;
  padding: 2px 6px;
  border-radius: 6px;
}
.dk-msgr-close:hover { opacity: 1; background: rgba(255, 255, 255, 0.15); }

/* --- Лента сообщений --- */
.dk-msgr-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: #f7f7f8;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.dk-msg {
  max-width: 78%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
  animation: dk-msg-in 0.25s ease;
}
@keyframes dk-msg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.dk-msg a { color: #c8102e; }
.dk-msg a:hover { text-decoration: underline; }
.dk-msg b, .dk-msg strong { font-weight: 600; }
/* Списки товаров в ответе бота: воздушность между пунктами */
.dk-msg-bot a + br + a { display: inline-block; margin-top: 3px; }
.dk-msg-bot { background: #fff; border: 1px solid #e6e6ea; border-bottom-left-radius: 4px; align-self: flex-start; }
.dk-msg-user { background: #c8102e; color: #fff; border-bottom-right-radius: 4px; align-self: flex-end; }
.dk-msg-manager { background: #e8f4e8; border: 1px solid #c9e0c9; border-bottom-left-radius: 4px; align-self: flex-start; }
.dk-msg-sys {
  align-self: center;
  background: transparent;
  color: #8a8a94;
  font-size: 12.5px;
  padding: 4px 10px;
  max-width: 90%;
  text-align: center;
}
.dk-msg-meta { font-size: 10.5px; color: #9aa0a8; margin-top: 3px; }
.dk-msg-bot .dk-msg-meta { color: #b0b6bd; }
.dk-msg-user .dk-msg-meta { color: rgba(255, 255, 255, 0.75); }
.dk-msg-ai-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: #c8102e;
  background: #fde8ec;
  border-radius: 5px;
  padding: 1px 6px;
  margin-bottom: 4px;
  text-transform: uppercase;
}

/* --- Быстрые ответы --- */
.dk-msgr-quick {
  display: flex;
  gap: 7px;
  padding: 8px 12px 4px;
  overflow-x: auto;
  flex: none;
  background: #f7f7f8;
}
.dk-msgr-chip {
  flex: none;
  background: #fff;
  border: 1px solid #d9d9e0;
  color: #444;
  border-radius: 16px;
  padding: 7px 13px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.dk-msgr-chip:hover { border-color: #c8102e; color: #c8102e; }

/* --- Индикатор набора --- */
.dk-msgr-typing { display: flex; gap: 4px; padding: 2px 14px 8px; background: #f7f7f8; }
.dk-msgr-typing span {
  width: 7px; height: 7px; border-radius: 50%; background: #c3c8cf;
  animation: dk-typing 1.2s infinite;
}
.dk-msgr-typing span:nth-child(2) { animation-delay: 0.2s; }
.dk-msgr-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dk-typing { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* --- Поле ввода --- */
.dk-msgr-input-bar {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #e6e6ea;
  background: #fff;
  flex: none;
}
.dk-msgr-input {
  flex: 1;
  border: 1px solid #d9d9e0;
  border-radius: 22px;
  padding: 10px 15px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.dk-msgr-input:focus { border-color: #c8102e; }
.dk-msgr-send {
  background: #c8102e;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  transition: transform 0.15s;
}
.dk-msgr-send:hover { transform: scale(1.08); }
.dk-msgr-send svg { width: 18px; height: 18px; fill: #fff; }
.dk-msgr-send:disabled { opacity: 0.5; cursor: default; transform: none; }

/* --- Офлайн-форма --- */
.dk-msgr-offline {
  padding: 18px 16px;
  background: #fff;
}
.dk-msgr-offline h3 { margin: 0 0 6px; font-size: 16px; }
.dk-msgr-offline p { margin: 0 0 14px; color: #666; font-size: 13.5px; }
.dk-msgr-offline input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #d9d9e0;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.dk-msgr-offline input:focus { border-color: #c8102e; }
.dk-msgr-offline button {
  width: 100%;
  background: #c8102e;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.dk-msgr-offline button:hover { background: #a50d25; }

.dk-msgr-powered {
  text-align: center;
  font-size: 11px;
  color: #b0b6bd;
  padding: 5px 0 7px;
  background: #fff;
}
.dk-msgr-powered b { color: #c8102e; }

@media (max-width: 480px) {
  #dk-messenger { bottom: 12px; right: 12px; }
  .dk-msgr-panel { width: calc(100vw - 24px); height: calc(100vh - 96px); bottom: 72px; }
}
