/* =============================================
   IKKATTHE SILKS — Conversational Assistant CSS
   ============================================= */

:root {
  --chat-primary: #5c1420;
  --chat-accent: #c44e15;
  --chat-gold: #c9a84c;
  --chat-bg: #f8f5ef;
  --chat-white: #ffffff;
  --chat-text: #1a1a1a;
  --chat-border: rgba(92, 20, 32, 0.08);
  --chat-shadow: 0 12px 40px rgba(92, 20, 32, 0.12);
}

/* ── FLOATING BUBBLE ── */
.chatbot-bubble {
  position: fixed;
  bottom: 30px;
  left: 30px;
  right: auto;
  width: 60px;
  height: 60px;
  background: var(--chat-primary);
  border-radius: 50%;
  box-shadow: 0 8px 24px rgba(92, 20, 32, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--chat-white);
  font-size: 1.6rem;
  cursor: pointer;
  z-index: 9999;
  transition: transform 0.35s cubic-bezier(0.19, 1, 0.22, 1), background-color 0.3s;
}

.chatbot-bubble:hover {
  transform: scale(1.08) rotate(5deg);
  background: var(--chat-accent);
}

.chatbot-bubble i {
  transition: transform 0.3s;
}

.chatbot-bubble.active i {
  transform: rotate(90deg);
}

/* ── CHAT WINDOW ── */
.chatbot-window {
  position: fixed;
  bottom: 105px;
  left: 30px;
  right: auto;
  width: 380px;
  height: 580px;
  max-height: calc(100vh - 140px);
  background: var(--chat-bg);
  border-radius: 16px;
  box-shadow: var(--chat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9998;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  visibility: hidden;   /* truly removes the full-screen window (and its children) from hit-testing when closed */
  transition: opacity 0.4s cubic-bezier(0.19, 1, 0.22, 1), transform 0.4s cubic-bezier(0.19, 1, 0.22, 1), visibility 0.4s;
  border: 1px solid var(--chat-border);
}

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

/* ── HEADER ── */
.chat-header {
  background: var(--chat-primary);
  color: var(--chat-white);
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.chat-avatar {
  width: 38px;
  height: 38px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--chat-gold);
  border: 1px solid rgba(201, 168, 76, 0.3);
  font-size: 1.15rem;
}

.chat-title-wrapper h3 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.1rem;
  margin: 0;
  font-weight: 500;
  letter-spacing: 0.03em;
}

.chat-status {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.6);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.chat-status::before {
  content: '';
  width: 6px;
  height: 6px;
  background: #4caf50;
  border-radius: 50%;
  display: inline-block;
}

.chat-close-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.3rem;
  transition: color 0.2s;
}

.chat-close-btn:hover {
  color: var(--chat-white);
}

/* ── TABS ── */
.chat-tabs {
  display: flex;
  background: var(--chat-white);
  border-bottom: 1px solid var(--chat-border);
  flex-shrink: 0;
}

.chat-tab {
  flex: 1;
  padding: 0.8rem 0;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: rgba(26, 26, 26, 0.5);
  border-bottom: 2px solid transparent;
  text-align: center;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.chat-tab:hover {
  color: var(--chat-primary);
}

.chat-tab.active {
  color: var(--chat-primary);
  border-color: var(--chat-primary);
}

/* ── VIEWS CONTAINER ── */
.chat-views {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.chat-view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  overflow: hidden;
}

.chat-view.active {
  opacity: 1;
  pointer-events: all;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── CHAT VIEW AREA ── */
.chat-messages {
  flex: 1;
  padding: 1.25rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Message Styles */
.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  animation: msgFadeIn 0.3s ease forwards;
}

@keyframes msgFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-msg.bot {
  align-self: flex-start;
}

.chat-msg.user {
  align-self: flex-end;
}

.chat-msg-bubble {
  padding: 0.8rem 1rem;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.5;
  word-break: break-word;
}

.chat-msg.bot .chat-msg-bubble {
  background: var(--chat-white);
  color: var(--chat-text);
  border-top-left-radius: 2px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
  border: 1px solid rgba(92, 20, 32, 0.04);
}

.chat-msg.user .chat-msg-bubble {
  background: var(--chat-primary);
  color: var(--chat-white);
  border-top-right-radius: 2px;
}

.chat-msg-time {
  font-size: 0.65rem;
  color: rgba(26, 26, 26, 0.4);
  margin-top: 0.25rem;
  padding-inline: 0.2rem;
}

.chat-msg.user .chat-msg-time {
  align-self: flex-end;
}

/* Dynamic Product Grid inside Chat */
.chat-product-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.6rem;
  width: 100%;
}

.chat-product-card {
  display: flex;
  gap: 0.8rem;
  background: var(--chat-white);
  padding: 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--chat-border);
  align-items: center;
}

.chat-product-card img {
  width: 50px;
  height: 66px;
  object-fit: cover;
  border-radius: 4px;
  background: #efeae0;
}

.chat-product-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.chat-product-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--chat-text);
  line-height: 1.2;
}

.chat-product-price {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--chat-primary);
}

.chat-product-qv {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--chat-accent);
  background: none;
  border: none;
  font-weight: 700;
  cursor: pointer;
  align-self: flex-start;
  padding: 0;
  margin-top: 0.2rem;
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.chat-product-qv:hover {
  text-decoration: underline;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 0.5rem 0.8rem;
  background: var(--chat-white);
  border-radius: 12px;
  border-top-left-radius: 2px;
  align-self: flex-start;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
  border: 1px solid rgba(92, 20, 32, 0.04);
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: rgba(92, 20, 32, 0.4);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out;
}

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

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.6); }
  40% { transform: scale(1) translateY(-4px); background: var(--chat-primary); }
}

