/* ============================================================
   GZMBot Chat Widget — Production v2.0
   GZM Enterprises · Purple branded theme
   ============================================================ */

:root {
  --gzm-purple-dark:  #4a2fbf;
  --gzm-purple:       #5b3fd6;
  --gzm-purple-mid:   #6d4ef0;
  --gzm-purple-light: #8a6df5;
  --gzm-purple-pale:  #f3f0ff;
  --gzm-purple-tint:  #ebe8fd;
  /* Kept as legacy aliases so the floating-bubble block below compiles unchanged */
  --gzm-navy:    #4a2fbf;
  --gzm-blue:    #6d4ef0;
  --gzm-accent:  #5b3fd6;
  --gzm-sky:     #8a6df5;
  --gzm-light:   #f3f0ff;
  /* Neutrals */
  --gzm-white:     #ffffff;
  --gzm-gray-50:   #f8f7fc;
  --gzm-gray-100:  #eeedf6;
  --gzm-gray-200:  #dddbe9;
  --gzm-gray-300:  #c0bdd4;
  --gzm-gray-500:  #7a7890;
  --gzm-gray-700:  #2d2b3a;
  /* Status */
  --gzm-green:     #22c55e;
  --gzm-red:       #ef4444;
  --gzm-booking:   #ef4444;
  /* Shape */
  --gzm-radius:    18px;
  --gzm-radius-md: 12px;
  --gzm-radius-sm: 8px;
  --gzm-shadow:    0 8px 32px rgba(74,47,191,.14), 0 2px 8px rgba(74,47,191,.08);
  --gzm-font:      'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ── Widget shell ──────────────────────────────────────────── */
.gzmbot-widget {
  font-family: var(--gzm-font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--gzm-gray-700);
  background: var(--gzm-white);
  border: 1px solid var(--gzm-gray-200);
  border-radius: var(--gzm-radius);
  box-shadow: var(--gzm-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-width: 820px;
  margin: 0 auto;
}

/* ── Header ────────────────────────────────────────────────── */
.gzmbot-header {
  background: linear-gradient(118deg, var(--gzm-purple-dark) 0%, var(--gzm-purple-mid) 100%);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}
.gzmbot-header-title {
  color: #fff;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -.015em;
  white-space: nowrap;
}

/* ── Overflow menu ─────────────────────────────────────────── */
.gzmbot-header-actions { position: relative; }

.gzmbot-menu-trigger {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 8px;
  color: rgba(255,255,255,.9);
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .15s;
  flex-shrink: 0;
}
.gzmbot-menu-trigger:hover { background: rgba(255,255,255,.26); }
.gzmbot-menu-trigger svg { width: 18px; height: 18px; }

.gzmbot-menu-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--gzm-white);
  border: 1px solid var(--gzm-gray-200);
  border-radius: var(--gzm-radius-md);
  box-shadow: 0 10px 28px rgba(45,43,58,.18);
  min-width: 175px;
  padding: 5px;
  opacity: 0;
  transform: translateY(-6px) scale(.97);
  pointer-events: none;
  transition: opacity .15s, transform .15s;
  z-index: 50;
}
.gzmbot-menu-dropdown.gzmbot-menu-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.gzmbot-menu-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%;
  background: none; border: none; text-align: left;
  padding: 9px 11px;
  border-radius: 7px;
  font-family: var(--gzm-font);
  font-size: 13.5px; font-weight: 500;
  color: var(--gzm-gray-700);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.gzmbot-menu-item:hover { background: var(--gzm-purple-pale); color: var(--gzm-purple); }
.gzmbot-menu-item svg { width: 15px; height: 15px; flex-shrink: 0; opacity: .7; }

/* ── Messages container ────────────────────────────────────── */
.gzmbot-messages {
  overflow-y: auto;
  padding: 22px 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--gzm-white);
  scroll-behavior: smooth;
  flex: 1;
}
.gzmbot-messages::-webkit-scrollbar { width: 4px; }
.gzmbot-messages::-webkit-scrollbar-thumb {
  background: var(--gzm-gray-200);
  border-radius: 4px;
}

/* ── Avatar ────────────────────────────────────────────────── */
.gzmbot-avatar-wrap {
  width: 38px; height: 38px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--gzm-purple-pale);
  border: 2px solid var(--gzm-purple-tint);
  display: flex; align-items: center; justify-content: center;
  align-self: flex-end;  /* sits at bottom of bubble for multi-line messages */
}
.gzmbot-avatar-img { width: 100%; height: 100%; object-fit: cover; }
.gzmbot-avatar-fallback {
  display: none;
  width: 100%; height: 100%;
  align-items: center; justify-content: center;
  color: var(--gzm-purple);
}
.gzmbot-avatar-fallback svg { width: 20px; height: 20px; }

