/* ══════════════════════════════════════════════════════════
   EVBot Chat Widget
   ══════════════════════════════════════════════════════════ */

#chat-widget {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9998;
  font-family: var(--font-body, 'Outfit', sans-serif);
}

/* ── Toggle Button ─────────────────────────────────────── */
.chat-toggle-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--color-dark, #1A1A1A);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 1.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(26,26,26,0.28);
  transition: transform 0.2s, background 0.2s;
  position: relative;
  flex-shrink: 0;
}
.chat-toggle-btn:hover {
  background: var(--color-accent, #D19B9C);
  transform: scale(1.08);
}
.chat-toggle-btn:active { transform: scale(0.96); }

.chat-notif-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #EF4444;
  color: #fff;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 0.62rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
}

/* ── Chat Panel ────────────────────────────────────────── */
.chat-panel {
  position: absolute;
  bottom: 68px;
  right: 0;
  width: 360px;
  height: 530px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transform: scale(0.85) translateY(16px);
  opacity: 0;
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), opacity 0.2s ease;
}
.chat-panel-visible {
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* ── Header ────────────────────────────────────────────── */
.chat-header {
  background: var(--color-dark, #1A1A1A);
  color: #fff;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  border-radius: 18px 18px 0 0;
}
.chat-header-info {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.chat-avatar {
  width: 38px;
  height: 38px;
  background: var(--color-accent, #D19B9C);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.chat-header-name {
  font-family: var(--font-display, 'Space Grotesk', sans-serif);
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}
.chat-header-status {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.55);
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 1px;
}
.chat-status-dot {
  width: 6px;
  height: 6px;
  background: #22C55E;
  border-radius: 50%;
  display: inline-block;
  animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.4; }
}
.chat-ctrl-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.55);
  cursor: pointer;
  font-size: 0.82rem;
  padding: 0.3rem 0.35rem;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  line-height: 1;
}
.chat-ctrl-btn:hover { color: #fff; background: rgba(255,255,255,0.1); }

/* ── Messages ──────────────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  background: #F8F9FA;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 2px; }

/* Message rows */
.chat-msg-row       { display: flex; }
.chat-msg-row-user  { justify-content: flex-end; }
.chat-msg-row-bot   { justify-content: flex-start; flex-direction: column; gap: 0.45rem; }

/* Bubbles */
.chat-bubble {
  padding: 0.55rem 0.85rem;
  border-radius: 14px;
  font-size: 0.862rem;
  line-height: 1.55;
  max-width: 85%;
  word-break: break-word;
}
.chat-bubble-user {
  background: var(--color-dark, #1A1A1A);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-bubble-bot {
  background: #fff;
  color: #1A1A1A;
  border: 1px solid #E8E8E8;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

/* Typing animation */
.chat-typing-row .chat-bubble {
  padding: 0.65rem 1rem;
}
.chat-typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
}
.chat-typing-dots span {
  width: 7px;
  height: 7px;
  background: #CBD5E1;
  border-radius: 50%;
  animation: typing-bounce 1.3s infinite ease-in-out;
}
.chat-typing-dots span:nth-child(2) { animation-delay: 0.18s; }
.chat-typing-dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes typing-bounce {
  0%,60%,100% { transform: translateY(0);   opacity: 0.4; }
  30%          { transform: translateY(-5px); opacity: 1;   }
}

/* ── Product Cards Grid ────────────────────────────────── */
.chat-products-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.45rem;
  max-width: 310px;
}
.chat-product-card {
  background: #fff;
  border: 1px solid #E8E8E8;
  border-radius: 10px;
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.2s;
}
.chat-product-card:hover {
  box-shadow: 0 3px 14px rgba(0,0,0,0.1);
  transform: translateY(-1px);
}
.chat-product-img-link {
  display: block;
  height: 86px;
  overflow: hidden;
  background: #F3F4F6;
}
.chat-product-img-link img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.25s;
}
.chat-product-card:hover .chat-product-img-link img { transform: scale(1.06); }
.chat-product-body { padding: 0.45rem 0.5rem 0.5rem; }
.chat-product-name {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: #1A1A1A;
  text-decoration: none;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 0.2rem;
}
.chat-product-name:hover { color: var(--color-accent, #D19B9C); }
.chat-product-price {
  font-size: 0.78rem;
  font-weight: 700;
  color: #1A1A1A;
  line-height: 1;
}
.chat-product-old-price {
  font-size: 0.65rem;
  color: #9CA3AF;
  text-decoration: line-through;
  margin-left: 2px;
}
.chat-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  width: 100%;
  margin-top: 0.38rem;
  padding: 0.28rem 0;
  background: var(--color-dark, #1A1A1A);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.18s;
  letter-spacing: 0.02em;
}
.chat-add-btn:hover   { background: var(--color-accent, #D19B9C); }
.chat-add-btn.added   { background: #22C55E; }
.chat-add-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── Order Tracking Card ───────────────────────────────── */
.chat-order-card {
  background: #fff;
  border: 1px solid #E8E8E8;
  border-radius: 10px;
  padding: 0.8rem 0.85rem;
  max-width: 300px;
  font-size: 0.82rem;
}
.chat-order-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.3rem;
}
.chat-order-num  { font-weight: 800; font-size: 0.88rem; color: #1A1A1A; }
.chat-order-badge {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.18rem 0.55rem;
  border-radius: 50px;
}
.chat-order-meta { color: #6B7280; font-size: 0.75rem; margin-bottom: 0.6rem; }

.chat-timeline {
  border-left: 2px solid #E5E7EB;
  padding-left: 0.8rem;
  margin: 0.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.chat-tl-step { position: relative; }
.chat-tl-dot {
  position: absolute;
  left: -1.03rem;
  top: 4px;
  width: 8px;
  height: 8px;
  background: var(--color-accent, #D19B9C);
  border-radius: 50%;
  border: 2px solid #fff;
}
.chat-tl-status  { font-weight: 700; font-size: 0.75rem; text-transform: capitalize; color: #374151; }
.chat-tl-msg     { font-size: 0.7rem; color: #6B7280; line-height: 1.35; }
.chat-tl-time    { font-size: 0.65rem; color: #9CA3AF; }
.chat-order-link {
  display: block;
  text-align: right;
  font-size: 0.73rem;
  font-weight: 700;
  color: var(--color-accent, #D19B9C);
  text-decoration: none;
  margin-top: 0.5rem;
}
.chat-order-link:hover { color: var(--color-dark, #1A1A1A); }

/* ── Cart Summary Card ─────────────────────────────────── */
.chat-cart-card {
  background: #fff;
  border: 1px solid #E8E8E8;
  border-radius: 10px;
  padding: 0.8rem 0.85rem;
  max-width: 300px;
}
.chat-cart-title {
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 0.55rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: #1A1A1A;
}
.chat-cart-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.4rem;
  align-items: center;
  padding: 0.3rem 0;
  border-bottom: 1px solid #F3F4F6;
  font-size: 0.76rem;
}
.chat-cart-item:last-of-type { border-bottom: none; }
.chat-cart-iname { color: #374151; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-cart-iqty  { color: #9CA3AF; font-size: 0.7rem; }
.chat-cart-iprice { font-weight: 700; font-size: 0.76rem; }
.chat-cart-more  { font-size: 0.7rem; color: #9CA3AF; padding: 0.2rem 0; text-align: center; }
.chat-cart-total {
  font-weight: 800;
  font-size: 0.88rem;
  text-align: right;
  margin-top: 0.5rem;
  color: #1A1A1A;
}
.chat-checkout-link {
  display: block;
  text-align: center;
  margin-top: 0.55rem;
  padding: 0.45rem;
  background: var(--color-dark, #1A1A1A);
  color: #fff;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 700;
  transition: background 0.18s;
}
.chat-checkout-link:hover { background: var(--color-accent, #D19B9C); color: #fff; }

/* ── FAQ Card ──────────────────────────────────────────── */
.chat-faq-card {
  background: #fff;
  border: 1px solid #E8E8E8;
  border-left: 3px solid var(--color-accent, #D19B9C);
  border-radius: 10px;
  padding: 0.8rem 0.85rem;
  max-width: 300px;
}
.chat-faq-title {
  font-weight: 800;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
  color: #1A1A1A;
}
.chat-faq-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.chat-faq-list li {
  font-size: 0.76rem;
  color: #374151;
  padding: 0.25rem 0;
  border-bottom: 1px solid #F3F4F6;
  line-height: 1.45;
}
.chat-faq-list li:last-child { border-bottom: none; }

/* ── Suggestions ───────────────────────────────────────── */
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.38rem;
  padding: 0.55rem 0.9rem;
  background: #F8F9FA;
  border-top: 1px solid #F0F0F0;
  flex-shrink: 0;
}
.chat-chip {
  padding: 0.28rem 0.7rem;
  background: #fff;
  border: 1px solid #E0E0E0;
  border-radius: 50px;
  font-size: 0.73rem;
  font-weight: 500;
  cursor: pointer;
  color: #374151;
  transition: all 0.15s;
  white-space: nowrap;
  font-family: inherit;
}
.chat-chip:hover {
  background: var(--color-dark, #1A1A1A);
  color: #fff;
  border-color: var(--color-dark, #1A1A1A);
}

/* ── Input Row ─────────────────────────────────────────── */
.chat-input-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.65rem 0.8rem;
  background: #fff;
  border-top: 1px solid #E8E8E8;
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  border: 1px solid #E0E0E0;
  border-radius: 50px;
  padding: 0.48rem 0.95rem;
  font-size: 0.862rem;
  font-family: inherit;
  color: #1A1A1A;
  background: #F8F9FA;
  outline: none;
  transition: border-color 0.18s, background 0.18s;
}
.chat-input:focus {
  border-color: var(--color-accent, #D19B9C);
  background: #fff;
}
.chat-input::placeholder { color: #A0A0A0; }
.chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-dark, #1A1A1A);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
  transition: background 0.18s, transform 0.15s;
}
.chat-send-btn:hover     { background: var(--color-accent, #D19B9C); }
.chat-send-btn:active    { transform: scale(0.9); }
.chat-send-btn:disabled  { opacity: 0.45; cursor: not-allowed; }

/* ── Empty State ───────────────────────────────────────── */
.chat-empty-box {
  text-align: center;
  padding: 1rem 0.5rem;
  font-size: 0.8rem;
  color: #9CA3AF;
}
.chat-empty-box .chat-empty-icon { font-size: 2rem; margin-bottom: 0.4rem; }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 480px) {
  .chat-panel {
    width: calc(100vw - 1.5rem);
    right: -0.25rem;
    height: 88vh;
    max-height: 520px;
    bottom: 66px;
  }
  .chat-products-grid { grid-template-columns: repeat(2, 1fr); }
}
