/* =============================================================================
   TechZone AI Chatbot Widget — chatbot.css
   Sits at bottom-right, right: 84px so it doesn't overlap the theme's
   existing live-chat icon. Teaser collapses on scroll, springs back on idle.
   ============================================================================= */

/* ── Root wrapper ─────────────────────────────────────────────────────────── */
#tz-chatbot {
  position: fixed;
  bottom: 24px;
  right: 84px;
  z-index: 999990;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1;
}

/* ─────────────────────────────────────────────────────────────────────────────
   TOGGLE BUTTON
   ───────────────────────────────────────────────────────────────────────────── */
.tz-cb-toggle {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(145deg, #1d4ed8 0%, #3b82f6 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 22px rgba(29, 78, 216, .45);
  outline: none;
  transition: transform .22s ease, box-shadow .22s ease;
  overflow: visible;
}
.tz-cb-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 32px rgba(29, 78, 216, .55);
}
.tz-cb-toggle:active  { transform: scale(.92); }
.tz-cb-toggle:focus-visible {
  outline: 3px solid #3b82f6;
  outline-offset: 4px;
}

/* ── Icons inside toggle ────────────────────────────────────────────────── */
.tz-cb-toggle svg {
  width: 27px;
  height: 27px;
  fill: #fff;
  position: absolute;
  transition: opacity .25s ease, transform .32s cubic-bezier(.34, 1.56, .64, 1);
}
.tz-cb-icon-open  { opacity: 1; transform: scale(1) rotate(0deg); }
.tz-cb-icon-close { opacity: 0; transform: scale(.55) rotate(-90deg); }

#tz-chatbot.tz-cb-active .tz-cb-icon-open  { opacity: 0; transform: scale(.55) rotate(90deg); }
#tz-chatbot.tz-cb-active .tz-cb-icon-close { opacity: 1; transform: scale(1)  rotate(0deg); }

/* ── Pulse ring ─────────────────────────────────────────────────────────── */
.tz-cb-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(59, 130, 246, .38);
  animation: tz-cb-pulse 2.8s ease-out infinite;
  pointer-events: none;
  z-index: -1;
}
#tz-chatbot.tz-cb-active .tz-cb-pulse { display: none; }

@keyframes tz-cb-pulse {
  0%   { transform: scale(1);    opacity: .85; }
  75%  { transform: scale(1.68); opacity: 0; }
  100% { transform: scale(1.68); opacity: 0; }
}

/* ── Notification dot ───────────────────────────────────────────────────── */
.tz-cb-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  background: #ef4444;
  border-radius: 50%;
  border: 2.5px solid #fff;
  animation: tz-cb-dot-bounce 1.1s ease-in-out infinite alternate;
  z-index: 1;
}
#tz-chatbot.tz-cb-active .tz-cb-dot { display: none; }

@keyframes tz-cb-dot-bounce {
  from { transform: scale(1); }
  to   { transform: scale(1.28); }
}

/* ─────────────────────────────────────────────────────────────────────────────
   TEASER BUBBLE
   ───────────────────────────────────────────────────────────────────────────── */
.tz-cb-teaser {
  position: absolute;
  bottom: calc(100% + 14px);
  right: 0;
  width: 248px;
  background: #fff;
  border-radius: 16px 16px 0 16px;
  padding: 13px 15px 12px;
  box-shadow: 0 8px 38px rgba(0, 0, 0, .17);
  border: 1px solid rgba(29, 78, 216, .13);
  transform-origin: bottom right;
  /* Hidden by default */
  opacity: 0;
  transform: scale(.82) translateY(10px);
  pointer-events: none;
  transition: opacity .35s ease, transform .42s cubic-bezier(.34, 1.56, .64, 1);
  cursor: pointer;
}
.tz-cb-teaser.tz-cb-teaser-show {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}

/* small arrow pointing at button */
.tz-cb-teaser::after {
  content: '';
  position: absolute;
  bottom: -8px;
  right: 18px;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 9px solid #fff;
  filter: drop-shadow(0 3px 2px rgba(0, 0, 0, .07));
}

/* ── Typing dots phase ──────────────────────────────────────────────────── */
.tz-cb-teaser-dots {
  display: flex;
  gap: 5px;
  align-items: center;
  height: 22px;
  padding: 2px 0;
}
.tz-cb-teaser-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3b82f6;
  animation: tz-cb-typing 1s ease infinite;
}
.tz-cb-teaser-dots span:nth-child(2) { animation-delay: .2s; }
.tz-cb-teaser-dots span:nth-child(3) { animation-delay: .4s; }