/* ── Message rows ──────────────────────────────────────────── */
.gzmbot-msg { display: flex; flex-direction: column; margin-bottom: 10px; }
.gzmbot-msg--user { align-items: flex-end; }
.gzmbot-msg--bot  { align-items: flex-start; }

.gzmbot-msg-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: 88%;
}
.gzmbot-msg--bot .gzmbot-msg-row  { flex-direction: row; }
.gzmbot-msg--user .gzmbot-msg-row { flex-direction: row-reverse; }

/* ── Bubbles ───────────────────────────────────────────────── */
.gzmbot-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  line-height: 1.6;
  word-break: break-word;
  max-width: 100%;
}
.gzmbot-msg--user .gzmbot-bubble {
  background: linear-gradient(135deg, var(--gzm-purple) 0%, var(--gzm-purple-mid) 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.gzmbot-msg--bot .gzmbot-bubble {
  background: var(--gzm-gray-50);
  border: 1px solid var(--gzm-gray-100);
  color: var(--gzm-gray-700);
  border-bottom-left-radius: 4px;
}
.gzmbot-bubble p         { margin: 0 0 8px; }
.gzmbot-bubble p:last-child { margin-bottom: 0; }
.gzmbot-bubble ul        { margin: 6px 0 6px 18px; padding: 0; }
.gzmbot-bubble li        { margin-bottom: 4px; }
.gzmbot-bubble strong    { font-weight: 700; }

/* ── Timestamps ────────────────────────────────────────────── */
.gzmbot-timestamp {
  font-size: 11px;
  color: var(--gzm-gray-300);
  margin-top: 4px;
  padding: 0 2px;
}
.gzmbot-timestamp--bot  { margin-left: 48px; }
.gzmbot-timestamp--user { margin-right: 2px; }

/* ── Suggestion chips (full-width pill rows with icon) ─────── */
.gzmbot-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 6px 0 4px 48px;
}
.gzmbot-chip {
  display: flex; align-items: center; gap: 9px;
  background: var(--gzm-white);
  border: 1.5px solid var(--gzm-gray-200);
  color: var(--gzm-purple);
  border-radius: 24px;
  padding: 9px 16px;
  font-size: 13.5px; font-weight: 600;
  font-family: var(--gzm-font);
  cursor: pointer;
  transition: all .15s;
  flex: 1 1 calc(50% - 4px);
  min-width: 140px;
  text-align: left;
  line-height: 1.3;
}
.gzmbot-chip--wide { flex-basis: 100%; }
.gzmbot-chip svg   { width: 16px; height: 16px; flex-shrink: 0; opacity: .7; }
.gzmbot-chip span  { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gzmbot-chip:hover {
  color:var(--gzm-purple);    
  background: var(--gzm-purple-pale);
  border-color: var(--gzm-purple);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(91,63,214,.12);
}
.gzmbot-chip:active { transform: translateY(0); }

/* ── Source links ──────────────────────────────────────────── */
.gzmbot-sources {
  font-size: 12px;
  color: var(--gzm-gray-500);
  background: var(--gzm-purple-pale);
  border: 1px solid var(--gzm-purple-tint);
  border-radius: var(--gzm-radius-sm);
  padding: 7px 11px;
  line-height: 1.5;
  margin-top: 6px;
  margin-left: 48px;
}
.gzmbot-sources a {
  color: var(--gzm-purple);
  text-decoration: none;
  font-weight: 600;
}
.gzmbot-sources a:hover { text-decoration: underline; }

/* ── Booking CTA ───────────────────────────────────────────── */
.gzmbot-booking-cta {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(90deg, #b91c1c, var(--gzm-red));
  color: #fff !important;
  text-decoration: none !important;
  border-radius: var(--gzm-radius-sm);
  padding: 10px 14px;
  font-size: 13.5px; font-weight: 600;
  line-height: 1.4;
  margin-top: 6px;
  margin-left: 48px;
  transition: opacity .18s, transform .15s;
}
.gzmbot-booking-cta:hover { opacity: .92; transform: translateY(-1px); }

/* ── Typing indicator ──────────────────────────────────────── */
.gzmbot-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 0 8px 68px;
  background: var(--gzm-white);
  flex-shrink: 0;
}
.gzmbot-typing span {
  width: 7px; height: 7px;
  background: var(--gzm-purple-light);
  border-radius: 50%;
  animation: gzmBounce 1.2s infinite ease-in-out;
}
.gzmbot-typing span:nth-child(2) { animation-delay: .2s; }
.gzmbot-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes gzmBounce {
  0%,60%,100% { transform: translateY(0);   opacity: .5; }
  30%          { transform: translateY(-8px); opacity: 1; }
}

/* ── Input area ────────────────────────────────────────────── */
.gzmbot-input-area {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--gzm-gray-100);
  background: var(--gzm-white);
  flex-shrink: 0;
}
.gzmbot-input {
  flex: 1;
  resize: none;
  border: 1.5px solid var(--gzm-gray-200);
  border-radius: 26px;
  padding: 11px 18px;
  font-family: var(--gzm-font);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--gzm-gray-700);
  background: var(--gzm-gray-50);
  outline: none;
  transition: border-color .18s, background .18s, box-shadow .18s;
  max-height: 120px;
  overflow-y: auto;
  -webkit-appearance: none;
}
.gzmbot-input:focus {
  background: var(--gzm-white);
  border-color: var(--gzm-purple);
  box-shadow: 0 0 0 3px rgba(91,63,214,.12);
}
.gzmbot-input::placeholder { color: var(--gzm-gray-300); }
.gzmbot-input:disabled { opacity: .55; }

