/* === Мессенджер «Лофт и дерево» (Консультант по дереву и лофт-материалам) === */
/* Премиальная палитра: глубокий графит (#12141a, #161924) и благородное золото (#deb15c, #c9983e) */

#dk-messenger {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  color: #e2e8f0;
}

/* --- Кнопка запуска виджета в лофт-стиле --- */
.dk-msgr-btn {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(145deg, #1e2330 0%, #141722 100%);
  border: 2px solid #deb15c;
  cursor: pointer;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.6), 0 0 18px rgba(222, 177, 92, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease, border-color 0.25s ease;
  position: relative;
  outline: none;
}

.dk-msgr-btn:hover {
  transform: scale(1.08) translateY(-2px);
  border-color: #f5cf7c;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.75), 0 0 26px rgba(222, 177, 92, 0.55);
}

.dk-msgr-btn svg {
  width: 30px;
  height: 30px;
  fill: #deb15c;
  transition: transform 0.25s ease;
}

.dk-msgr-btn:hover svg {
  transform: scale(1.05);
}

.dk-msgr-btn.dk-msgr-open svg {
  display: none;
}

.dk-msgr-btn .dk-msgr-x {
  display: none;
  color: #deb15c;
  font-size: 32px;
  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: linear-gradient(135deg, #deb15c 0%, #c9983e 100%);
  color: #0d0f14;
  font-size: 11.5px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  border: 2px solid #141722;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  animation: dk-badge-pulse 2s infinite;
}

.dk-msgr-badge.dk-show {
  display: flex;
}

@keyframes dk-badge-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* --- Всплывающая панель чата --- */
.dk-msgr-panel {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 570px;
  max-height: calc(100vh - 110px);
  background: #141722;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(222, 177, 92, 0.28);
  display: none;
  flex-direction: column;
  overflow: hidden;
  backdrop-filter: blur(16px);
  animation: dk-panel-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.dk-msgr-panel.dk-show {
  display: flex;
}

@keyframes dk-panel-in {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* --- Шапка чата --- */
.dk-msgr-header {
  background: linear-gradient(135deg, #1b202c 0%, #151824 100%);
  color: #ffffff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
  border-bottom: 1px solid rgba(222, 177, 92, 0.2);
}

.dk-msgr-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
  background: #141722;
  border: 1.5px solid rgba(222, 177, 92, 0.5);
  box-shadow: 0 0 10px rgba(222, 177, 92, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.dk-msgr-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.dk-msgr-avatar svg {
  width: 22px;
  height: 22px;
  fill: #deb15c;
}

.dk-msgr-title {
  font-weight: 700;
  font-size: 15px;
  color: #deb15c;
  line-height: 1.25;
}

.dk-msgr-status {
  font-size: 12px;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.dk-msgr-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  flex: none;
}

.dk-msgr-dot.off {
  background: #f59e0b;
  box-shadow: 0 0 8px #f59e0b;
}

.dk-msgr-close {
  margin-left: auto;
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: all 0.15s;
}

.dk-msgr-close:hover {
  color: #deb15c;
  background: rgba(222, 177, 92, 0.12);
}

/* --- Лента сообщений --- */
.dk-msgr-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  background: #0f1219;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dk-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  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: #deb15c;
  font-weight: 600;
  text-decoration: underline;
}

.dk-msg a:hover {
  color: #f3cf88;
}

.dk-msg b, .dk-msg strong {
  font-weight: 700;
  color: #fff;
}

/* Сообщения консультанта/бота */
.dk-msg-bot {
  background: #191e2b;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  color: #e2e8f0;
}

/* Сообщения пользователя */
.dk-msg-user {
  background: linear-gradient(135deg, #deb15c 0%, #c9983e 100%);
  color: #0d0f14;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(222, 177, 92, 0.25);
}

.dk-msg-user b, .dk-msg-user strong {
  color: #0d0f14;
}

.dk-msg-user a {
  color: #0d0f14;
}

/* Сообщения менеджера */
.dk-msg-manager {
  background: #1b283d;
  border: 1px solid #3b82f6;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  color: #f8fafc;
}

.dk-msg-manager::before {
  content: '👨‍💼 Менеджер: ';
  font-weight: 700;
  color: #60a5fa;
  display: block;
  font-size: 11px;
  margin-bottom: 3px;
}

/* Системные сообщения */
.dk-msg-sys {
  align-self: center;
  background: rgba(222, 177, 92, 0.08);
  border: 1px dashed rgba(222, 177, 92, 0.3);
  color: #deb15c;
  font-size: 12px;
  padding: 6px 12px;
  max-width: 90%;
  text-align: center;
  border-radius: 10px;
}

.dk-msg-meta {
  font-size: 10px;
  opacity: 0.65;
  margin-top: 4px;
  text-align: right;
}

.dk-msg-bot .dk-msg-meta {
  color: #94a3b8;
}

.dk-msg-user .dk-msg-meta {
  color: rgba(13, 15, 20, 0.7);
}

/* --- Быстрые кнопки (Chips) скрыты --- */
.dk-msgr-quick {
  display: none !important;
}

.dk-msgr-quick::-webkit-scrollbar {
  height: 4px;
}

.dk-msgr-quick::-webkit-scrollbar-thumb {
  background: rgba(222, 177, 92, 0.2);
  border-radius: 4px;
}

.dk-msgr-chip {
  flex: none;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(222, 177, 92, 0.3);
  color: #cbd5e1;
  border-radius: 16px;
  padding: 6px 12px;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.18s ease;
  font-family: inherit;
}

.dk-msgr-chip:hover {
  border-color: #deb15c;
  color: #deb15c;
  background: rgba(222, 177, 92, 0.12);
  transform: translateY(-1px);
}

/* --- Индикатор набора сообщения --- */
.dk-msgr-typing {
  display: flex;
  gap: 5px;
  padding: 4px 14px 8px;
  background: #0f1219;
}

.dk-msgr-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #deb15c;
  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.25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* --- Поле ввода сообщения --- */
.dk-msgr-input-bar {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: #141722;
  flex: none;
}

.dk-msgr-input {
  flex: 1;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  padding: 9px 15px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  background: #0f1219;
  color: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.dk-msgr-input:focus {
  border-color: #deb15c;
  box-shadow: 0 0 8px rgba(222, 177, 92, 0.25);
}

.dk-msgr-send {
  background: linear-gradient(135deg, #deb15c 0%, #c9983e 100%);
  border: none;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  transition: transform 0.15s, box-shadow 0.15s;
}

.dk-msgr-send:hover {
  transform: scale(1.08);
  box-shadow: 0 0 12px rgba(222, 177, 92, 0.45);
}

.dk-msgr-send svg {
  width: 17px;
  height: 17px;
  fill: #0d0f14;
}

.dk-msgr-send:disabled {
  opacity: 0.4;
  cursor: default;
  transform: none;
}

/* --- Офлайн форма обратной связи --- */
.dk-msgr-offline {
  padding: 20px 16px;
  background: #141722;
  color: #e2e8f0;
}

.dk-msgr-offline h3 {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 700;
  color: #deb15c;
}

.dk-msgr-offline p {
  margin: 0 0 14px;
  color: #94a3b8;
  font-size: 13px;
  line-height: 1.45;
}

.dk-msgr-offline input {
  width: 100%;
  box-sizing: border-box;
  background: #0f1219;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.dk-msgr-offline input:focus {
  border-color: #deb15c;
}

.dk-msgr-offline button {
  width: 100%;
  background: linear-gradient(135deg, #deb15c 0%, #c9983e 100%);
  color: #0d0f14;
  border: none;
  border-radius: 8px;
  padding: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}

.dk-msgr-offline button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(222, 177, 92, 0.35);
}

.dk-msgr-powered {
  text-align: center;
  font-size: 11px;
  color: #64748b;
  padding: 7px 0 8px;
  background: #10131b;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.dk-msgr-powered b {
  color: #deb15c;
}

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