/* ── Text phase (shown after typing animation) ──────────────────────────── */
.tz-cb-teaser-body { display: none; }

.tz-cb-teaser.tz-cb-typed .tz-cb-teaser-dots { display: none; }
.tz-cb-teaser.tz-cb-typed .tz-cb-teaser-body { display: block; }

.tz-cb-teaser-body p {
  margin: 0 0 4px;
  font-size: 13.5px;
  color: #1e293b;
  line-height: 1.55;
  padding-right: 18px; /* space for X button */
}
.tz-cb-teaser-body p strong { color: #1d4ed8; }
.tz-cb-teaser-body small {
  display: block;
  font-size: 11.5px;
  color: #64748b;
  margin-top: 5px;
  line-height: 1.4;
}

/* ── Dismiss × ──────────────────────────────────────────────────────────── */
.tz-cb-teaser-x {
  position: absolute;
  top: 9px;
  right: 10px;
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  color: #94a3b8;
  border-radius: 50%;
  padding: 0;
  line-height: 1;
  transition: color .15s, background .15s;
}
.tz-cb-teaser-x:hover {
  color: #1e293b;
  background: #f1f5f9;
}

/* ─────────────────────────────────────────────────────────────────────────────
   CHAT PANEL
   ───────────────────────────────────────────────────────────────────────────── */
.tz-cb-panel {
  position: absolute;
  bottom: calc(100% + 14px);
  right: 0;
  width: 364px;
  height: 516px;
  background: #fff;
  border-radius: 22px;
  box-shadow: 0 12px 56px rgba(0, 0, 0, .22);
  border: 1px solid rgba(0, 0, 0, .07);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Hidden by default */
  opacity: 0;
  transform: scale(.88) translateY(26px);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity .3s ease, transform .38s cubic-bezier(.34, 1.2, .64, 1);
}
.tz-cb-panel.tz-cb-panel-open {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}

/* ─────────────────────────────────────────────────────────────────────────────
   PANEL — HEADER
   ───────────────────────────────────────────────────────────────────────────── */
.tz-cb-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 55%, #1d4ed8 100%);
  padding: 14px 14px 13px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.tz-cb-hinfo {
  display: flex;
  align-items: center;
  gap: 11px;
}
.tz-cb-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  border: 1.5px solid rgba(255, 255, 255, .28);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.tz-cb-hname {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.3;
}
/* Online green dot */
.tz-cb-hname::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
  animation: tz-cb-dot-bounce 1.2s ease-in-out infinite alternate;
}
.tz-cb-hsub {
  font-size: 11.5px;
  color: rgba(255, 255, 255, .62);
  margin-top: 2px;
  line-height: 1;
  display: block;
}
.tz-cb-panel-x {
  background: rgba(255, 255, 255, .12);
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  color: #fff;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
  transition: background .15s;
}
.tz-cb-panel-x:hover { background: rgba(255, 255, 255, .26); }

/* ─────────────────────────────────────────────────────────────────────────────
   PANEL — MESSAGES
   ───────────────────────────────────────────────────────────────────────────── */
.tz-cb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}
.tz-cb-messages::-webkit-scrollbar { width: 4px; }
.tz-cb-messages::-webkit-scrollbar-track { background: transparent; }
.tz-cb-messages::-webkit-scrollbar-thumb {
  background: #e2e8f0;
  border-radius: 4px;
}