.gzmbot-send {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--gzm-purple-dark), var(--gzm-purple-mid));
  border: none; border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: transform .15s, box-shadow .15s;
  box-shadow: 0 3px 12px rgba(91,63,214,.35);
}
.gzmbot-send:hover  { transform: scale(1.07); box-shadow: 0 5px 16px rgba(91,63,214,.45); }
.gzmbot-send:active { transform: scale(.95); }
.gzmbot-send:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.gzmbot-send svg { width: 18px; height: 18px; margin-left: 1px; }

/* ── Footer ────────────────────────────────────────────────── */
.gzmbot-footer {
  text-align: center;
  font-size: 11px;
  color: var(--gzm-gray-300);
  padding: 7px 16px 11px;
  background: var(--gzm-white);
  flex-shrink: 0;
}
.gzmbot-footer a { color: var(--gzm-gray-500); text-decoration: none; }
.gzmbot-footer a:hover { color: var(--gzm-purple); text-decoration: underline; }

/* ── Inline (page-embedded) responsive ─────────────────────── */
@media (max-width: 640px) {
  .gzmbot-widget        { border-radius: var(--gzm-radius-md); }
  .gzmbot-chip          { flex-basis: 100%; }
  .gzmbot-msg-row       { max-width: 94%; }
  .gzmbot-timestamp--bot,
  .gzmbot-sources,
  .gzmbot-booking-cta,
  .gzmbot-suggestions   { margin-left: 0; }
}

/* ============================================================
   FLOATING LAUNCHER — fixed bottom-right, click to expand
   ============================================================

   position:fixed anchors to the VIEWPORT only when no ancestor
   has a CSS transform/filter/will-change (Elementor adds these
   constantly). The !important overrides on .gzmbot-float-root
   force it back to viewport-relative regardless of any ancestor.
   Loading at wp_enqueue_scripts priority 999 means this file
   comes AFTER theme/Elementor sheets, winning the cascade tie.
   ============================================================ */

.gzmbot-float-root {
  position: fixed !important;
  bottom: 24px !important;
  right: 24px !important;
  top:  auto !important;
  left: auto !important;
  z-index: 2147483000 !important;
  font-family: var(--gzm-font);
  transform: none !important;
  filter:    none !important;
  will-change: auto !important;
}

/* ── Bubble button ─────────────────────────────────────────── */
.gzmbot-float-bubble {
  width: 60px; height: 60px;
  border-radius: 50%; border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--gzm-purple-dark), var(--gzm-purple-mid));
  box-shadow: 0 6px 20px rgba(74,47,191,.38), 0 2px 6px rgba(74,47,191,.2);
  display: flex; align-items: center; justify-content: center;
  position: relative;
  color: #fff;
  transition: transform .22s cubic-bezier(.34,1.56,.64,1), box-shadow .22s;
}
.gzmbot-float-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 26px rgba(74,47,191,.46), 0 3px 8px rgba(74,47,191,.24);
}
.gzmbot-float-bubble:active { transform: scale(.96); }