/* ── CHAT INPUT FOOTER ── */
.chat-input-area {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.8rem 1rem;
  background: var(--chat-white);
  border-top: 1px solid var(--chat-border);
  flex-shrink: 0;
}

.chat-input-area input {
  flex: 1;
  border: 1px solid var(--chat-border);
  border-radius: 24px;
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  outline: none;
  background: var(--chat-bg);
  color: var(--chat-text);
  font-family: inherit;
}

.chat-input-area input:focus {
  border-color: var(--chat-primary);
  background: var(--chat-white);
}

.chat-send-btn {
  width: 36px;
  height: 36px;
  background: var(--chat-primary);
  color: var(--chat-white);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  font-size: 1.1rem;
  transition: background-color 0.2s, transform 0.2s;
}

.chat-send-btn:hover {
  background: var(--chat-accent);
  transform: scale(1.05);
}

/* Quick replies suggestion chips */
.chat-suggestions {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0 1rem 0.8rem 1rem;
  scrollbar-width: none;
  flex-shrink: 0;
}

.chat-suggestions::-webkit-scrollbar {
  display: none;
}

.chat-chip {
  white-space: nowrap;
  background: var(--chat-white);
  color: var(--chat-primary);
  border: 1px solid var(--chat-primary);
  padding: 0.4rem 0.8rem;
  border-radius: 16px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}

.chat-chip:hover {
  background: var(--chat-primary);
  color: var(--chat-white);
}

/* ── SHOP TAB VIEW ── */
.shop-view-content {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.shop-section-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1rem;
  color: var(--chat-primary);
  margin-bottom: 0.6rem;
  border-bottom: 1px solid var(--chat-border);
  padding-bottom: 0.3rem;
  font-weight: 600;
}

.shop-categories-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
}

.shop-cat-btn {
  background: var(--chat-white);
  border: 1px solid var(--chat-border);
  padding: 0.75rem;
  border-radius: 8px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--chat-text);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.shop-cat-btn:hover {
  border-color: var(--chat-primary);
  color: var(--chat-primary);
  background: rgba(92, 20, 32, 0.02);
  transform: translateY(-2px);
}

.shop-cat-btn i {
  font-size: 1.2rem;
  color: var(--chat-accent);
}

.shop-featured-grid {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* ── FAQ TAB VIEW ── */
.faq-view-content {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.faq-item {
  background: var(--chat-white);
  border: 1px solid var(--chat-border);
  border-radius: 8px;
  overflow: hidden;
}

.faq-question {
  width: 100%;
  padding: 0.85rem 1rem;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--chat-primary);
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  background: rgba(92, 20, 32, 0.01);
}

.faq-answer-inner {
  padding: 0 1.25rem 1rem 1.25rem;
  font-size: 0.8rem;
  color: rgba(26, 26, 26, 0.75);
  line-height: 1.5;
}

.faq-item.active .faq-answer {
  max-height: 200px;
}

.faq-item.active .faq-question i {
  transform: rotate(180deg);
}

.faq-question i {
  transition: transform 0.25s;
}

/* ── GUIDE TAB VIEW ── */
.guide-view-content {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.guide-card {
  background: var(--chat-white);
  padding: 1.25rem;
  border-radius: 10px;
  border: 1px solid var(--chat-border);
  box-shadow: 0 2px 10px rgba(92, 20, 32, 0.02);
}

.guide-card h4 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 0.95rem;
  color: var(--chat-primary);
  margin: 0 0 0.5rem 0;
  font-weight: 600;
}

.guide-card p {
  font-size: 0.78rem;
  color: rgba(26, 26, 26, 0.7);
  line-height: 1.6;
  margin: 0;
}

/* Webkit overflow smooth touch scrolling */
.chat-messages,
.shop-view-content,
.faq-view-content,
.guide-view-content {
  -webkit-overflow-scrolling: touch;
}

/* Body Scroll Lock Rule */
body.chat-open {
  overflow: hidden !important;
}

@media(max-width: 768px) {
  .chatbot-bubble {
    left: 20px;
    right: auto;
    bottom: 80px; /* Positioned neatly above the mobile bottom nav bar */
    width: 52px;
    height: 52px;
    font-size: 1.35rem;
    box-shadow: 0 6px 18px rgba(92, 20, 32, 0.2);
    z-index: 10001; /* Above bottom nav bar */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  .chatbot-window {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100vw;
    height: 100%;
    max-height: none;
    border-radius: 0;
    border: none;
    z-index: 10002; /* Overlays bubble, bottom nav and other overlays */
  }

  .chatbot-window .chat-views {
    flex: 1;
    min-height: 0; /* Allow flex child to shrink and enable scroll */
  }

  .chatbot-window .chat-messages {
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .chat-header {
    padding-top: calc(1.25rem + env(safe-area-inset-top, 0px));
    flex-shrink: 0;
  }

  .chat-tabs {
    flex-shrink: 0;
  }

  .chat-input-area {
    padding-bottom: calc(0.8rem + env(safe-area-inset-bottom, 0px));
    flex-shrink: 0;
  }

  .chat-suggestions {
    flex-shrink: 0;
  }
}
