/* ===== CHATBOT WIDGET ===== */

/* Floating Toggle Button */
.chatbot-toggle {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 9000;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1.6rem;
  background: var(--earth-dark);
  color: var(--cream-100);
  border-radius: 9999px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  box-shadow: 0 8px 32px rgba(28, 18, 8, 0.35), 0 0 0 0 rgba(196, 112, 75, 0);
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  animation: chatbot-pulse 3s ease-in-out infinite;
}

.chatbot-toggle:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 12px 40px rgba(28, 18, 8, 0.45);
  background: var(--earth-brown);
}

.chatbot-toggle.hidden {
  transform: translateY(20px) scale(0.8);
  opacity: 0;
  pointer-events: none;
}

.chatbot-toggle__icon {
  width: 2.2rem;
  height: 2.2rem;
  background: var(--accent-terracotta);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: white;
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.chatbot-toggle:hover .chatbot-toggle__icon {
  transform: rotate(-10deg) scale(1.1);
}

.chatbot-toggle__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 14px;
  height: 14px;
  background: #e74c3c;
  border-radius: 50%;
  border: 2px solid var(--earth-dark);
  animation: chatbot-badge-pulse 2s ease-in-out infinite;
}

@keyframes chatbot-pulse {
  0%, 100% { box-shadow: 0 8px 32px rgba(28, 18, 8, 0.35), 0 0 0 0 rgba(196, 112, 75, 0.4); }
  50% { box-shadow: 0 8px 32px rgba(28, 18, 8, 0.35), 0 0 0 12px rgba(196, 112, 75, 0); }
}

@keyframes chatbot-badge-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); }
}

/* ===== Chat Window ===== */
.chatbot-window {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 9001;
  width: 420px;
  max-height: 680px;
  height: calc(100vh - 6rem);
  background: var(--cream-50);
  border-radius: 28px;
  box-shadow: 0 25px 80px rgba(28, 18, 8, 0.25), 0 0 0 1px rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(30px) scale(0.92);
  transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.chatbot-window.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* ===== Chat Header ===== */
.chatbot-header {
  background: var(--earth-dark);
  color: var(--cream-100);
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.chatbot-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(196, 112, 75, 0.15) 0%, transparent 60%);
  pointer-events: none;
}

.chatbot-header__avatar {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-terracotta), var(--accent-sage));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
  position: relative;
}

.chatbot-header__avatar::after {
  content: '';
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  background: #4ade80;
  border-radius: 50%;
  border: 2px solid var(--earth-dark);
}

.chatbot-header__info {
  flex: 1;
  position: relative;
}

.chatbot-header__name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--cream-100);
}

.chatbot-header__status {
  font-size: 0.72rem;
  color: var(--cream-300);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.15rem;
}

.chatbot-header__status-dot {
  width: 6px;
  height: 6px;
  background: #4ade80;
  border-radius: 50%;
  animation: chatbot-status-glow 2s ease-in-out infinite;
}

@keyframes chatbot-status-glow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.chatbot-header__close {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cream-300);
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  border: none;
  position: relative;
}

.chatbot-header__close:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  transform: rotate(90deg);
}

/* ===== Chat Messages Area ===== */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  scroll-behavior: smooth;
  background: linear-gradient(180deg, var(--cream-100) 0%, var(--cream-50) 30%);
}

.chatbot-messages::-webkit-scrollbar { width: 4px; }
.chatbot-messages::-webkit-scrollbar-track { background: transparent; }
.chatbot-messages::-webkit-scrollbar-thumb { background: var(--cream-300); border-radius: 10px; }

/* Message Bubbles */
.chat-msg {
  display: flex;
  gap: 0.6rem;
  max-width: 92%;
  animation: chatMsg-in 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes chatMsg-in {
  from { opacity: 0; transform: translateY(12px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.chat-msg--bot { align-self: flex-start; }
.chat-msg--user { align-self: flex-end; flex-direction: row-reverse; }

.chat-msg__avatar {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  flex-shrink: 0;
  margin-top: 0.15rem;
}

.chat-msg--bot .chat-msg__avatar {
  background: linear-gradient(135deg, var(--accent-sage), var(--accent-moss));
  color: white;
}

.chat-msg--user .chat-msg__avatar {
  background: var(--accent-terracotta);
  color: white;
}

.chat-msg__bubble {
  padding: 0.85rem 1.1rem;
  border-radius: 18px;
  font-size: 0.85rem;
  line-height: 1.55;
  font-family: 'Outfit', sans-serif;
  position: relative;
}

.chat-msg--bot .chat-msg__bubble {
  background: white;
  color: var(--earth-brown);
  border-bottom-left-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  border: 1px solid var(--cream-200);
}

.chat-msg--user .chat-msg__bubble {
  background: var(--earth-dark);
  color: var(--cream-100);
  border-bottom-right-radius: 6px;
}

.chat-msg__bubble strong {
  color: var(--accent-terracotta);
  font-weight: 600;
}

.chat-msg__bubble em {
  color: var(--accent-sage);
  font-style: normal;
  font-weight: 500;
}

/* Typing Indicator */
.chat-typing {
  display: flex;
  gap: 0.6rem;
  align-self: flex-start;
  max-width: 92%;
  animation: chatMsg-in 0.3s ease;
}

.chat-typing__avatar {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-sage), var(--accent-moss));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: white;
  flex-shrink: 0;
  margin-top: 0.15rem;
}

.chat-typing__bubble {
  background: white;
  border: 1px solid var(--cream-200);
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  padding: 0.85rem 1.2rem;
  display: flex;
  gap: 0.3rem;
  align-items: center;
}

.chat-typing__dot {
  width: 6px;
  height: 6px;
  background: var(--earth-sand);
  border-radius: 50%;
  animation: typingBounce 1.4s ease-in-out infinite;
}

.chat-typing__dot:nth-child(2) { animation-delay: 0.15s; }
.chat-typing__dot:nth-child(3) { animation-delay: 0.3s; }

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

/* ===== Quick Reply Chips ===== */
.chat-quickreplies {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.25rem 0 0.5rem;
  animation: chatMsg-in 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both;
}

.chat-quickreply {
  padding: 0.5rem 0.9rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-family: 'Outfit', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 1px solid var(--cream-300);
  background: white;
  color: var(--earth-brown);
  white-space: nowrap;
}

.chat-quickreply:hover {
  background: var(--earth-dark);
  color: white;
  border-color: var(--earth-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(28, 18, 8, 0.15);
}

.chat-quickreply i {
  margin-right: 0.3rem;
  font-size: 0.7rem;
}

/* ===== Product Cards in Chat ===== */
.chat-products {
  display: flex;
  gap: 0.65rem;
  overflow-x: auto;
  overscroll-behavior: contain;
  padding: 0.5rem 0;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  animation: chatMsg-in 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-products::-webkit-scrollbar { height: 3px; }
.chat-products::-webkit-scrollbar-thumb { background: var(--cream-300); border-radius: 10px; }

.chat-product-card {
  min-width: 180px;
  max-width: 180px;
  background: white;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--cream-200);
  cursor: pointer;
  transition: all 0.3s ease;
  scroll-snap-align: start;
  flex-shrink: 0;
  text-decoration: none;
  color: inherit;
  display: block;
}

.chat-product-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 28px rgba(0,0,0,0.08);
  border-color: var(--accent-terracotta);
}

.chat-product-card__img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--cream-100);
}

