/* ====================================================
   METCHAN CHATBOX AVANCÉE - chatbox.css
   Option A — Streaming + historique + voix + suggestions
   ==================================================== */

#chatbox-widget {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 10000;
}

/* ── TOGGLE BUTTON ─── */
#chat-toggle {
  width: 60px;
  height: 60px;
  background: var(--brand-gold);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(200,169,106,0.5);
  transition: all 0.25s ease;
  border: none;
  cursor: pointer;
  position: relative;
}
#chat-toggle:hover {
  background: #B89960;
  transform: scale(1.1);
  box-shadow: 0 6px 30px rgba(200,169,106,0.6);
}
.chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #e53e3e;
  color: white;
  font-size: 10px;
  font-weight: 700;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
}

/* ── CHAT PANEL ─── */
.chat-panel {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 370px;
  max-height: 580px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(15,47,38,0.1);
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-panel.hidden { display: none; }

@media (max-width: 480px) {
  .chat-panel {
    width: calc(100vw - 2rem);
    right: -0.5rem;
    bottom: 75px;
    max-height: 70vh;
  }
}

/* ── CHAT HEADER ─── */
.chat-header {
  background: var(--brand-green);
  color: white;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.chat-logo {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: contain;
  background: white;
  padding: 4px;
}
.chat-header > div { flex: 1; }
.chat-header strong { display: block; font-size: 0.95rem; }
.online-dot {
  font-size: 0.75rem;
  color: #68d391;
}
.chat-close {
  color: rgba(255,255,255,0.7);
  font-size: 1.2rem;
  transition: color 0.2s;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
}
.chat-close:hover { color: white; }

/* ── CHAT TOOLBAR ─── */
.chat-toolbar {
  display: flex;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: var(--brand-cream);
  border-bottom: 1px solid rgba(15,47,38,0.08);
}
.toolbar-btn {
  font-size: 0.75rem;
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
  border: 1px solid rgba(15,47,38,0.2);
  color: var(--brand-green);
  transition: all 0.2s;
  background: white;
}
.toolbar-btn:hover, .toolbar-btn.active {
  background: var(--brand-green);
  color: white;
  border-color: var(--brand-green);
}

/* ── CHAT MESSAGES ─── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(15,47,38,0.2); border-radius: 4px; }

.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}
.chat-msg.bot { align-self: flex-start; }
.chat-msg.user { align-self: flex-end; }
.chat-msg p {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0;
}
.chat-msg.bot p {
  background: var(--brand-cream);
  color: var(--brand-charcoal);
  border-bottom-left-radius: 4px;
}
.chat-msg.user p {
  background: var(--brand-green);
  color: white;
  border-bottom-right-radius: 4px;
}
.chat-msg-time {
  font-size: 0.7rem;
  color: #999;
  margin-top: 0.25rem;
  padding: 0 0.5rem;
}
.chat-msg.user .chat-msg-time { text-align: right; }

/* ── TYPING INDICATOR ─── */
.chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.75rem 1rem;
  background: var(--brand-cream);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}
.typing-dot {
  width: 7px;
  height: 7px;
  background: var(--brand-green);
  border-radius: 50%;
  animation: typingBounce 1.4s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%,60%,100% { transform: translateY(0); opacity: 0.6; }
  30%          { transform: translateY(-8px); opacity: 1; }
}

/* ── STREAMING CURSOR ─── */
.streaming-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--brand-green);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 0.8s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ── SUGGESTIONS ─── */
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.6rem;
}
.chat-suggestions button {
  font-size: 0.8rem;
  padding: 0.35rem 0.8rem;
  border-radius: 20px;
  border: 1px solid var(--brand-gold);
  color: var(--brand-gold);
  background: white;
  transition: all 0.2s;
}
.chat-suggestions button:hover {
  background: var(--brand-gold);
  color: white;
}

/* ── PRODUCT CARD IN CHAT ─── */
.chat-product-card {
  background: white;
  border: 1px solid rgba(15,47,38,0.1);
  border-radius: 10px;
  overflow: hidden;
  margin-top: 0.5rem;
  max-width: 240px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.chat-product-card img { width: 100%; height: 120px; object-fit: cover; }
.chat-product-card-body { padding: 0.6rem 0.75rem; }
.chat-product-card-name { font-weight: 600; font-size: 0.85rem; color: var(--brand-green); margin-bottom: 0.3rem; }
.chat-product-card-price { color: var(--brand-gold); font-weight: 700; font-size: 0.9rem; }
.chat-product-card-btn {
  display: block;
  width: 100%;
  padding: 0.5rem;
  background: var(--brand-green);
  color: white;
  text-align: center;
  font-size: 0.8rem;
  transition: background 0.2s;
}
.chat-product-card-btn:hover { background: var(--brand-gold); }

/* ── INPUT AREA ─── */
.chat-input-area {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid rgba(15,47,38,0.08);
  background: white;
}
.chat-input-area input {
  flex: 1;
  padding: 0.65rem 1rem;
  border: 2px solid rgba(15,47,38,0.12);
  border-radius: 25px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
  background: var(--brand-cream);
}
.chat-input-area input:focus {
  border-color: var(--brand-gold);
  background: white;
}
.chat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--brand-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.1s;
  flex-shrink: 0;
}
.chat-send:hover { background: #B89960; transform: scale(1.05); }

/* ── VOICE BUTTON ─── */
.chat-voice-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand-cream);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
  color: var(--brand-green);
  font-size: 1rem;
}
.chat-voice-btn:hover { background: var(--brand-green); color: white; }
.chat-voice-btn.recording {
  background: #e53e3e;
  color: white;
  animation: pulse 1s ease infinite;
}
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(229,62,62,0.4); }
  50%      { box-shadow: 0 0 0 10px rgba(229,62,62,0); }
}

/* ── WHATSAPP FLOATING BUTTON ─── */
#whatsapp-float {
  position: fixed;
  bottom: 7rem;
  right: 1.5rem;
  z-index: 9999;
  width: 52px;
  height: 52px;
  background: #25D366;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(37,211,102,0.4);
  transition: all 0.25s;
  text-decoration: none;
}
#whatsapp-float:hover { background: #20bd5c; transform: scale(1.1); }
#whatsapp-float svg { width: 28px; height: 28px; fill: white; }
