/* ═══════════════════════════════════════════
   VegiFlow Chat Widget — Styles
   ═══════════════════════════════════════════ */

/* ── Floating Button ──────────────────────── */
.vf-chat-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #22a65a, #1d8f4e);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(34, 166, 90, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.25s ease;
}
.vf-chat-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(34, 166, 90, 0.45);
}
.vf-chat-btn:active {
  transform: scale(0.96);
}
.vf-chat-btn svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
}

/* ── Chat Window ──────────────────────────── */
.vf-chat-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 120px);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 12px 48px rgba(34, 166, 90, 0.12),
              0 4px 16px rgba(0, 0, 0, 0.06);
  display: none;
  flex-direction: column;
  z-index: 1001;
  overflow: hidden;
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
}
.vf-chat-window.open {
  display: flex;
  animation: vfSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* ── Header ───────────────────────────────── */
.vf-chat-header {
  background: linear-gradient(135deg, #22a65a, #14532d);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.vf-chat-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.vf-chat-header-avatar {
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,0.2);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.vf-chat-header-info h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.vf-chat-header-info span {
  font-size: 12px;
  opacity: 0.8;
}
.vf-chat-close {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: background 0.15s ease;
}
.vf-chat-close:hover {
  background: rgba(255,255,255,0.15);
}

/* ── Messages ─────────────────────────────── */
.vf-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #faf9f7;
  scroll-behavior: smooth;
}

.vf-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.vf-msg-user {
  align-self: flex-end;
  background: #22a65a;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.vf-msg-bot {
  align-self: flex-start;
  background: #fff;
  color: #1a1815;
  border: 1px solid #e5e0d8;
  border-bottom-left-radius: 4px;
}

/* ── Markdown rendering trong tin nhắn bot ── */
.vf-msg-md {
  /* override white-space: pre-wrap của .vf-msg — marked đã tự tạo <br>/<p> */
  white-space: normal;
}
.vf-msg-md p { margin: 0 0 6px; }
.vf-msg-md p:last-child { margin-bottom: 0; }
.vf-msg-md strong, .vf-msg-md b { font-weight: 600; }
.vf-msg-md em, .vf-msg-md i { font-style: italic; }
.vf-msg-md ul, .vf-msg-md ol { margin: 4px 0 6px; padding-left: 18px; }
.vf-msg-md li { margin: 2px 0; }
.vf-msg-md code {
  background: #f3efe8;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 13px;
  font-family: ui-monospace, 'JetBrains Mono', monospace;
}
.vf-msg-md a { color: #1d8f4e; text-decoration: underline; word-break: break-word; }
.vf-msg-md img {
  max-width: 100%;
  max-height: 180px;
  border-radius: 10px;
  margin: 6px 0;
  cursor: zoom-in;
  display: block;
  object-fit: cover;
}

/* ── Typing Indicator ─────────────────────── */
.vf-typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid #e5e0d8;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}
.vf-typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9a938c;
  animation: vfBounce 1.4s infinite both;
}
.vf-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.vf-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes vfBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ── Input Area ───────────────────────────── */
.vf-chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid #e5e0d8;
  display: flex;
  gap: 8px;
  background: #fff;
  flex-shrink: 0;
}
.vf-chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #e5e0d8;
  border-radius: 24px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s ease;
  color: #1a1815;
}
.vf-chat-input:focus {
  border-color: #22a65a;
}
.vf-chat-input::placeholder {
  color: #9a938c;
}
.vf-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #22a65a;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease, transform 0.15s ease;
}
.vf-chat-send:hover {
  background: #1d8f4e;
  transform: scale(1.05);
}
.vf-chat-send:active {
  transform: scale(0.95);
}
.vf-chat-send:disabled {
  background: #d4cfc8;
  cursor: not-allowed;
  transform: none;
}
.vf-chat-send svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* ── New Chat Button ──────────────────────── */
.vf-new-chat-btn {
  align-self: center;
  padding: 6px 16px;
  border: 1px solid #e5e0d8;
  border-radius: 20px;
  background: #fff;
  color: #6b6560;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}
.vf-new-chat-btn:hover {
  border-color: #22a65a;
  color: #22a65a;
}

/* ── Scrollbar ────────────────────────────── */
.vf-chat-messages::-webkit-scrollbar {
  width: 4px;
}
.vf-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.vf-chat-messages::-webkit-scrollbar-thumb {
  background: #d4cfc8;
  border-radius: 2px;
}

/* ── Quick Reply Suggestions ──────────────── */
.vf-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.vf-suggestion-btn {
  padding: 6px 12px;
  border: 1px solid #22a65a;
  border-radius: 16px;
  background: #fff;
  color: #1d8f4e;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}
.vf-suggestion-btn:hover {
  background: rgba(34, 166, 90, 0.06);
}

/* ── Lightbox (phóng to ảnh bot) ─────────── */
.vf-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  cursor: zoom-out;
  padding: 16px;
  animation: vfFade 0.2s ease;
}
.vf-lightbox img {
  max-width: 92vw;
  max-height: 92vh;
  border-radius: 10px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
}
@keyframes vfFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Product Cards ────────────────────────── */
.vf-product-gallery {
  align-self: flex-start;
  max-width: 88%;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
}
.vf-product-gallery::-webkit-scrollbar { height: 4px; }
.vf-product-gallery::-webkit-scrollbar-thumb { background: #d4cfc8; border-radius: 2px; }
.vf-product-card {
  flex: 0 0 148px;
  background: #fff;
  border: 1px solid #e5e0d8;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.vf-product-card:hover {
  box-shadow: 0 4px 16px rgba(34, 166, 90, 0.12);
  transform: translateY(-2px);
}
.vf-pc-img {
  width: 100%;
  height: 110px;
  object-fit: cover;
  background: #f3efe8;
}
.vf-pc-noimg {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: #9a938c;
}
.vf-pc-body {
  padding: 8px 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.vf-pc-name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  color: #1a1815;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.vf-pc-price {
  font-size: 13px;
  font-weight: 600;
  color: #22a65a;
  display: flex;
  gap: 5px;
  align-items: baseline;
  flex-wrap: wrap;
}
.vf-pc-old {
  font-size: 11px;
  color: #9a938c;
  text-decoration: line-through;
  font-weight: 400;
}
.vf-pc-desc {
  font-size: 11px;
  color: #6b6560;
  line-height: 1.35;
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.vf-pc-btn {
  display: block;
  text-align: center;
  padding: 8px;
  font-size: 12px;
  font-weight: 600;
  background: #22a65a;
  color: #fff;
  text-decoration: none;
}
.vf-pc-btn:hover {
  background: #1d8f4e;
}

/* ── Mobile Responsive ────────────────────── */
@media (max-width: 480px) {
  .vf-chat-window {
    bottom: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }
  .vf-chat-btn {
    bottom: 16px;
    right: 16px;
  }
}
