/* =====================================================
   Saste Tools — FAQ Chatbot Widget
   Floating bottom-right assistant, stacked directly above
   the WhatsApp button (which stays bottom-right, lowest).
   ===================================================== */

:root {
  --fab-size: 56px;
  --fab-gap: 14px;
  --fab-right: 22px;
  --fab-bottom: 22px;
  --fab-stack: calc(var(--fab-bottom) + (2 * var(--fab-size)) + (2 * var(--fab-gap)));
  --faqbot-vh: 100dvh; /* overridden by JS to the real visible viewport height (handles mobile keyboard) */
}

.whatsapp-fab {
  position: fixed;
  bottom: var(--fab-bottom);
  right: var(--fab-right);
  width: var(--fab-size);
  height: var(--fab-size);
  background: #25D366;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: #fff;
  box-shadow: 0 6px 20px rgba(0,0,0,0.5);
  z-index: 1050;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.whatsapp-fab:hover { transform: translateY(-2px) scale(1.04); }

.faqbot-toggle {
  position: fixed;
  bottom: calc(var(--fab-bottom) + var(--fab-size) + var(--fab-gap));
  right: var(--fab-right);
  left: auto;
  width: var(--fab-size);
  height: var(--fab-size);
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), #ffdb70 55%, var(--gold));
  color: #000;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.55rem;
  cursor: pointer;
  box-shadow: 0 6px 20px var(--gold-glow);
  z-index: 1050;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.faqbot-toggle:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 10px 28px var(--gold-glow); }
.faqbot-toggle .fa-xmark { display: none; }
.faqbot-toggle.open .fa-comment-dots { display: none; }
.faqbot-toggle.open .fa-xmark { display: block; }

.faqbot-toggle-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  opacity: 0.55;
  animation: faqbotPulse 2.4s ease-out infinite;
  pointer-events: none;
}
.faqbot-toggle.open .faqbot-toggle-ring,
.faqbot-toggle.seen .faqbot-toggle-ring { animation-iteration-count: 3; }
@keyframes faqbotPulse {
  0% { transform: scale(0.85); opacity: 0.55; }
  100% { transform: scale(1.35); opacity: 0; }
}

.faqbot-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ff4444;
  border: 2px solid var(--black, #0a0a0a);
}
.faqbot-toggle.open .faqbot-badge,
.faqbot-toggle.seen .faqbot-badge { display: none; }

.faqbot-panel {
  position: fixed;
  /* Anchored between a safe top margin and the buttons at the bottom —
     guarantees the header is always fully on-screen no matter how tall
     or short the browser window is. Capped at 560px so it doesn't turn
     into a giant column on huge monitors. */
  top: 24px;
  bottom: var(--fab-stack);
  right: var(--fab-right);
  left: auto;
  width: 340px;
  max-width: calc(100vw - 32px);
  height: auto;
  max-height: 560px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg, 18px);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1050;
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.faqbot-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.faqbot-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--gold-glow-soft), transparent);
  border-bottom: 1px solid var(--card-border);
  flex-shrink: 0;
}
.faqbot-header i {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--gold);
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.faqbot-header div { min-width: 0; flex: 1; }
.faqbot-header strong { color: var(--text-light); font-size: 0.95rem; display: block; }
.faqbot-header span { color: var(--text-muted); font-size: 0.78rem; }

.faqbot-reset {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  flex-shrink: 0;
  transition: 0.15s ease;
}
.faqbot-reset:hover { color: var(--gold); background: var(--gold-glow-soft); }

.faqbot-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--card-border);
  flex-shrink: 0;
  background: var(--card-bg);
}
.faqbot-input-bar input {
  flex: 1;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 10px 16px;
  color: var(--text-light);
  font-size: 0.86rem;
  outline: none;
  transition: border-color 0.15s ease;
}
.faqbot-input-bar input:focus { border-color: var(--gold); }
.faqbot-input-bar input::placeholder { color: var(--text-muted); }
.faqbot-input-bar button {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--gold);
  color: #000;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}
.faqbot-input-bar button:hover { transform: scale(1.06); }
.faqbot-input-bar button:active { transform: scale(0.95); }

