*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body { font-family: 'Inter', sans-serif; background: #f5f5f5; color: #333; }

/* ── Demo page ──────────────────────────────────────── */
.demo-page { min-height: 100vh; display: flex; flex-direction: column; }

.demo-header {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 24px; color: white; flex-wrap: wrap;
}
.demo-logo { height: 44px; width: auto; object-fit: contain; flex-shrink: 0; }
.demo-header h1 { font-size: 1.4rem; font-weight: 600; }
.demo-header p  { font-size: 0.875rem; opacity: 0.85; margin-top: 2px; }

.demo-main {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; padding: 48px 20px;
}
.demo-main h2 { font-size: 1.6rem; margin-bottom: 12px; }
.demo-main p  { color: #666; max-width: 480px; line-height: 1.6; margin-bottom: 28px; }

.demo-open-btn {
  color: white; border: none; padding: 14px 32px;
  border-radius: 8px; font-size: 1rem; font-weight: 500;
  cursor: pointer; transition: opacity 0.2s; touch-action: manipulation;
}
.demo-open-btn:hover { opacity: 0.88; }

/* ── Widget container ────────────────────────────────── */
#chatbot-widget {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  display: flex; flex-direction: column; align-items: flex-end; gap: 12px;
}

.chat-toggle {
  width: 56px; height: 56px; border-radius: 50%; border: none;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25); transition: transform 0.2s;
  touch-action: manipulation; flex-shrink: 0;
}
.chat-toggle:hover { transform: scale(1.07); }
.chat-toggle:active { transform: scale(0.96); }

/* ── Chat window ─────────────────────────────────────── */
.chat-window {
  width: 360px;
  height: 520px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.25s ease;
}
.chat-window.hidden { display: none; }

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

.chat-header {
  padding: 14px 16px; color: white;
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; font-size: 0.95rem; flex-shrink: 0;
}
.online-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #69f0ae; box-shadow: 0 0 0 2px rgba(255,255,255,0.4);
  flex-shrink: 0;
}

.messages {
  flex: 1; overflow-y: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
  scroll-behavior: smooth; -webkit-overflow-scrolling: touch;
}

.message {
  max-width: 84%; padding: 10px 13px; border-radius: 14px;
  font-size: 0.875rem; line-height: 1.55; word-break: break-word;
}
.message.user {
  background: var(--color-primary); color: white;
  align-self: flex-end; border-bottom-right-radius: 4px;
}
.message.assistant {
  background: #f1f1f1; color: #222;
  align-self: flex-start; border-bottom-left-radius: 4px;
}

.sources { margin-top: 6px; display: flex; flex-direction: column; gap: 3px; }
.sources a {
  font-size: 0.76rem; color: var(--color-primary);
  text-decoration: none; opacity: 0.85; word-break: break-all;
}
.sources a:hover { opacity: 1; text-decoration: underline; }

/* Suggested chips */
.suggestions {
  padding: 0 10px 8px; display: flex; flex-wrap: wrap; gap: 6px;
}
.suggestion-chip {
  background: #f0f0f0; border: 1px solid #ddd; border-radius: 20px;
  padding: 6px 11px; font-size: 0.78rem; cursor: pointer;
  transition: background 0.15s; touch-action: manipulation;
  white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.suggestion-chip:hover  { background: #e4e4e4; }
.suggestion-chip:active { background: #d8d8d8; }

/* Typing indicator */
.typing {
  padding: 4px 18px 8px; display: flex; gap: 5px; align-items: center;
}
.typing.hidden { display: none; }
.typing span {
  width: 7px; height: 7px; border-radius: 50%; background: #bbb;
  animation: bounce 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
  40%           { transform: scale(1);   opacity: 1; }
}

/* Input row */
.chat-input-row {
  display: flex; gap: 8px; padding: 10px 12px;
  border-top: 1px solid #eee; flex-shrink: 0;
}
#chat-input {
  flex: 1; border: 1px solid #ddd; border-radius: 8px;
  padding: 9px 12px; font-size: 0.9rem; outline: none;
  font-family: inherit; transition: border-color 0.2s;
  min-width: 0; -webkit-appearance: none;
}
#chat-input:focus { border-color: var(--color-primary); }

#send-btn {
  width: 40px; height: 40px; border-radius: 8px; border: none;
  cursor: pointer; display: flex; align-items: center;
  justify-content: center; transition: opacity 0.2s;
  flex-shrink: 0; touch-action: manipulation;
}
#send-btn:hover  { opacity: 0.85; }
#send-btn:active { opacity: 0.7; }
#send-btn:disabled, #chat-input:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Mobile: tablet (≤ 600px) ───────────────────────── */
@media (max-width: 600px) {
  #chatbot-widget { bottom: 16px; right: 14px; }

  .chat-window {
    width: calc(100vw - 28px);
    height: calc(100svh - 100px);
    max-height: 540px;
    border-radius: 14px;
  }

  .demo-header { padding: 14px 16px; gap: 12px; }
  .demo-header h1 { font-size: 1.2rem; }
  .demo-logo { height: 38px; }
  .demo-main { padding: 36px 16px; }
  .demo-main h2 { font-size: 1.4rem; }
}

/* ── Mobile: small phones (≤ 380px) ─────────────────── */
@media (max-width: 380px) {
  #chatbot-widget { bottom: 12px; right: 10px; }

  .chat-window {
    width: calc(100vw - 20px);
    height: calc(100svh - 80px);
    max-height: 500px;
    border-radius: 12px;
  }

  .chat-toggle { width: 50px; height: 50px; }
  .message { font-size: 0.83rem; padding: 9px 11px; }
  .suggestion-chip { font-size: 0.75rem; padding: 5px 9px; }
}