.gzmbot-float-bubble-icon,
.gzmbot-float-bubble-close {
  position: absolute;
  display: flex;
  transition: opacity .18s, transform .24s cubic-bezier(.34,1.2,.64,1);
}
.gzmbot-float-bubble-icon  svg,
.gzmbot-float-bubble-close svg { width: 26px; height: 26px; }

.gzmbot-float-bubble-icon  { opacity: 1; transform: rotate(0deg) scale(1); }
.gzmbot-float-bubble-close { opacity: 0; transform: rotate(-90deg) scale(.5); }
.gzmbot-float-open .gzmbot-float-bubble-icon  { opacity: 0; transform: rotate(90deg) scale(.5); }
.gzmbot-float-open .gzmbot-float-bubble-close { opacity: 1; transform: rotate(0deg) scale(1); }

/* Attention pulse on first load */
.gzmbot-float-bubble::before {
  content: '';
  position: absolute; inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--gzm-purple-light);
  opacity: 0;
  animation: gzmFloatPulse 2.8s ease-out 1.2s infinite;
}
@keyframes gzmFloatPulse {
  0%   { transform: scale(1);    opacity: .55; }
  100% { transform: scale(1.48); opacity: 0; }
}
.gzmbot-float-open .gzmbot-float-bubble::before { animation: none; opacity: 0; }

/* ── Unread badge ──────────────────────────────────────────── */
.gzmbot-float-badge {
  position: absolute; top: -2px; right: -2px;
  width: 20px; height: 20px;
  background: var(--gzm-red); color: #fff;
  border-radius: 50%; font-size: 11px; font-weight: 800;
  display: none; align-items: center; justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.22);
  animation: gzmBadgePop .25s cubic-bezier(.34,1.56,.64,1);
}
@keyframes gzmBadgePop {
  from { transform: scale(0); }
  to   { transform: scale(1); }
}

/* ── Expanding panel ───────────────────────────────────────── */
.gzmbot-float-panel {
  position: absolute;
  bottom: 74px; right: 0;
  width: 380px;
  max-width: calc(100vw - 32px);
  /* Prevent the panel growing taller than the viewport minus bubble + gap */
  max-height: calc(100vh - 110px);
  overflow: hidden;
  opacity: 0;
  transform: translateY(14px) scale(.96);
  pointer-events: none;
  transform-origin: bottom right;
  transition: opacity .22s ease, transform .22s cubic-bezier(.34,1.2,.64,1);
}
.gzmbot-float-open .gzmbot-float-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.gzmbot-widget--floating {
  margin: 0;
  max-width: none;
  box-shadow: 0 16px 48px rgba(74,47,191,.24), 0 4px 14px rgba(74,47,191,.14);
  border-radius: 16px;
  /* Hard cap — header (~58px) + messages + typing + input (~74px) + footer (~36px)
     must all fit within this. Messages area fills whatever is left. */
  max-height: 580px;
  height: 580px;
  display: flex;
  flex-direction: column;
}
.gzmbot-widget--floating .gzmbot-messages {
  /* Let flex-grow fill the space between header and input, never exceed it.
     overflow-y: auto gives the scrollbar only when content exceeds the height. */
  flex: 1 1 auto;
  height: auto;         /* override any inline style set by the render() method */
  min-height: 0;        /* critical: without this, flex children don't shrink     */
  overflow-y: auto;
}

/* ── Mobile: full-screen takeover ─────────────────────────── */
@media (max-width: 600px) {
  .gzmbot-float-root   { bottom: 16px !important; right: 16px !important; }
  .gzmbot-float-bubble { width: 54px; height: 54px; }
  .gzmbot-float-bubble-icon svg,
  .gzmbot-float-bubble-close svg { width: 22px; height: 22px; }

  .gzmbot-float-panel {
    position: fixed;
    inset: 0; bottom: 0; right: 0;
    width: 100%; max-width: 100%;
    max-height: 100%;   /* reset the desktop cap for full-screen mobile */
    overflow: visible;
    transform: translateY(100%);
    border-radius: 0;
  }
  .gzmbot-float-open .gzmbot-float-panel { transform: translateY(0); }

  .gzmbot-widget--floating {
    height: 100%;
    border-radius: 0;
    border: none;
  }
  .gzmbot-widget--floating .gzmbot-messages {
    height: auto;
    flex: 1;
  }
}