.faqbot-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.faqbot-bubble {
  max-width: 88%;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--card-border);
  border-radius: 14px 14px 14px 4px;
  padding: 10px 13px;
  color: var(--text-light);
  font-size: 0.86rem;
  line-height: 1.5;
  align-self: flex-start;
  overflow-wrap: anywhere;
  word-break: break-word;
  box-sizing: border-box;
}

.faqbot-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-self: stretch;
}
.faqbot-option {
  text-align: left;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text-light);
  font-size: 0.84rem;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: 0.15s ease;
}
.faqbot-option:hover,
.faqbot-option:active {
  border-color: var(--gold);
  background: var(--gold-glow-soft);
}
.faqbot-option i { color: var(--gold); margin-right: 8px; width: 14px; }

.faqbot-bubble-user {
  align-self: flex-end;
  background: var(--gold-glow-soft);
  border-color: var(--gold);
  border-radius: 14px 14px 4px 14px;
  color: var(--text-light);
}

.faqbot-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-self: stretch;
}
.faqbot-quick-btn {
  flex: 1 1 auto;
  white-space: nowrap;
  background: var(--gold-glow-soft);
  border: 1px solid var(--gold);
  color: var(--text-light);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 20px;
  cursor: pointer;
  transition: 0.15s ease;
}
.faqbot-quick-btn:hover { background: var(--gold); color: #000; }
.faqbot-quick-btn i { margin-right: 6px; color: inherit; }

.faqbot-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--card-border);
  border-radius: 14px 14px 14px 4px;
  padding: 12px 14px;
}
.faqbot-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: faqbotTypingBounce 1.1s infinite ease-in-out;
}
.faqbot-typing span:nth-child(2) { animation-delay: 0.15s; }
.faqbot-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes faqbotTypingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.faqbot-products {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-self: stretch;
}
.faqbot-product-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 8px;
}
.faqbot-product-card img {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: rgba(255,255,255,0.05);
}
.faqbot-product-info { flex: 1; min-width: 0; }
.faqbot-product-name {
  color: var(--text-light);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.faqbot-product-price {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--gold);
  font-size: 0.82rem;
  font-weight: 700;
}
.faqbot-old-price {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.74rem;
  text-decoration: line-through;
}
.faqbot-product-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}
.faqbot-product-view,
.faqbot-product-buy {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 8px;
  text-decoration: none;
  white-space: nowrap;
}
.faqbot-product-view {
  border: 1px solid var(--card-border);
  color: var(--text-light);
}
.faqbot-product-buy {
  background: var(--gold);
  color: #000;
}
.faqbot-product-oos {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-align: center;
}

.faqbot-back {
  align-self: flex-start;
  background: none;
  border: none;
  color: var(--gold);
  font-size: 0.78rem;
  cursor: pointer;
  padding: 4px 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

@media (max-width: 480px) {
  :root {
    --fab-size: 48px;
    --fab-gap: 10px;
    --fab-right: 14px;
    --fab-bottom: 14px;
  }
  .faqbot-toggle { font-size: 1.25rem; }
  .whatsapp-fab { font-size: 1.3rem; }
  .faqbot-panel {
    top: auto;
    right: 8px;
    width: calc(100vw - 16px);
    /* On mobile the on-screen keyboard eats space from the bottom, so we
       size the panel from the actual visible viewport height (kept live
       by JS in --faqbot-vh) instead of a fixed top margin — otherwise the
       keyboard pushes the header off the top of the screen. */
    height: min(500px, calc(var(--faqbot-vh) - var(--fab-stack) - 16px));
    max-height: calc(var(--faqbot-vh) - var(--fab-stack) - 16px);
  }
}

@media (max-width: 360px) {
  :root {
    --fab-size: 44px;
    --fab-gap: 8px;
    --fab-right: 10px;
    --fab-bottom: 10px;
  }
  .faqbot-toggle { font-size: 1.1rem; }
  .whatsapp-fab { font-size: 1.15rem; }
  .faqbot-header strong { font-size: 0.88rem; }
  .faqbot-input-bar input { font-size: 0.8rem; padding: 8px 12px; }
}
