/* =========================================================
   chat-widget.css — Floating Zalo + Haiku chatbot
   Brand: ink #1A1A1A · accent #E8825A · Zalo blue #0068FF
   ========================================================= */

#bds-chat-root {
  --cw-zalo: #0068FF;
  --cw-zalo-dark: #0050CC;
  --cw-accent: #E8825A;
  --cw-accent-dark: #D06840;
  --cw-ink: #1A1A1A;
  --cw-paper: #FFFFFF;
  --cw-cream: #F5F0E8;
  --cw-line: rgba(26, 26, 26, 0.08);
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9998;
  font-family: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.55;
  color: var(--cw-ink);
}

/* ── FAB STACK (Đăng tin / Tìm / Chat) ───────────────────── */
.cw-fab-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.cw-fab {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px 10px 12px;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(26, 26, 26, 0.18), 0 2px 6px rgba(26, 26, 26, 0.08);
  transition: transform 200ms cubic-bezier(0.16, 1, 0.3, 1), box-shadow 200ms ease, background 200ms ease;
}
.cw-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(26, 26, 26, 0.24), 0 4px 10px rgba(26, 26, 26, 0.12);
}
.cw-fab:focus-visible {
  outline: 3px solid rgba(232, 130, 90, 0.55);
  outline-offset: 3px;
}
.cw-fab svg { width: 22px; height: 22px; flex: none; }
.cw-fab-label { white-space: nowrap; }

.cw-fab-post {
  background: var(--cw-accent);
  color: #fff;
}
.cw-fab-post:hover { background: var(--cw-accent-dark); }

.cw-fab-search {
  background: #fff;
  color: var(--cw-ink);
  border: 1px solid var(--cw-line);
}
.cw-fab-search:hover {
  background: var(--cw-cream);
  color: var(--cw-accent);
  border-color: var(--cw-accent);
}

.cw-fab-chat {
  background: var(--cw-zalo);
  color: #fff;
}
.cw-fab-chat:hover { background: var(--cw-zalo-dark); }

.cw-pulse {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  background: #2BC25F;
  border: 2px solid #fff;
  border-radius: 50%;
  animation: cw-pulse 2.4s ease-in-out infinite;
}
@keyframes cw-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.85; }
}

/* ── PANEL ────────────────────────────────────────────────── */
#bds-chat-panel {
  position: fixed;
  bottom: 84px;
  right: 20px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 540px;
  max-height: calc(100vh - 110px);
  background: var(--cw-paper);
  border: 1px solid var(--cw-line);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18), 0 4px 12px rgba(0, 0, 0, 0.08);
  display: none;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  z-index: 9999;
}
#bds-chat-panel.cw-open {
  display: flex;
  animation: cw-pop 240ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes cw-pop {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.cw-header {
  padding: 14px 16px;
  background: linear-gradient(135deg, #0068FF 0%, #2A8AFF 100%);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
}
.cw-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fff;
  color: var(--cw-zalo);
  display: grid;
  place-items: center;
  flex: none;
}
.cw-avatar svg { width: 20px; height: 20px; }
.cw-title { flex: 1; min-width: 0; }
.cw-title strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.005em;
}
.cw-title span {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  opacity: 0.9;
}
.cw-title span::before {
  content: "";
  width: 7px;
  height: 7px;
  background: #2BC25F;
  border-radius: 50%;
  display: inline-block;
}
.cw-close {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: none;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 150ms;
}
.cw-close:hover { background: rgba(255, 255, 255, 0.28); }
.cw-close svg { width: 16px; height: 16px; }

/* Body */
.cw-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--cw-cream);
  scroll-behavior: smooth;
}
.cw-body::-webkit-scrollbar { width: 6px; }
.cw-body::-webkit-scrollbar-thumb { background: rgba(26, 26, 26, 0.18); border-radius: 3px; }

