/* ==========================================================================
   DIMARIO BIKE MASTER — chat widget
   Стилістика підхоплює токени з style.css (--bg-panel, --accent, --line...).
   Якщо підключити цей файл на сторінці без style.css, використовуються
   фолбек-значення (другий аргумент var()).
   ========================================================================== */

.dbm-chat {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 9999;
  font-family: var(--f-body, "Manrope", -apple-system, "Segoe UI", sans-serif);
}

/* ---------- плаваюча кнопка ---------- */
.dbm-chat-fab {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 1px solid var(--line, #2c333c);
  background: var(--accent, #e8a317);
  color: #12151a;
  font-size: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  transition: transform 0.25s var(--ease, cubic-bezier(0.16, 1, 0.3, 1));
  position: relative;
}

.dbm-chat-fab:hover {
  transform: scale(1.06);
}

.dbm-chat-fab:active {
  transform: scale(0.96);
}

.dbm-chat-fab .dbm-fab-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ff5a5f;
  border: 2px solid var(--bg, #12151a);
}

.dbm-chat-fab .dbm-fab-icon-close {
  display: none;
}

.dbm-chat.is-open .dbm-chat-fab .dbm-fab-icon-open {
  display: none;
}

.dbm-chat.is-open .dbm-chat-fab .dbm-fab-icon-close {
  display: block;
}

/* ---------- вікно чату ---------- */
.dbm-chat-window {
  position: absolute;
  left: 0;
  bottom: 76px;
  width: 360px;
  max-width: calc(100vw - 40px);
  height: 520px;
  max-height: calc(100vh - 140px);
  background: var(--bg-panel, #1b2027);
  border: 1px solid var(--line, #2c333c);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.22s var(--ease, ease), transform 0.22s var(--ease, ease);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.dbm-chat.is-open .dbm-chat-window {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ---------- шапка ---------- */
.dbm-chat-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line, #2c333c);
  background: var(--bg-panel-2, #20262e);
  display: flex;
  align-items: center;
  gap: 12px;
}

.dbm-chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent, #e8a317);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.dbm-chat-header-text {
  min-width: 0;
}

.dbm-chat-title {
  font-family: var(--f-display, "Bebas Neue", sans-serif);
  font-size: 18px;
  letter-spacing: 0.03em;
  color: var(--text, #edeae2);
  text-transform: uppercase;
  line-height: 1;
}

.dbm-chat-status {
  font-family: var(--f-mono, "Space Mono", monospace);
  font-size: 11px;
  color: var(--text-dim, #8d95a3);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
}

.dbm-chat-status .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent, #e8a317);
  display: inline-block;
}

/* ---------- тіло чату ---------- */
.dbm-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--line, #2c333c) transparent;
}

.dbm-chat-body::-webkit-scrollbar {
  width: 6px;
}
.dbm-chat-body::-webkit-scrollbar-thumb {
  background: var(--line, #2c333c);
  border-radius: 3px;
}

.dbm-msg {
  max-width: 86%;
  padding: 10px 13px;
  border-radius: 3px;
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-line;
  animation: dbmFadeIn 0.2s ease;
}

@keyframes dbmFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.dbm-msg.bot {
  align-self: flex-start;
  background: var(--bg-panel-2, #20262e);
  border: 1px solid var(--line-soft, #232932);
  color: var(--text, #edeae2);
  border-bottom-left-radius: 0;
}

.dbm-msg.user {
  align-self: flex-end;
  background: var(--accent, #e8a317);
  color: #12151a;
  border-bottom-right-radius: 0;
  font-weight: 500;
}

.dbm-msg a {
  color: var(--accent-ink, #f0c14b);
  text-decoration: underline;
}
.dbm-msg.user a {
  color: #12151a;
}

/* ---------- швидкі кнопки ---------- */
.dbm-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-self: flex-start;
  max-width: 100%;
}

.dbm-quick-btn {
  border: 1px solid var(--line, #2c333c);
  background: transparent;
  color: var(--text, #edeae2);
  font-family: var(--f-body, inherit);
  font-size: 12.5px;
  padding: 7px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.dbm-quick-btn:hover {
  border-color: var(--accent, #e8a317);
  color: var(--accent-ink, #f0c14b);
}

.dbm-quick-btn.primary {
  background: var(--accent, #e8a317);
  border-color: var(--accent, #e8a317);
  color: #12151a;
  font-weight: 600;
}

.dbm-quick-btn.primary:hover {
  opacity: 0.9;
  color: #12151a;
}

/* ---------- typing indicator ---------- */
.dbm-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 12px 14px;
  background: var(--bg-panel-2, #20262e);
  border: 1px solid var(--line-soft, #232932);
  border-radius: 3px;
  border-bottom-left-radius: 0;
}
.dbm-typing span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-faint, #575f6b);
  animation: dbmBlink 1.1s infinite ease-in-out;
}
.dbm-typing span:nth-child(2) { animation-delay: 0.15s; }
.dbm-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes dbmBlink {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); }
}

/* ---------- футер / інпут ---------- */
.dbm-chat-footer {
  border-top: 1px solid var(--line, #2c333c);
  padding: 10px;
  display: flex;
  gap: 8px;
  background: var(--bg-panel-2, #20262e);
}

.dbm-chat-input {
  flex: 1;
  background: var(--bg, #12151a);
  border: 1px solid var(--line, #2c333c);
  border-radius: 20px;
  padding: 10px 14px;
  color: var(--text, #edeae2);
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
}

.dbm-chat-input:focus {
  border-color: var(--accent, #e8a317);
}

.dbm-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--accent, #e8a317);
  color: #12151a;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s ease;
}

.dbm-chat-send:hover {
  opacity: 0.9;
}

.dbm-chat-hint {
  font-family: var(--f-mono, "Space Mono", monospace);
  font-size: 10px;
  color: var(--text-faint, #575f6b);
  text-align: center;
  padding: 6px 10px 10px;
  background: var(--bg-panel-2, #20262e);
}

/* ---------- мобільна адаптація ---------- */
@media (max-width: 480px) {
  .dbm-chat {
    right: 12px;
    bottom: 12px;
  }
  .dbm-chat-window {
    width: calc(100vw - 24px);
    height: calc(100vh - 120px);
    bottom: 72px;
  }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .dbm-chat-fab,
  .dbm-chat-window,
  .dbm-msg {
    transition: none;
    animation: none;
  }
}
