/* ============================================================
   Pinnacles Farm — Chatbot Styles
   ============================================================ */

/* ── Launcher Button ─────────────────────────────────────────── */
#chat-launcher {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #2d6a4f, #52b788);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 24px rgba(45,106,79,.55);
  z-index: 2000;
  transition: transform .25s cubic-bezier(.34,1.56,.64,1), box-shadow .25s;
}
#chat-launcher:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 32px rgba(45,106,79,.7);
}
#chat-launcher svg { transition: transform .3s; }
#chat-launcher.open svg { transform: rotate(90deg); }

/* Pulse ring */
#chat-launcher::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(82,183,136,.5);
  animation: chatPulse 2.4s ease-out infinite;
}
@keyframes chatPulse {
  0%   { opacity: .9; transform: scale(1); }
  70%  { opacity: 0;  transform: scale(1.5); }
  100% { opacity: 0;  transform: scale(1.5); }
}

/* Unread badge */
#chat-unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #e76f51;
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  opacity: 0;
  transform: scale(0);
  transition: opacity .2s, transform .2s;
}
#chat-unread-badge.show {
  opacity: 1;
  transform: scale(1);
}

/* ── Chat Window ─────────────────────────────────────────────── */
#chat-window {
  position: fixed;
  bottom: 166px;
  right: 24px;
  width: 370px;
  max-height: 580px;
  background: #0d1f14;
  border: 1px solid rgba(82,183,136,.2);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.6), 0 0 0 1px rgba(82,183,136,.08);
  z-index: 1999;
  overflow: hidden;
  transform: translateY(20px) scale(.95);
  opacity: 0;
  pointer-events: none;
  transition: transform .3s cubic-bezier(.34,1.2,.64,1), opacity .25s;
}
#chat-window.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

/* ── Header ──────────────────────────────────────────────────── */
#chat-header {
  background: linear-gradient(135deg, #1b4332 0%, #2d6a4f 100%);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(82,183,136,.15);
}
.chat-avatar {
  width: 42px;
  height: 42px;
  background: rgba(82,183,136,.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  border: 2px solid rgba(82,183,136,.4);
  flex-shrink: 0;
}
.chat-header-info { flex: 1; }
.chat-header-name {
  font-weight: 700;
  font-size: .95rem;
  color: #fff;
  display: block;
}
.chat-header-status {
  font-size: .75rem;
  color: rgba(255,255,255,.65);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}
.chat-header-status::before {
  content: '';
  width: 7px;
  height: 7px;
  background: #52b788;
  border-radius: 50%;
  box-shadow: 0 0 6px #52b788;
  animation: blink 2s infinite;
}
@keyframes blink { 0%,100% { opacity:1 } 50% { opacity:.4 } }

#chat-close-btn {
  background: rgba(255,255,255,.1);
  border: none;
  color: rgba(255,255,255,.7);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s, color .2s;
}
#chat-close-btn:hover { background: rgba(255,255,255,.2); color: #fff; }

/* ── Messages Area ───────────────────────────────────────────── */
#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
#chat-messages::-webkit-scrollbar { width: 4px; }
#chat-messages::-webkit-scrollbar-track { background: transparent; }
#chat-messages::-webkit-scrollbar-thumb { background: rgba(82,183,136,.3); border-radius: 4px; }

/* Bubbles */
.chat-bubble {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: .875rem;
  line-height: 1.55;
  word-break: break-word;
  animation: bubbleIn .2s ease;
}
@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-bubble.bot {
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(82,183,136,.15);
  color: #d8f3e8;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}
.chat-bubble.user {
  background: linear-gradient(135deg, #2d6a4f, #52b788);
  color: #fff;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}

/* Typing indicator */
.chat-typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(82,183,136,.15);
  padding: 10px 14px;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}
.chat-typing span {
  width: 7px;
  height: 7px;
  background: #52b788;
  border-radius: 50%;
  animation: typingDot .9s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: .15s; }
.chat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes typingDot {
  0%,60%,100% { transform: translateY(0); opacity: .6; }
  30%          { transform: translateY(-6px); opacity: 1; }
}

/* Quick reply chips */
.chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
  align-self: flex-start;
  max-width: 100%;
}
.chip {
  background: rgba(82,183,136,.12);
  border: 1px solid rgba(82,183,136,.35);
  color: #52b788;
  padding: 6px 12px;
  border-radius: 50px;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .15s;
  white-space: nowrap;
  font-family: 'Outfit', sans-serif;
}
.chip:hover {
  background: rgba(82,183,136,.25);
  transform: translateY(-1px);
}

/* Product cards in chat */
.chat-product-card {
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(82,183,136,.2);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: background .2s, transform .15s;
  max-width: 100%;
  align-self: flex-start;
  width: 280px;
}
.chat-product-card:hover { background: rgba(82,183,136,.1); transform: translateY(-1px); }
.chat-product-thumb {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: rgba(82,183,136,.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
}
.chat-product-thumb img {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  object-fit: cover;
}
.chat-product-info { flex: 1; min-width: 0; }
.chat-product-name {
  font-weight: 600;
  font-size: .83rem;
  color: #d8f3e8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-product-price { font-size: .78rem; color: #52b788; font-weight: 700; margin-top: 2px; }
.chat-add-btn {
  background: linear-gradient(135deg, #2d6a4f, #52b788);
  border: none;
  color: #fff;
  padding: 5px 11px;
  border-radius: 50px;
  font-size: .75rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  font-family: 'Outfit', sans-serif;
  transition: opacity .2s;
}
.chat-add-btn:hover { opacity: .85; }

/* ── Input Bar ───────────────────────────────────────────────── */
#chat-input-bar {
  padding: 12px 14px;
  border-top: 1px solid rgba(82,183,136,.12);
  display: flex;
  gap: 8px;
  align-items: center;
  background: rgba(0,0,0,.25);
}
#chat-input {
  flex: 1;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(82,183,136,.2);
  border-radius: 50px;
  padding: 9px 16px;
  color: #fff;
  font-size: .88rem;
  font-family: 'Outfit', sans-serif;
  outline: none;
  transition: border-color .2s;
}
#chat-input::placeholder { color: rgba(255,255,255,.35); }
#chat-input:focus { border-color: rgba(82,183,136,.5); }
#chat-send-btn {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #2d6a4f, #52b788);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity .2s, transform .15s;
}
#chat-send-btn:hover { opacity: .85; transform: scale(1.05); }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 440px) {
  #chat-window {
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 100dvh;
    border-radius: 20px 20px 0 0;
  }
  #chat-launcher { right: 16px; bottom: 80px; }
}