.cw-msg {
  margin-bottom: 10px;
  display: flex;
  animation: cw-msg-in 200ms ease-out;
}
@keyframes cw-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.cw-msg-bubble {
  max-width: 85%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.cw-msg-bot {
  justify-content: flex-start;
}
.cw-msg-bot .cw-msg-bubble {
  background: #fff;
  color: var(--cw-ink);
  border: 1px solid var(--cw-line);
  border-bottom-left-radius: 4px;
}
.cw-msg-user {
  justify-content: flex-end;
}
.cw-msg-user .cw-msg-bubble {
  background: var(--cw-zalo);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.cw-msg-bubble a {
  color: inherit;
  text-decoration: underline;
  font-weight: 600;
}
.cw-msg-user .cw-msg-bubble a { color: #fff; }

/* Quick actions */
.cw-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 10px 0;
}
.cw-quick button {
  padding: 6px 11px;
  background: #fff;
  border: 1px solid rgba(0, 104, 255, 0.3);
  color: var(--cw-zalo);
  border-radius: 14px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  transition: all 150ms;
}
.cw-quick button:hover {
  background: var(--cw-zalo);
  color: #fff;
  border-color: var(--cw-zalo);
}

/* Typing indicator */
.cw-typing {
  display: inline-flex;
  gap: 4px;
  padding: 11px 14px;
}
.cw-typing span {
  width: 6px;
  height: 6px;
  background: rgba(26, 26, 26, 0.4);
  border-radius: 50%;
  animation: cw-blink 1.2s infinite ease-in-out;
}
.cw-typing span:nth-child(2) { animation-delay: 0.2s; }
.cw-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes cw-blink {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* Footer */
.cw-footer {
  padding: 10px 12px;
  background: #fff;
  border-top: 1px solid var(--cw-line);
}
.cw-zalo-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px;
  margin-bottom: 8px;
  background: rgba(0, 104, 255, 0.06);
  color: var(--cw-zalo);
  text-decoration: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  transition: background 150ms;
}
.cw-zalo-link:hover { background: rgba(0, 104, 255, 0.14); }
.cw-zalo-link svg { width: 18px; height: 18px; }

.cw-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.cw-input {
  flex: 1;
  border: 1px solid var(--cw-line);
  border-radius: 12px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  resize: none;
  max-height: 100px;
  background: var(--cw-cream);
  color: var(--cw-ink);
  outline: none;
  transition: border-color 150ms;
}
.cw-input:focus { border-color: var(--cw-zalo); background: #fff; }
.cw-send {
  flex: none;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: var(--cw-zalo);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 150ms, transform 150ms;
}
.cw-send:hover { background: var(--cw-zalo-dark); transform: scale(1.05); }
.cw-send:disabled {
  background: rgba(26, 26, 26, 0.18);
  cursor: not-allowed;
  transform: none;
}
.cw-send svg { width: 18px; height: 18px; }

/* ── SEARCH MODAL ─────────────────────────────────────────── */
.cw-search-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 80px 16px 16px 16px;
}
.cw-search-modal.cw-open { display: flex; animation: cw-modal-fade 200ms ease-out; }
@keyframes cw-modal-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.cw-search-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 26, 26, 0.55);
  backdrop-filter: blur(2px);
}
.cw-search-modal__panel {
  position: relative;
  width: 100%;
  max-width: 560px;
  background: var(--cw-paper);
  border-radius: 16px;
  padding: 28px 28px 24px 28px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35), 0 6px 18px rgba(0, 0, 0, 0.12);
  animation: cw-modal-pop 280ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes cw-modal-pop {
  from { opacity: 0; transform: translateY(-12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.cw-search-modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--cw-ink);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 150ms;
}
.cw-search-modal__close:hover { background: var(--cw-cream); }
.cw-search-modal__close svg { width: 16px; height: 16px; }

.cw-search-modal__head { margin-bottom: 16px; }
.cw-search-modal__eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cw-accent);
  margin-bottom: 8px;
}
.cw-search-modal__head h3 {
  font-family: 'Lora', Georgia, serif;
  font-size: 24px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--cw-ink);
  margin: 0 0 6px 0;
}
.cw-search-modal__head p {
  font-size: 14px;
  color: rgba(26, 26, 26, 0.65);
  margin: 0;
}

.cw-search-modal__input-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--cw-cream);
  border: 1.5px solid var(--cw-line);
  border-radius: 12px;
  padding: 6px 6px 6px 14px;
  transition: border-color 150ms;
}
.cw-search-modal__input-row:focus-within {
  border-color: var(--cw-accent);
  background: #fff;
}
.cw-search-modal__icon {
  display: grid;
  place-items: center;
  color: rgba(26, 26, 26, 0.55);
  flex: none;
}
.cw-search-modal__icon svg { width: 18px; height: 18px; }
.cw-search-modal__input-row input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  padding: 10px 0;
  font-family: inherit;
  font-size: 15px;
  color: var(--cw-ink);
  min-width: 0;
}
.cw-search-modal__input-row input::-webkit-search-cancel-button { display: none; }
.cw-search-modal__submit {
  flex: none;
  background: var(--cw-accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms;
}
.cw-search-modal__submit:hover { background: var(--cw-accent-dark); }

.cw-search-modal__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}
.cw-chip {
  background: #fff;
  border: 1px solid var(--cw-line);
  border-radius: 999px;
  padding: 6px 12px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--cw-ink);
  cursor: pointer;
  transition: all 150ms;
}
.cw-chip:hover {
  background: var(--cw-accent);
  color: #fff;
  border-color: var(--cw-accent);
}

.cw-search-modal__shortcuts {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--cw-line);
  font-size: 13px;
  color: rgba(26, 26, 26, 0.55);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.cw-search-modal__shortcuts a {
  color: var(--cw-accent);
  text-decoration: none;
  font-weight: 600;
}
.cw-search-modal__shortcuts a:hover { text-decoration: underline; }

/* ── Mobile ───────────────────────────────────────────────── */
@media (max-width: 480px) {
  #bds-chat-root { bottom: 14px; right: 14px; }
  .cw-fab { padding: 12px; }
  .cw-fab-label { display: none; }
  .cw-fab svg { width: 24px; height: 24px; }
  #bds-chat-panel {
    width: calc(100vw - 24px);
    height: calc(100vh - 100px);
    bottom: 80px;
    right: 12px;
  }
  .cw-search-modal { padding: 40px 12px 12px 12px; }
  .cw-search-modal__panel { padding: 24px 20px 20px 20px; }
  .cw-search-modal__head h3 { font-size: 20px; }
}
