/* ==========================================================================
   KAVYA FASHION HOUSE - CHATBOT WIDGET STYLING
   ========================================================================== */

:root {
  --chat-primary: var(--crimson, #8B1A2F);
  --chat-primary-dark: var(--crimson-dk, #5C0E1E);
  --chat-accent: var(--gold, #C9954A);
  --chat-accent-light: var(--gold-light, #E8C07A);
  --chat-accent-pale: var(--gold-pale, #F5E6C8);
  --chat-bg-light: var(--ivory, #FAF6EF);
  --chat-bg-dark: var(--charcoal, #1C1009);
  --chat-text-dark: var(--charcoal, #1C1009);
  --chat-text-light: #FFFFFF;
  --chat-text-muted: var(--warm-gray, #7A6A58);
  
  --chat-window-width: 380px;
  --chat-window-height: 520px;
  --chat-shadow: var(--shadow-lg, 0 16px 48px rgba(28, 16, 9, 0.15));
  --chat-radius: 20px;
  --chat-transition: 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* --- Floating Toggle Button --- */
.chat-toggle {
  position: fixed;
  bottom: 28px;
  left: 28px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
  color: var(--chat-text-light);
  border: 2px solid var(--chat-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  box-shadow: 0 6px 24px rgba(139, 26, 47, 0.4);
  cursor: pointer;
  z-index: 850;
  transition: var(--chat-transition);
  outline: none;
  animation: chatBtnPulse 2.5s ease-in-out infinite;
}

.chat-toggle:hover {
  transform: scale(1.1) rotate(5deg);
  background: linear-gradient(135deg, var(--chat-accent), var(--chat-accent-light));
  border-color: var(--chat-primary);
  box-shadow: 0 8px 30px rgba(201, 149, 74, 0.5);
}

.chat-toggle.active {
  transform: scale(0.9) rotate(-90deg);
  background: var(--chat-bg-dark);
  border-color: var(--chat-accent-light);
}

@keyframes chatBtnPulse {
  0%, 100% { box-shadow: 0 6px 24px rgba(139, 26, 47, 0.4); }
  50% { box-shadow: 0 6px 36px rgba(139, 26, 47, 0.65), 0 0 0 10px rgba(139, 26, 47, 0.15); }
}

/* --- Chat Window Container --- */
.chat-window {
  position: fixed;
  bottom: 104px;
  left: 28px;
  width: var(--chat-window-width);
  height: var(--chat-window-height);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1.5px solid rgba(201, 149, 74, 0.25);
  border-radius: var(--chat-radius);
  box-shadow: var(--chat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 850;
  opacity: 0;
  pointer-events: none;
  transform: translateY(24px) scale(0.95);
  transition: var(--chat-transition);
}

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

/* --- Chat Header --- */
.chat-header {
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2.5px solid var(--chat-accent);
  position: relative;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-avatar {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid var(--chat-accent-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.chat-header-info h4 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--chat-text-light);
  margin: 0;
  letter-spacing: 0.5px;
}

.chat-status {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.75);
  display: flex;
  align-items: center;
  gap: 4px;
}

.status-dot {
  width: 6px;
  height: 6px;
  background-color: #2ec4b6;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 8px #2ec4b6;
  animation: statusGlow 1.8s infinite;
}

@keyframes statusGlow {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.chat-close {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: var(--chat-text-light);
  font-size: 0.85rem;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: 0.3s;
  font-family: sans-serif;
}

.chat-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

/* --- Chat Messages Area --- */
.chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: linear-gradient(to bottom, transparent, rgba(253, 248, 242, 0.6));
}

/* Custom Scrollbars */
.chat-messages::-webkit-scrollbar {
  width: 4px;
}
.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: var(--chat-accent-light);
  border-radius: 2px;
}

/* --- Message Bubbles --- */
.chat-message {
  max-width: 80%;
  padding: 11px 15px;
  border-radius: 16px;
  font-size: 0.88rem;
  line-height: 1.5;
  word-wrap: break-word;
  animation: messageSlideIn 0.35s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
  opacity: 0;
  transform: translateY(12px);
}

@keyframes messageSlideIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-message.bot {
  align-self: flex-start;
  background-color: var(--chat-text-light);
  color: var(--chat-text-dark);
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(201, 149, 74, 0.15);
  box-shadow: 0 4px 12px rgba(28, 16, 9, 0.04);
}

.chat-message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
  color: var(--chat-text-light);
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(139, 26, 47, 0.18);
}

.chat-message p {
  margin: 0;
}
.chat-message p + p {
  margin-top: 8px;
}

.chat-message strong {
  color: inherit;
  font-weight: 600;
}

.chat-message ul, .chat-message ol {
  margin: 6px 0 0 18px;
  padding: 0;
}

.chat-message li {
  margin-bottom: 4px;
}

/* --- Typing Indicator --- */
.chat-message.typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 18px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--chat-text-muted);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* --- Suggestions Area --- */
.chat-suggestions {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 20px;
  background: transparent;
  border-top: 1px solid rgba(201, 149, 74, 0.1);
  white-space: nowrap;
}

.chat-suggestions::-webkit-scrollbar {
  height: 0; /* Hide scrollbar but keep scroll functionality */
}

.suggestion-chip {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--chat-accent);
  background: rgba(255, 255, 255, 0.7);
  color: var(--chat-primary);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: 0.3s;
  flex-shrink: 0;
}

.suggestion-chip:hover {
  background: var(--chat-primary);
  border-color: var(--chat-primary);
  color: var(--chat-text-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(139, 26, 47, 0.15);
}

/* --- Dynamic Product Cards in Chat --- */
.chat-products-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
  width: 100%;
}

.chat-product-card {
  background: #ffffff;
  border: 1px solid rgba(201, 149, 74, 0.2);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  box-shadow: 0 4px 10px rgba(28, 16, 9, 0.05);
  transition: 0.3s;
}

.chat-product-card:hover {
  border-color: var(--chat-accent);
  box-shadow: 0 6px 15px rgba(28, 16, 9, 0.08);
}

.chat-product-img {
  width: 75px;
  height: 100px;
  object-fit: cover;
  flex-shrink: 0;
}

.chat-product-placeholder {
  width: 75px;
  height: 100px;
  background-color: var(--chat-accent-pale);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  flex-shrink: 0;
}

.chat-product-details {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: 1;
}

.chat-product-title {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--chat-primary-dark);
  margin: 0 0 2px 0;
  line-height: 1.2;
}

.chat-product-price {
  font-weight: 700;
  color: var(--chat-primary);
  font-size: 0.85rem;
  margin-bottom: 6px;
}

.chat-product-btn {
  align-self: flex-start;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  background-color: var(--chat-accent);
  color: var(--chat-text-dark);
  border-radius: 20px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.chat-product-btn:hover {
  background-color: var(--chat-primary);
  color: var(--chat-text-light);
}

/* --- Input Form --- */
.chat-form {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: #ffffff;
  border-top: 1.5px solid rgba(201, 149, 74, 0.15);
}

.chat-form input {
  flex: 1;
  border: none;
  outline: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem;
  padding: 8px 12px;
  color: var(--chat-text-dark);
  background: transparent;
}

.chat-form input::placeholder {
  color: var(--chat-text-muted);
  opacity: 0.7;
}

.chat-send {
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
  color: var(--chat-text-light);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.85rem;
  transition: 0.3s;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(139, 26, 47, 0.2);
}

.chat-send:hover {
  background: linear-gradient(135deg, var(--chat-accent), var(--chat-accent-light));
  color: var(--chat-text-dark);
  transform: scale(1.08);
}

/* ==========================================================================
   RESPONSIVE MEDIA QUERIES
   ========================================================================== */

@media (max-width: 640px) {
  .chat-toggle {
    bottom: 20px;
    left: 20px;
    width: 54px;
    height: 54px;
    font-size: 1.4rem;
  }
  
  .chat-window {
    width: 100%;
    height: 100%;
    bottom: 0;
    left: 0;
    border-radius: 0;
    border: none;
    z-index: 1000; /* overlay all floats on mobile */
  }
  
  .chat-header {
    border-bottom: 2px solid var(--chat-accent);
    padding: 14px 16px;
  }
  
  .chat-form {
    padding: 10px 14px 20px; /* extra bottom padding for mobile safe area */
  }
}