.chat-product-card__body {
  padding: 0.7rem 0.75rem;
}

.chat-product-card__name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--earth-brown);
  line-height: 1.2;
  margin-bottom: 0.2rem;
}

.chat-product-card__cat {
  font-size: 0.65rem;
  color: var(--earth-tan);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
}

.chat-product-card__badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 99px;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.chat-product-card__badge--best {
  background: var(--earth-dark);
  color: white;
}

.chat-product-card__badge--new {
  background: var(--accent-sage);
  color: white;
}

.chat-product-card__btn {
  display: block;
  width: 100%;
  padding: 0.45rem;
  margin-top: 0.45rem;
  border-radius: 8px;
  font-size: 0.7rem;
  font-weight: 600;
  text-align: center;
  background: var(--cream-100);
  color: var(--earth-brown);
  border: none;
  font-family: 'Outfit', sans-serif;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chat-product-card:hover .chat-product-card__btn {
  background: var(--earth-dark);
  color: white;
}

/* ===== Chat Input Area ===== */
.chatbot-input {
  padding: 0.75rem 1rem;
  background: white;
  border-top: 1px solid var(--cream-200);
  display: flex;
  gap: 0.6rem;
  align-items: flex-end;
  flex-shrink: 0;
}

.chatbot-input__field {
  flex: 1;
  padding: 0.7rem 1rem;
  border-radius: 14px;
  border: 1px solid var(--cream-300);
  background: var(--cream-50);
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  color: var(--earth-brown);
  outline: none;
  resize: none;
  min-height: 40px;
  max-height: 100px;
  line-height: 1.4;
  transition: border-color 0.3s ease;
}

.chatbot-input__field::placeholder {
  color: var(--earth-sand);
}

.chatbot-input__field:focus {
  border-color: var(--accent-terracotta);
  box-shadow: 0 0 0 3px rgba(196, 112, 75, 0.1);
}

.chatbot-input__send {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--earth-dark);
  color: var(--cream-100);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  cursor: pointer;
  border: none;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.chatbot-input__send:hover {
  background: var(--accent-terracotta);
  transform: scale(1.05);
}

.chatbot-input__send:active {
  transform: scale(0.95);
}

/* ===== Powered By Footer ===== */
.chatbot-footer {
  padding: 0.4rem;
  text-align: center;
  font-size: 0.6rem;
  color: var(--earth-sand);
  background: white;
  border-top: 1px solid var(--cream-100);
  flex-shrink: 0;
}

.chatbot-footer span {
  color: var(--accent-sage);
  font-weight: 600;
}

/* ===== Welcome State ===== */
.chat-welcome {
  text-align: center;
  padding: 1rem 0.5rem;
  animation: chatMsg-in 0.5s ease;
}

.chat-welcome__emoji {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  display: block;
}

.chat-welcome__title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--earth-brown);
  margin-bottom: 0.4rem;
}

.chat-welcome__desc {
  font-size: 0.8rem;
  color: var(--earth-tan);
  line-height: 1.5;
  max-width: 280px;
  margin: 0 auto 1rem;
}

/* ===== Category Section in Chat ===== */
.chat-section-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--earth-sand);
  font-weight: 600;
  padding: 0.5rem 0 0.25rem;
  margin-top: 0.25rem;
}

/* ===== Mobile Responsive ===== */
@media (max-width: 480px) {
  .chatbot-window {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
  }

  .chatbot-window.active {
    border-radius: 0;
  }

  .chatbot-toggle {
    bottom: 1.25rem;
    right: 1.25rem;
    padding: 0.75rem 1.2rem;
    font-size: 0.82rem;
  }

  .chat-product-card {
    min-width: 160px;
    max-width: 160px;
  }
}

@media (max-width: 768px) {
  .chatbot-window {
    width: 100%;
    max-width: 100%;
    bottom: 0;
    right: 0;
    border-radius: 24px 24px 0 0;
    max-height: 85vh;
    height: 85vh;
  }

  .chatbot-toggle__text {
    display: none;
  }

  .chatbot-toggle {
    padding: 0.8rem;
  }
}
