/* ============================================
   MAISON NOIR — Chatbot Widget
   ============================================ */

/* TOGGLE BUTTON */
.cb-toggle {
  position: fixed;
  bottom: 1.75rem;
  right: 1.75rem;
  z-index: 9000;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: #0d0d0d;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3), 0 0 0 0 rgba(201,169,110,0.4);
  transition: transform 0.3s cubic-bezier(0.22,1,0.36,1), box-shadow 0.3s;
  animation: cb-pulse 3s ease-in-out infinite;
}

@keyframes cb-pulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(0,0,0,0.3), 0 0 0 0 rgba(201,169,110,0.4); }
  50% { box-shadow: 0 4px 20px rgba(0,0,0,0.3), 0 0 0 10px rgba(201,169,110,0); }
}

.cb-toggle:hover {
  transform: scale(1.08);
  animation: none;
  box-shadow: 0 6px 28px rgba(0,0,0,0.4);
}

.cb-toggle-icon,
.cb-close-icon {
  position: absolute;
  transition: opacity 0.25s, transform 0.25s;
}

.cb-toggle-icon { opacity: 1; transform: scale(1) rotate(0deg); }
.cb-close-icon  { opacity: 0; transform: scale(0.5) rotate(-90deg); }
.cb-toggle-icon svg { width: 24px; height: 24px; fill: none; stroke: #c9a96e; stroke-width: 1.8; }
.cb-close-icon svg  { width: 22px; height: 22px; fill: none; stroke: #f8f6f2; stroke-width: 2; }

.cb-toggle.open .cb-toggle-icon { opacity: 0; transform: scale(0.5) rotate(90deg); }
.cb-toggle.open .cb-close-icon  { opacity: 1; transform: scale(1) rotate(0deg); }

.cb-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #c9a96e;
  color: #0d0d0d;
  font-size: 0.6rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #f8f6f2;
  transition: opacity 0.2s, transform 0.2s;
}

.cb-badge.hidden { opacity: 0; transform: scale(0); pointer-events: none; }

/* PANEL */
.cb-panel {
  position: fixed;
  bottom: calc(1.75rem + 68px);
  right: 1.75rem;
  z-index: 9000;
  width: 360px;
  max-height: 580px;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 16px 64px rgba(0,0,0,0.18), 0 4px 16px rgba(0,0,0,0.08);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 0.3s cubic-bezier(0.22,1,0.36,1),
              transform 0.3s cubic-bezier(0.22,1,0.36,1);
}

.cb-panel.open {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0) scale(1);
}

/* HEADER */
.cb-header {
  background: #0d0d0d;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.875rem;
  flex-shrink: 0;
}

.cb-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #c9a96e, #a07840);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Cormorant Garamond', serif;
  font-size: 1rem;
  font-weight: 600;
  color: #0d0d0d;
  flex-shrink: 0;
  position: relative;
}

.cb-avatar::after {
  content: '';
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #27ae60;
  border: 2px solid #0d0d0d;
}

.cb-header-info { flex: 1; min-width: 0; }

.cb-header-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.95rem;
  font-weight: 500;
  color: #f8f6f2;
  letter-spacing: 0.06em;
  display: block;
  line-height: 1.2;
}

.cb-header-status {
  font-size: 0.68rem;
  color: rgba(248,246,242,0.5);
  letter-spacing: 0.04em;
}

.cb-header-actions { display: flex; gap: 0.4rem; }

.cb-hbtn {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}

.cb-hbtn:hover { background: rgba(255,255,255,0.12); }
.cb-hbtn svg { width: 14px; height: 14px; fill: none; stroke: rgba(248,246,242,0.7); stroke-width: 1.8; }

/* MESSAGES AREA */
.cb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  scroll-behavior: smooth;
  background: #f9f8f6;
}

.cb-messages::-webkit-scrollbar { width: 4px; }
.cb-messages::-webkit-scrollbar-track { background: transparent; }
.cb-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }

/* MESSAGE ROWS */
.cb-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  animation: cb-msg-in 0.3s cubic-bezier(0.22,1,0.36,1);
}

@keyframes cb-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.cb-row.user { flex-direction: row-reverse; }

.cb-row-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #c9a96e, #a07840);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.6rem; font-weight: 700; color: #0d0d0d;
  flex-shrink: 0;
}

