/* ==========================================================================
   DNH Chat Widget Styles
   ========================================================================== */

/* ── Chat Bubble ──────────────────────── */
#dnh-chat-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9998;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--color-primary, #5B2D8E);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(91, 45, 142, 0.4);
  transition: transform 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease;
}
#dnh-chat-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(91, 45, 142, 0.5);
}
#dnh-chat-bubble.dnh-chat-bubble--hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}

/* ── Chat Panel ──────────────────────── */
#dnh-chat-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 48px);
  background: var(--color-bg, #faf8f5);
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.95);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
#dnh-chat-panel.dnh-chat-panel--open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* ── Header ──────────────────────── */
.dnh-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--color-primary, #5B2D8E);
  color: #fff;
}
.dnh-chat-header__info {
  display: flex;
  align-items: center;
  gap: 12px;
}
.dnh-chat-header__info strong {
  display: block;
  font-size: 15px;
  line-height: 1.2;
}
.dnh-chat-header__info small {
  display: block;
  font-size: 11px;
  opacity: 0.8;
  margin-top: 2px;
}
.dnh-chat-header__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #4ade80;
  flex-shrink: 0;
  animation: dnh-pulse 2s infinite;
}
@keyframes dnh-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.dnh-chat-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.dnh-chat-close:hover {
  opacity: 1;
}

/* ── Messages ──────────────────────── */
.dnh-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.dnh-chat-msg p {
  margin: 0;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  max-width: 85%;
  word-wrap: break-word;
}
.dnh-chat-msg--bot p {
  background: var(--color-surface-offset, #f0ebe4);
  color: var(--color-text, #1a1412);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}
.dnh-chat-msg--user p {
  background: var(--color-primary, #5B2D8E);
  color: #fff;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
  margin-left: auto;
}
.dnh-chat-msg--user {
  display: flex;
  justify-content: flex-end;
}

/* ── Typing Indicator ──────────────────────── */
.dnh-chat-typing p {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 12px 18px;
}
.dnh-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-text-muted, #6b5d52);
  animation: dnh-bounce 1.4s infinite ease-in-out;
}
.dnh-dot:nth-child(2) { animation-delay: 0.2s; }
.dnh-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes dnh-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ── Input ──────────────────────── */
.dnh-chat-input {
  display: flex;
  padding: 12px 16px;
  border-top: 1px solid var(--color-divider, #e8e0d8);
  gap: 8px;
  background: var(--color-bg, #faf8f5);
}
.dnh-chat-input input {
  flex: 1;
  border: 1px solid var(--color-border, #d4ccc4);
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 14px;
  font-family: inherit;
  background: var(--color-surface, #fff);
  color: var(--color-text, #1a1412);
  outline: none;
  transition: border-color 0.2s;
}
.dnh-chat-input input:focus {
  border-color: var(--color-primary, #5B2D8E);
}
.dnh-chat-input input::placeholder {
  color: var(--color-text-faint, #a89888);
}
.dnh-chat-input button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--color-primary, #5B2D8E);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}
.dnh-chat-input button:hover {
  background: var(--color-primary-hover, #4A1A8A);
}
.dnh-chat-input button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Mobile ──────────────────────── */
@media (max-width: 480px) {
  #dnh-chat-panel {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    max-width: 100vw;
    border-radius: 0;
  }
  #dnh-chat-bubble {
    bottom: 16px;
    right: 16px;
    width: 54px;
    height: 54px;
  }
}

/* ── Dark Mode ──────────────────────── */
[data-theme="dark"] #dnh-chat-panel {
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4);
}

/* ── Bot Message Markdown Styling ──────────────────────── */
.dnh-chat-msg--bot h3,
.dnh-chat-msg--bot h4,
.dnh-chat-msg--bot h5 {
  margin: 4px 14px 2px;
  padding: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--color-primary, #5B2D8E);
  line-height: 1.3;
}
.dnh-chat-msg--bot h3 { font-size: 15px; }

.dnh-chat-msg--bot ul,
.dnh-chat-msg--bot ol {
  margin: 4px 14px 4px 28px;
  padding: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-text, #1a1412);
}
.dnh-chat-msg--bot li {
  margin-bottom: 3px;
}
.dnh-chat-msg--bot strong {
  font-weight: 700;
  color: var(--color-primary, #5B2D8E);
}
.dnh-chat-msg--bot em {
  font-style: italic;
}
.dnh-chat-msg--bot code {
  background: rgba(91, 45, 142, 0.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 13px;
  font-family: 'SF Mono', 'Fira Code', monospace;
}
.dnh-chat-msg--bot a {
  color: var(--color-primary, #5B2D8E);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.dnh-chat-msg--bot a:hover {
  color: var(--color-primary-hover, #4A1A8A);
}