/* Message row */
.tz-cb-msg {
  display: flex;
  animation: tz-cb-msgin .28s ease both;
}
@keyframes tz-cb-msgin {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.tz-cb-msg-bot  { justify-content: flex-start; }
.tz-cb-msg-user { justify-content: flex-end; }

/* Bubbles */
.tz-cb-bubble {
  max-width: 84%;
  padding: 10px 14px;
  font-size: 13.5px;
  line-height: 1.65;
  word-break: break-word;
  border-radius: 16px;
}
.tz-cb-msg-bot  .tz-cb-bubble {
  background: #f1f5f9;
  color: #1e293b;
  border-top-left-radius: 4px;
}
.tz-cb-msg-user .tz-cb-bubble {
  background: linear-gradient(135deg, #1d4ed8, #3b82f6);
  color: #fff;
  border-top-right-radius: 4px;
}

/* ── Typing indicator ────────────────────────────────────────────────────── */
.tz-cb-typing-row {
  display: flex;
  animation: tz-cb-msgin .28s ease both;
}
.tz-cb-typing-dots {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 11px 14px;
  background: #f1f5f9;
  border-radius: 16px;
  border-top-left-radius: 4px;
}
.tz-cb-typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  animation: tz-cb-typing 1s ease infinite;
}
.tz-cb-typing-dots span:nth-child(2) { animation-delay: .2s; }
.tz-cb-typing-dots span:nth-child(3) { animation-delay: .4s; }

@keyframes tz-cb-typing {
  0%, 80%, 100% { transform: scale(1);    opacity: .5; }
  40%            { transform: scale(1.35); opacity: 1; }
}

/* ─────────────────────────────────────────────────────────────────────────────
   PANEL — QUICK SUGGESTIONS
   ───────────────────────────────────────────────────────────────────────────── */
.tz-cb-suggestions {
  padding: 8px 14px 10px;
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  flex-shrink: 0;
  border-top: 1px solid #f1f5f9;
}
.tz-cb-chip {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.5;
  transition: background .15s, color .15s, border-color .15s, transform .12s;
}
.tz-cb-chip:hover  { background: #1d4ed8; color: #fff; border-color: #1d4ed8; }
.tz-cb-chip:active { transform: scale(.95); }

/* ─────────────────────────────────────────────────────────────────────────────
   PANEL — INPUT ROW
   ───────────────────────────────────────────────────────────────────────────── */
.tz-cb-input-row {
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  border-top: 1px solid #e2e8f0;
  background: #fafbfc;
  flex-shrink: 0;
}
#tz-cb-input {
  flex: 1;
  border: 1.5px solid #e2e8f0;
  border-radius: 13px;
  padding: 9px 13px;
  font-size: 13.5px;
  font-family: inherit;
  resize: none;
  outline: none;
  background: #fff;
  color: #1e293b;
  max-height: 100px;
  min-height: 38px;
  line-height: 1.5;
  transition: border-color .2s;
  overflow-y: auto;
}
#tz-cb-input:focus       { border-color: #3b82f6; }
#tz-cb-input::placeholder { color: #94a3b8; }
#tz-cb-input[dir="rtl"]  { text-align: right; }   /* Arabic RTL support */

.tz-cb-send {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: #1d4ed8;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, transform .15s;
}
.tz-cb-send:hover  { background: #1e40af; transform: scale(1.06); }
.tz-cb-send:active { transform: scale(.94); }
.tz-cb-send svg    { width: 18px; height: 18px; fill: #fff; }

/* ─────────────────────────────────────────────────────────────────────────────
   PANEL — FOOTER
   ───────────────────────────────────────────────────────────────────────────── */
.tz-cb-footer {
  text-align: center;
  font-size: 10.5px;
  color: #94a3b8;
  padding: 6px 12px 8px;
  background: #fafbfc;
  border-top: 1px solid #f1f5f9;
  flex-shrink: 0;
  letter-spacing: .01em;
}
.tz-cb-footer strong { color: #64748b; }

/* ─────────────────────────────────────────────────────────────────────────────
   MOBILE — fullscreen panel
   ───────────────────────────────────────────────────────────────────────────── */
@media (max-width: 520px) {
  #tz-chatbot {
    right: 16px;
    bottom: 16px;
  }
  .tz-cb-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100dvh;
    height: 100vh;
    border-radius: 0;
    transform-origin: bottom center;
  }
  .tz-cb-teaser { width: 210px; }
}


/* =============================================================================
   PRODUCT CARDS — rendered inside bot bubble when the API returns matches
   ============================================================================= */

.tz-cb-products {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.tz-cb-prod {
  display: flex;
  gap: 10px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 8px;
  text-decoration: none;
  color: #1e293b;
  transition: border-color .15s, box-shadow .15s, transform .12s;
}
.tz-cb-prod:hover {
  border-color: #3b82f6;
  box-shadow: 0 4px 14px rgba(29, 78, 216, .14);
  transform: translateY(-1px);
}
.tz-cb-prod:active { transform: scale(.98); }

.tz-cb-prod__img {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: #f1f5f9;
}

.tz-cb-prod__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}

.tz-cb-prod__name {
  font-size: 12.5px;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tz-cb-prod__meta {
  font-size: 11px;
  color: #64748b;
  line-height: 1.3;
}

.tz-cb-prod__price {
  font-size: 13px;
  font-weight: 700;
  color: #1d4ed8;
  margin-top: 2px;
}
