/* Deb8er Assistant widget — brand palette */
:root {
  --db8-black: #0B0E14;
  --db8-midnight: #111827;
  --db8-border: rgba(255, 255, 255, 0.08);
  --db8-b1: #a68af9;
  --db8-b2: #3ABEFF;
  --db8-cyan: #22d3ee;
  --db8-white: #E5E7EB;
  --db8-gray: #9CA3AF;
  --db8-font: "Montserrat", system-ui, -apple-system, sans-serif;
}

#db8-chat-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147483000;
  font-family: var(--db8-font);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Toggle button ---------- */
#db8-chat-fab {
  width: 58px;
  height: 58px;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--db8-b1), var(--db8-b2));
  box-shadow: 0 8px 24px rgba(166, 138, 249, 0.45), 0 4px 12px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  margin-left: auto;
  overflow: hidden;
}
#db8-chat-fab:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 12px 30px rgba(58, 190, 255, 0.5), 0 6px 16px rgba(0, 0, 0, 0.4);
}
#db8-chat-fab .db8-fab-chat {
  display: block;
  line-height: 1;
}
#db8-chat-fab .db8-fab-close {
  width: 28px;
  height: 28px;
  fill: #fff;
  display: none;
}

/* ---------- Panel ---------- */
#db8-chat-panel {
  position: absolute;
  right: 0;
  bottom: 72px;
  width: 372px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 110px);
  display: flex;
  flex-direction: column;
  background: var(--db8-midnight);
  border: 1px solid var(--db8-border);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
#db8-chat-root.db8-open #db8-chat-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ---------- Header ---------- */
#db8-chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(120deg, rgba(166, 138, 249, 0.16), rgba(58, 190, 255, 0.12));
  border-bottom: 1px solid var(--db8-border);
  flex-shrink: 0;
}
#db8-chat-head .db8-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
#db8-chat-head .db8-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
#db8-chat-head .db8-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--db8-white);
}
#db8-chat-head .db8-subtitle {
  font-size: 11px;
  color: var(--db8-gray);
  margin-top: 1px;
}
#db8-chat-head .db8-head-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
}
#db8-chat-head button {
  width: 28px;
  height: 28px;
  border: 1px solid var(--db8-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--db8-gray);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, border-color 0.15s ease;
}
#db8-chat-head button:hover {
  color: var(--db8-cyan);
  border-color: rgba(34, 211, 238, 0.4);
}
#db8-chat-head button svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

/* ---------- Messages ---------- */
#db8-chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(166, 138, 249, 0.35) transparent;
}
#db8-chat-msgs::-webkit-scrollbar {
  width: 6px;
}
#db8-chat-msgs::-webkit-scrollbar-thumb {
  background: rgba(166, 138, 249, 0.35);
  border-radius: 3px;
}
#db8-chat-msgs::-webkit-scrollbar-track {
  background: transparent;
}

.db8-msg {
  max-width: 86%;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.db8-msg.db8-bot {
  align-self: flex-start;
}
.db8-msg.db8-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.db8-msg .db8-avatar {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.db8-msg .db8-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.db8-msg.db8-user .db8-avatar {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(166, 138, 249, 0.4);
}
.db8-msg .db8-bubble {
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  color: var(--db8-white);
  word-break: break-word;
  white-space: normal;
}
.db8-msg.db8-bot .db8-bubble {
  background: #1a2133;
  border: 1px solid var(--db8-border);
  border-bottom-left-radius: 4px;
}
.db8-msg.db8-user .db8-bubble {
  background: linear-gradient(135deg, rgba(166, 138, 249, 0.85), rgba(58, 190, 255, 0.85));
  border-bottom-right-radius: 4px;
}
.db8-msg .db8-bubble p {
  margin: 0 0 6px;
}
.db8-msg .db8-bubble p:last-child {
  margin-bottom: 0;
}
.db8-msg .db8-bubble ul {
  margin: 6px 0;
  padding-left: 18px;
}
.db8-msg .db8-bubble ol {
  margin: 6px 0;
  padding-left: 20px;
}
.db8-msg .db8-bubble li {
  margin: 2px 0;
}
.db8-msg .db8-bubble strong {
  color: var(--db8-cyan);
}

/* Typing indicator */
.db8-typing .db8-bubble {
  display: flex;
  gap: 4px;
  padding: 14px 16px;
}
.db8-typing .db8-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--db8-gray);
  animation: db8-blink 1.2s infinite ease-in-out;
}
.db8-typing .db8-dot:nth-child(2) {
  animation-delay: 0.15s;
}
.db8-typing .db8-dot:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes db8-blink {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

/* Quick replies */
#db8-chat-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 10px;
  flex-shrink: 0;
}
.db8-chip {
  border: 1px solid rgba(166, 138, 249, 0.45);
  background: rgba(166, 138, 249, 0.1);
  color: var(--db8-white);
  font-size: 12px;
  font-family: var(--db8-font);
  padding: 6px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.db8-chip:hover {
  background: rgba(166, 138, 249, 0.24);
  border-color: var(--db8-b1);
}

/* ---------- Input ---------- */
#db8-chat-foot {
  border-top: 1px solid var(--db8-border);
  padding: 10px 12px;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.15);
}
#db8-chat-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
#db8-chat-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--db8-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--db8-white);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13.5px;
  font-family: var(--db8-font);
  max-height: 96px;
  outline: none;
  transition: border-color 0.15s ease;
}
#db8-chat-input::placeholder {
  color: var(--db8-gray);
}
#db8-chat-input:focus {
  border-color: rgba(166, 138, 249, 0.6);
}
#db8-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--db8-b1), var(--db8-b2));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
#db8-chat-send:hover {
  transform: translateY(-1px);
}
#db8-chat-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}
#db8-chat-send svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}
#db8-chat-note {
  text-align: center;
  font-size: 10.5px;
  color: var(--db8-gray);
  padding: 6px 8px 0;
}
#db8-chat-note a {
  color: var(--db8-cyan);
  text-decoration: none;
}

@media (max-width: 480px) {
  #db8-chat-panel {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
    right: 12px;
    bottom: 64px;
    height: calc(100vh - 100px);
    max-height: calc(100vh - 100px);
  }
  #db8-chat-root {
    right: 12px;
    bottom: 12px;
  }
}