.cb-bubble {
  max-width: 78%;
  padding: 0.7rem 0.95rem;
  border-radius: 16px;
  font-size: 0.82rem;
  line-height: 1.55;
  position: relative;
}

/* Bot bubble */
.cb-row.bot .cb-bubble {
  background: #ffffff;
  color: #1a1a1a;
  border: 1px solid #eaeae7;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

/* User bubble */
.cb-row.user .cb-bubble {
  background: #0d0d0d;
  color: #f8f6f2;
  border-bottom-right-radius: 4px;
}

.cb-time {
  font-size: 0.62rem;
  color: #b0b0b0;
  margin-top: 0.3rem;
  display: block;
  text-align: right;
}

.cb-row.bot .cb-time { text-align: left; margin-left: 0.5rem; }

/* TYPING INDICATOR */
.cb-typing {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  animation: cb-msg-in 0.3s ease;
}

.cb-typing-bubble {
  background: #ffffff;
  border: 1px solid #eaeae7;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  padding: 0.75rem 1rem;
  display: flex;
  gap: 4px;
  align-items: center;
}

.cb-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #c9a96e;
  animation: cb-bounce 1.2s ease-in-out infinite;
}

.cb-dot:nth-child(2) { animation-delay: 0.2s; }
.cb-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes cb-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* QUICK REPLIES */
.cb-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0 1rem 0.75rem;
  background: #f9f8f6;
}

.cb-chip {
  background: #ffffff;
  border: 1px solid #c9a96e;
  color: #0d0d0d;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.4rem 0.85rem;
  border-radius: 100px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.15s;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.cb-chip:hover {
  background: #0d0d0d;
  color: #c9a96e;
  border-color: #0d0d0d;
  transform: translateY(-1px);
}

/* DIVIDER */
.cb-date-divider {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.65rem;
  color: #b0b0b0;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0.25rem 0;
}

.cb-date-divider::before,
.cb-date-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #eaeae7;
}

/* INPUT AREA */
.cb-input-area {
  padding: 0.875rem 1rem;
  background: #ffffff;
  border-top: 1px solid #eaeae7;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-shrink: 0;
}

.cb-input {
  flex: 1;
  border: 1px solid #eaeae7;
  border-radius: 100px;
  padding: 0.6rem 1rem;
  font-size: 0.82rem;
  font-family: 'Inter', sans-serif;
  color: #1a1a1a;
  background: #f9f8f6;
  outline: none;
  transition: border-color 0.2s;
  resize: none;
}

.cb-input:focus { border-color: #c9a96e; }
.cb-input::placeholder { color: #b0b0b0; }

.cb-send {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: #0d0d0d;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}

.cb-send:hover { background: #c9a96e; transform: scale(1.05); }
.cb-send:active { transform: scale(0.95); }
.cb-send svg { width: 16px; height: 16px; fill: none; stroke: #f8f6f2; stroke-width: 2; }
.cb-send:hover svg { stroke: #0d0d0d; }

/* POWERED BY */
.cb-footer {
  padding: 0.45rem 1rem;
  text-align: center;
  font-size: 0.6rem;
  color: #c0c0c0;
  background: #ffffff;
  letter-spacing: 0.04em;
}

.cb-footer a { color: #c9a96e; text-decoration: none; }
.cb-footer a:hover { text-decoration: underline; }

/* PRODUCT CARD in chat */
.cb-product-card {
  background: #f9f8f6;
  border: 1px solid #eaeae7;
  border-radius: 10px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.cb-product-img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
  background: #eaeae7;
}

.cb-product-body { padding: 0.625rem 0.75rem; }
.cb-product-body strong { font-size: 0.8rem; display: block; margin-bottom: 0.15rem; color: #1a1a1a; }
.cb-product-body span { font-size: 0.72rem; color: #6b6b6b; }
.cb-product-price { font-weight: 700; color: #c9a96e; font-size: 0.85rem; }

/* RESPONSIVE */
@media (max-width: 480px) {
  .cb-panel {
    width: calc(100vw - 2rem);
    right: 1rem;
    bottom: calc(1rem + 68px);
    max-height: calc(100vh - 120px);
  }

  .cb-toggle {
    bottom: 1rem;
    right: 1rem;
  }
}
