/* Smart ChatBot — Chat Widget v1.5
   Self-contained. Zero external dependencies. */

/* ── Variables ───────────────────────────────────────────────────────────────── */
:root {
  --shb-primary:       #1a6b3c;
  --shb-primary-light: #2d9056;
  --shb-primary-dark:  #0f4527;
  --shb-bg:            #ffffff;
  --shb-surface:       #f8faf9;
  --shb-border:        #e4ede9;
  --shb-text:          #1c2b22;
  --shb-text-muted:    #6b7c73;
  --shb-user-bg:       linear-gradient(135deg, var(--shb-primary) 0%, var(--shb-primary-light) 100%);
  --shb-user-text:     #ffffff;
  --shb-bot-bg:        #f1f5f2;
  --shb-shadow:        0 12px 48px rgba(26,107,60,0.18), 0 4px 12px rgba(0,0,0,0.08);
  --shb-radius:        18px;
  --shb-bubble-r:      14px;
  --shb-font:          -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --shb-z:             9999;
  --shb-w:             380px;
  --shb-h:             560px;
}

/* ── Root ────────────────────────────────────────────────────────────────────── */
#shb-root {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--shb-z);
  font-family: var(--shb-font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--shb-text);
  box-sizing: border-box;
}
#shb-root *, #shb-root *::before, #shb-root *::after { box-sizing: border-box; }

/* ── Bubble button ───────────────────────────────────────────────────────────── */
#shb-bubble {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--shb-primary) 0%, var(--shb-primary-light) 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 24px rgba(26,107,60,0.4), 0 2px 8px rgba(0,0,0,0.1);
  transition: transform .25s cubic-bezier(.34,1.56,.64,1), box-shadow .25s ease, background .2s;
  outline: none;
}
#shb-bubble:hover  { transform: scale(1.1); box-shadow: 0 8px 32px rgba(26,107,60,.5), 0 4px 12px rgba(0,0,0,.15); }
#shb-bubble:active { transform: scale(.92); }
#shb-bubble svg    { width: 28px; height: 28px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.15)); }
#shb-bubble::after {
  content: ''; position: absolute; inset: -5px; border-radius: 50%;
  border: 2px solid var(--shb-primary); opacity: 0;
  animation: shb-pulse 2.5s ease-out infinite; pointer-events: none;
}
@keyframes shb-pulse { 0% { opacity:.6; transform:scale(1); } 100% { opacity:0; transform:scale(1.5); } }

/* Badge */
#shb-badge {
  position: absolute; top: -2px; right: -2px; min-width: 18px; height: 18px;
  border-radius: 9px; background: #e53e3e; color: white;
  font-size: 11px; font-weight: 700; display: flex; align-items: center;
  justify-content: center; padding: 0 4px; border: 2px solid white;
  animation: shb-badge-pop .3s cubic-bezier(.34,1.56,.64,1);
}
@keyframes shb-badge-pop { from { transform:scale(0); } to { transform:scale(1); } }

/* Proactive tooltip */
.shb-proactive-tip {
  position: absolute; bottom: 68px; right: 0; white-space: nowrap;
  background: #1c2b22; color: white; font-size: 12px; padding: 7px 12px;
  border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,.2);
  animation: shb-fade-in .3s ease;
}
.shb-proactive-tip::after {
  content: ''; position: absolute; bottom: -6px; right: 18px;
  border: 6px solid transparent; border-top-color: #1c2b22; border-bottom: 0;
}
@keyframes shb-fade-in { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:none; } }

/* ── Chat window ─────────────────────────────────────────────────────────────── */
#shb-window {
  position: absolute; bottom: 70px; right: 0;
  width: var(--shb-w); max-width: calc(100vw - 32px);
  height: var(--shb-h); max-height: calc(100vh - 120px);
  background: var(--shb-bg); border-radius: var(--shb-radius);
  box-shadow: 0 12px 48px rgba(26,107,60,0.2), 0 4px 16px rgba(0,0,0,0.1);
  display: flex; flex-direction: column;
  overflow: hidden; border: 1px solid rgba(26,107,60,0.1);
  transform: scale(.85) translateY(20px); transform-origin: bottom right;
  opacity: 0; pointer-events: none;
  transition: transform .3s cubic-bezier(.34,1.4,.64,1), opacity .25s ease;
  backdrop-filter: blur(1px);
}
#shb-window.shb-window--open { transform: scale(1) translateY(0); opacity: 1; pointer-events: all; }

/* ── Header ──────────────────────────────────────────────────────────────────── */
#shb-header {
  display: flex; align-items: center; gap: 6px; padding: 12px 12px;
  background: linear-gradient(135deg, var(--shb-primary) 0%, var(--shb-primary-light) 50%, #34d399 100%);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
#shb-header::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at 80% 20%, rgba(255,255,255,0.1) 0%, transparent 50%);
  pointer-events: none;
}
.shb-header-avatar {
  width: 35px; height: 35px; border-radius: 50%;
  background: rgba(255,255,255,.15); display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.shb-header-info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.shb-header-title { font-weight: 700; font-size: 15px; color: white; letter-spacing: -.01em; }
.shb-header-status { font-size: 11px; color: rgba(255,255,255,.8); display: flex; align-items: center; gap: 5px; }
.shb-status-dot {
  width: 7px; height: 7px; border-radius: 50%; background: #4ade80;
  animation: shb-online 2s ease-in-out infinite;
}
@keyframes shb-online { 0%,100% { opacity:1; } 50% { opacity:.5; } }
#shb-minimize {
  background: rgba(255,255,255,.12); border: none; border-radius: 8px;
  width: 34px; height: 34px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .15s; flex-shrink: 0;
  color: white;          /* ensures currentColor on SVG strokes resolves correctly */
  padding: 0;            /* kill any browser-default button padding */
  line-height: 1;
}
#shb-minimize svg { display: block; pointer-events: none; }
#shb-minimize:hover { background: rgba(255,255,255,.28); }

/* ── Messages area ───────────────────────────────────────────────────────────── */
#shb-messages {
  flex: 1; overflow-y: auto; padding: 14px 12px 8px;
  display: flex; flex-direction: column; gap: 10px;
  scroll-behavior: smooth; background: var(--shb-surface);
  -webkit-overflow-scrolling: touch;
}
#shb-messages::-webkit-scrollbar { width: 4px; }
#shb-messages::-webkit-scrollbar-thumb { background: #c8d8ce; border-radius: 2px; }

/* ── Message rows ────────────────────────────────────────────────────────────── */
.shb-msg {
  display: flex; align-items: flex-end; gap: 8px; max-width: 100%;
  animation: shb-msg-in .28s cubic-bezier(.22,1,.36,1);
}
@keyframes shb-msg-in { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }
.shb-msg--user { justify-content: flex-end; }
.shb-msg--bot  { justify-content: flex-start; }

.shb-bot-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: white;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; box-shadow: 0 1px 4px rgba(0,0,0,.1); margin-bottom: 2px;
}

.shb-bubble {
  max-width: 98%; padding: 10px 12px;
  border-radius: var(--shb-bubble-r); font-size: 13.5px; line-height: 1.55;
  word-wrap: break-word; overflow-wrap: break-word;
}
.shb-bubble--user { background: linear-gradient(135deg, var(--shb-primary) 0%, var(--shb-primary-light) 100%); color: white; border-bottom-right-radius: 4px; margin-left: auto; box-shadow: 0 2px 8px rgba(26,107,60,0.2); }
.shb-bubble--bot  { background: var(--shb-bot-bg); color: var(--shb-text); border-bottom-left-radius: 4px; box-shadow: 0 1px 4px rgba(0,0,0,0.04); }

/* ── Answer block ────────────────────────────────────────────────────────────── */
.shb-answer-block { display: flex; flex-direction: column; gap: 7px; }
.shb-answer-label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--shb-primary); font-weight: 600; }
.shb-answer-text  { font-size: 13.5px; line-height: 1.65; color: var(--shb-text); }

/* Rich text inside answers */
.shb-num    { display: inline-block; font-weight: 700; color: var(--shb-primary); margin-right: 2px; }
.shb-bullet { color: var(--shb-primary); margin-right: 4px; }

/* Clickable links inside bot messages */
.shb-link,
.shb-bubble--bot a {
  color: var(--shb-primary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  word-break: break-all;
  font-weight: 500;
  transition: opacity 0.15s;
}
.shb-link:hover,
.shb-bubble--bot a:hover { opacity: 0.75; }

/* Fuzzy match label */
.shb-fuzzy-label {
  font-size: 12px; color: var(--shb-text-muted); margin-bottom: 6px;
  padding: 5px 8px; background: rgba(26,107,60,.06); border-radius: 6px;
  border-left: 2px solid var(--shb-primary);
}

/* ── Fallback block ──────────────────────────────────────────────────────────── */
.shb-fallback-block { display: flex; flex-direction: column; gap: 10px; }
.shb-fallback-msg { display: flex; align-items: flex-start; gap: 6px; font-size: 13px; color: var(--shb-text-muted); }
.shb-suggestions-label { font-size: 11.5px; font-weight: 700; color: var(--shb-text-muted); text-transform: uppercase; letter-spacing: .05em; }
.shb-suggestions-list  { display: flex; flex-direction: column; gap: 6px; }

.shb-suggestion-btn {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px;
  background: white; border: 1.5px solid var(--shb-border); border-radius: 10px;
  cursor: pointer; font-size: 12.5px; font-family: var(--shb-font); color: var(--shb-primary);
  text-align: left; line-height: 1.4; font-weight: 500;
  transition: background .15s, border-color .15s, transform .1s;
}
.shb-suggestion-btn:hover  { background: #f0faf4; border-color: var(--shb-primary-light); transform: translateX(2px); }
.shb-suggestion-btn:active { transform: scale(.98); }
.shb-suggestion-btn svg { flex-shrink: 0; opacity: .6; }

/* ── CTA ─────────────────────────────────────────────────────────────────────── */
.shb-cta {
  display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--shb-text-muted);
  padding: 8px 10px; background: rgba(26,107,60,.06); border-radius: 8px; border-left: 3px solid var(--shb-primary);
}
.shb-cta a { color: var(--shb-primary); text-decoration: none; font-weight: 700; transition: color .15s; }
.shb-cta a:hover { color: var(--shb-primary-light); text-decoration: underline; }

/* ── Feedback buttons ────────────────────────────────────────────────────────── */
.shb-feedback {
  display: flex; align-items: center; gap: 8px; margin-top: 10px; padding-top: 8px;
  border-top: 1px solid var(--shb-border);
}
.shb-fb-label  { font-size: 11.5px; color: var(--shb-text-muted); }
.shb-fb-btn {
  background: none; border: 1.5px solid var(--shb-border); border-radius: 6px;
  padding: 3px 8px; cursor: pointer; font-size: 14px; transition: background .15s, border-color .15s, transform .1s;
}
.shb-fb-btn:hover  { background: #f0faf4; border-color: var(--shb-primary-light); transform: scale(1.1); }
.shb-fb-btn:active { transform: scale(.95); }
.shb-fb-thanks { font-size: 12px; font-weight: 600; }
.shb-fb-up   { color: var(--shb-primary); }
.shb-fb-down { color: #e53e3e; }

/* ── Category grid (onboarding) ──────────────────────────────────────────────── */
.shb-category-row { width: 100%; }
.shb-category-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; padding: 4px 0;
}
.shb-cat-chip {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 10px 6px; background: #aaffb5; border: 1.5px solid var(--shb-border); border-radius: 10px;
  cursor: pointer; font-size: 12px; font-family: var(--shb-font); color: var(--shb-text); font-weight: 600;
  transition: background .15s, border-color .15s, transform .1s; text-align: center;
}
.shb-cat-chip:hover  { background: #f0faf4; border-color: var(--shb-primary); transform: translateY(-2px); }
.shb-cat-chip:active { transform: scale(.97); }
.shb-cat-chip span   { font-size: 11.5px; }

/* Category results heading */
.shb-category-heading { font-size: 13px; font-weight: 700; color: var(--shb-primary); margin-bottom: 10px; }
.shb-category-results { display: flex; flex-direction: column; gap: 4px; }

/* ── Chips bar ───────────────────────────────────────────────────────────────── */
#shb-chips-bar {
  display: flex; gap: 6px; padding: 8px 12px; overflow-x: auto;
  background: var(--shb-surface); border-top: 1px solid var(--shb-border);
  flex-shrink: 0; scrollbar-width: none;
  animation: shb-msg-in .2s ease;
}
#shb-chips-bar::-webkit-scrollbar { display: none; }

.shb-chip {
  flex-shrink: 0; padding: 6px 12px; background: white; border: 1.5px solid var(--shb-border);
  border-radius: 20px; cursor: pointer; font-size: 12px; font-family: var(--shb-font);
  color: var(--shb-primary); white-space: nowrap; font-weight: 500;
  transition: background .15s, border-color .15s, transform .1s;
  max-width: 200px; overflow: hidden; text-overflow: ellipsis;
}
.shb-chip:hover  { background: #f0faf4; border-color: var(--shb-primary-light); }
.shb-chip:active { transform: scale(.97); }

/* ── Typing indicator ────────────────────────────────────────────────────────── */
.shb-typing-bubble { display: flex; align-items: center; gap: 5px; padding: 12px 16px; }
.shb-typing-dot {
  width: 7px; height: 7px; border-radius: 50%; background: #aabfb3;
  animation: shb-typing 1.2s ease-in-out infinite;
}
.shb-typing-dot:nth-child(2) { animation-delay: .2s; }
.shb-typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes shb-typing { 0%,80%,100% { transform:translateY(0);opacity:.4; } 40% { transform:translateY(-6px);opacity:1; } }

/* ── Input area ──────────────────────────────────────────────────────────────── */
#shb-input-area {
  display: flex; align-items: flex-end; gap: 6px; padding: 10px 12px;
  background: var(--shb-bg); border-top: 1px solid var(--shb-border); flex-shrink: 0;
  margin-top: 6px;
}
#shb-input {
  /* font-size MUST stay >= 16px so iOS Safari doesn't auto-zoom the page on focus
     (the zoom was pushing the send button off the right edge of the panel).
     min-width: 0 lets the textarea shrink inside the flex row so it can never
     push the mic/send buttons past the panel's right edge. */
  flex: 1; min-width: 0; padding: 11px 16px; background: var(--shb-surface); border: 1.5px solid var(--shb-border);
  border-radius: 12px; font-size: 16px; font-family: var(--shb-font); color: var(--shb-text);
  resize: none; outline: none; line-height: 1.55; min-height: 44px; max-height: 120px;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
#shb-input:focus   { border-color: var(--shb-primary); box-shadow: 0 0 0 3px rgba(26,107,60,.08); background: white; }
#shb-input::placeholder { color: #9bb5a5; }

/* ── Voice input & voice output toggle buttons ──────────────────────────────── */
#shb-voice-in,
#shb-voice-out {
  flex-shrink: 0;
  width: 36px; height: 36px;
  padding: 0;                          /* remove all default button padding */
  border: 1.5px solid var(--shb-border);
  border-radius: 12px;
  background: var(--shb-surface);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; line-height: 1;
  transition: background .15s, border-color .15s, transform .1s;
  color: var(--shb-text);              /* override any theme colour */
}
#shb-voice-in:hover,
#shb-voice-out:hover  { background: #e8f5ee; border-color: var(--shb-primary); }
#shb-voice-in:active,
#shb-voice-out:active { transform: scale(.93); }
#shb-voice-in.shb-recording {
  background: #fee2e2; border-color: #ef4444; animation: shb-pulse-rec .8s ease-in-out infinite;
}
@keyframes shb-pulse-rec { 0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,.4); } 50% { box-shadow: 0 0 0 5px rgba(239,68,68,0); } }

/* Animated sound-wave bars shown inside the mic button while listening */
.shb-voice-wave {
  display: flex; align-items: center; justify-content: center; gap: 2px;
  height: 16px;
}
.shb-voice-wave i {
  display: block; width: 3px; height: 6px; border-radius: 2px;
  background: #ef4444;
  animation: shb-wave-bar .9s ease-in-out infinite;
}
.shb-voice-wave i:nth-child(1) { animation-delay: 0s;   }
.shb-voice-wave i:nth-child(2) { animation-delay: .18s; }
.shb-voice-wave i:nth-child(3) { animation-delay: .36s; }
.shb-voice-wave i:nth-child(4) { animation-delay: .54s; }
@keyframes shb-wave-bar {
  0%, 100% { height: 5px;  opacity: .65; }
  50%      { height: 15px; opacity: 1;   }
}
@media (prefers-reduced-motion: reduce) {
  .shb-voice-wave i { animation: none; height: 10px; }
  #shb-voice-in.shb-recording { animation: none; }
}

/* ── Send button ─────────────────────────────────────────────────────────────── */
#shb-send {
  flex-shrink: 0;
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, var(--shb-primary) 0%, var(--shb-primary-light) 100%);
  border: none; cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: white;
  padding: 0;
  box-shadow: 0 3px 12px rgba(26,107,60,0.25);
  transition: background .15s, transform .15s, box-shadow .15s;
}
#shb-send svg { display: block; pointer-events: none; }
#shb-send:hover:not(:disabled)  { transform: scale(1.08); box-shadow: 0 4px 16px rgba(26,107,60,0.35); }
#shb-send:disabled               { background: #c8d8ce; cursor: not-allowed; box-shadow: none; }
#shb-send:active:not(:disabled)  { transform: scale(.92); }

/* ── Guided Flow options ─────────────────────────────────────────────────────── */
.shb-flow-message {
  font-size: 13.5px; line-height: 1.55; color: var(--shb-text);
  margin-bottom: 10px; font-weight: 500;
}
.shb-flow-options {
  display: flex; flex-direction: column; gap: 7px;
  margin-top: 6px;
}
.shb-flow-opt {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 10px 14px;
  background: white; border: 1.5px solid var(--shb-border);
  border-radius: 10px; cursor: pointer;
  font-size: 13.5px; font-family: var(--shb-font); color: var(--shb-text);
  font-weight: 500; text-align: left; line-height: 1.4;
  transition: border-color .15s, background .15s, transform .1s, box-shadow .15s;
}
.shb-flow-opt:hover  {
  border-color: var(--shb-primary); background: #f0faf4;
  box-shadow: 0 2px 8px rgba(26,107,60,.12); transform: translateX(2px);
}
.shb-flow-opt:active { transform: scale(.98); }
.shb-flow-opt--selected {
  border-color: var(--shb-primary); background: #e8f5ee;
  color: var(--shb-primary); font-weight: 600;
}
.shb-flow-opt:disabled { cursor: default; }
.shb-flow-arrow { color: var(--shb-primary); font-size: 16px; font-weight: 700; margin-left: 6px; }

/* ── Footer ──────────────────────────────────────────────────────────────────── */
#shb-footer {
  text-align: center; font-size: 10.5px; color: #b0c4ba; padding: 5px;
  background: var(--shb-bg); flex-shrink: 0; letter-spacing: .02em;
}

/* ── Related posts ───────────────────────────────────────────────────────────── */
.shb-posts-block { display: flex; flex-direction: column; gap: 6px; width: 100%; }

/* Toggle button */
.shb-posts-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  background: white;
  border: 1.5px solid var(--shb-primary);
  border-radius: 20px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  font-family: var(--shb-font);
  color: var(--shb-primary);
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
  align-self: flex-start;
}
.shb-posts-toggle:hover  { background: #f0faf4; box-shadow: 0 2px 8px rgba(26,107,60,.15); }
.shb-posts-toggle:active { transform: scale(0.97); }
.shb-posts-toggle svg    { flex-shrink: 0; }
.shb-posts-chevron       { transition: transform 0.2s ease; margin-left: 2px; }

/* Hidden / visible post list */
.shb-posts-list { display: flex; flex-direction: column; gap: 6px; }
.shb-posts-list--hidden { display: none; }

.shb-post-card {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  background: white; border: 1.5px solid var(--shb-border); border-radius: 10px;
  text-decoration: none !important; color: var(--shb-text);
  transition: border-color .15s, box-shadow .15s, transform .1s; min-width: 0;
  animation: shb-msg-in 0.2s ease;
}
.shb-post-card:hover { border-color: var(--shb-primary); box-shadow: 0 2px 10px rgba(26,107,60,.12); transform: translateY(-1px); }
.shb-post-card:active { transform: scale(.99); }
.shb-post-thumb { width: 44px; height: 44px; border-radius: 7px; object-fit: cover; flex-shrink: 0; }
.shb-post-thumb--placeholder {
  width: 44px; height: 44px; border-radius: 7px; background: var(--shb-surface);
  border: 1px solid var(--shb-border); display: flex; align-items: center; justify-content: center;
  color: #c8d8ce; flex-shrink: 0;
}
.shb-post-info    { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.shb-post-title   { font-size: 12.5px; font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.shb-post-excerpt { font-size: 11.5px; color: var(--shb-text-muted); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.shb-post-arrow   { color: var(--shb-primary); flex-shrink: 0; opacity: .5; transition: opacity .15s, transform .15s; }
.shb-post-card:hover .shb-post-arrow { opacity: 1; transform: translateX(2px); }

/* ── Restored history label ──────────────────────────────────────────────────── */
.shb-restored-label { display: block; font-size: 10px; color: #b0c4ba; margin-top: 4px; font-style: italic; }

/* ── Tablet ───────────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  :root { --shb-w: 340px; --shb-h: 500px; }
  #shb-root { bottom: 16px; right: 16px; left: auto !important; }
  #shb-window { right: 0; bottom: 68px; width: calc(100vw - 32px); max-width: 100%; }
}

/* ── Mobile full-screen ──────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #shb-root { bottom: 0; right: 0; left: auto; width: auto; }
  #shb-bubble { position: fixed; bottom: 18px; right: 18px; left: auto !important; width: 54px; height: 54px; z-index: calc(var(--shb-z) + 2); }
  #shb-window {
    position: fixed; bottom: 0; left: 0; right: 0; top: 0;
    width: 100%; max-width: 100%; height: 100%; max-height: 100%;
    border-radius: 0; transform-origin: bottom center;
    transform: translateY(100%);
    transition: transform .35s cubic-bezier(.22,1,.36,1), opacity .25s ease;
  }
  #shb-window.shb-window--open { transform: translateY(0); opacity: 1; }
  #shb-header { padding: max(16px, env(safe-area-inset-top)) 16px 16px; }
  #shb-input  { font-size: 16px; padding: 12px 16px; min-height: 48px; }
  #shb-input-area { padding: 8px 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  #shb-footer { padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  #shb-send        { width: 46px; height: 46px; }
  #shb-voice-in,
  #shb-voice-out   { width: 40px; height: 40px; font-size: 17px; }
  .shb-bubble { font-size: 14px; padding: 11px 14px; }
  .shb-suggestion-btn:hover { transform: none; }
  .shb-category-grid { grid-template-columns: repeat(3,1fr); gap: 6px; }
  .shb-cat-chip { padding: 9px 4px; font-size: 11px; }
}
@media (max-width: 360px) {
  #shb-bubble { width: 50px; height: 50px; bottom: 14px; right: 14px; left: auto !important; }
  .shb-category-grid { grid-template-columns: repeat(2,1fr); }
}

/* ── Language toggle button ──────────────────────────────────────────────────── */
.shb-lang-btn {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 6px;
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 6px 6px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
  font-family: inherit;
  letter-spacing: 0.02em;
}
.shb-lang-btn:hover  { background: rgba(255,255,255,0.25); }
.shb-lang-btn:active { transform: scale(0.95); }

/* ── Exit Satisfaction Survey ────────────────────────────────────────────────── */
#shb-survey {
  position: absolute;
  bottom: 70px;
  right: 0;
  z-index: calc(var(--shb-z) + 1);
  width: 280px;
  animation: shb-survey-in 0.3s cubic-bezier(0.34,1.4,0.64,1);
}

@keyframes shb-survey-in {
  from { opacity: 0; transform: translateY(16px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.shb-survey-card {
  background: white;
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(26,107,60,0.18), 0 2px 8px rgba(0,0,0,0.1);
  padding: 18px 16px 16px;
  border: 1px solid var(--shb-border);
  position: relative;
}

.shb-survey-close {
  position: absolute;
  top: 10px; right: 10px;
  background: none; border: none;
  cursor: pointer; font-size: 14px;
  color: var(--shb-text-muted);
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.shb-survey-close:hover { background: var(--shb-surface); }

.shb-survey-q {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--shb-text);
  line-height: 1.4;
  margin-bottom: 14px;
  padding-right: 18px;
}

.shb-survey-btns {
  display: flex;
  gap: 6px;
}

.shb-survey-btn {
  flex: 1;
  padding: 8px 4px;
  border-radius: 8px;
  border: 1.5px solid var(--shb-border);
  background: var(--shb-surface);
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  font-weight: 600;
  color: var(--shb-text);
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  text-align: center;
}
.shb-survey-btn:hover  { background: #f0faf4; border-color: var(--shb-primary); }
.shb-survey-btn:active { transform: scale(0.96); }
.shb-survey-yes:hover  { border-color: #16a34a; color: #16a34a; }
.shb-survey-no:hover   { border-color: #dc2626; color: #dc2626; }

.shb-survey-thanks {
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--shb-primary);
  padding: 12px 0;
}

/* Mobile: survey full width */
@media (max-width: 480px) {
  #shb-survey { width: calc(100vw - 32px); bottom: 80px; right: 16px; }
}

/* ── Welcome Screen ───────────────────────────────────────────────────────────── */
#shb-welcome-screen {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  position: relative;
}
.shb-welcome-bg {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: linear-gradient(145deg, var(--shb-primary) 0%, color-mix(in srgb, var(--shb-primary) 70%, #000) 100%);
  border-radius: 0;
  padding: 28px 24px 20px;
  position: relative;
  overflow: hidden;
}
.shb-welcome-bg::before {
  content: '';
  position: absolute;
  top: -40%;
  right: -30%;
  width: 80%;
  height: 80%;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
}
.shb-welcome-bg::after {
  content: '';
  position: absolute;
  bottom: -20%;
  left: -20%;
  width: 60%;
  height: 60%;
  border-radius: 50%;
  background: rgba(255,255,255,0.04);
}
.shb-welcome-logo {
  position: relative;
  z-index: 1;
  margin-bottom: 20px;
}
.shb-welcome-logo-img {
  max-width: 80px;
  max-height: 50px;
  object-fit: contain;
  border-radius: 8px;
}
.shb-welcome-content {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 28px 22px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.12);
}
.shb-welcome-title {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  margin: 0 0 10px;
  line-height: 1.3;
}
.shb-welcome-sub {
  font-size: 14px;
  color: rgba(255,255,255,0.8);
  margin: 0;
  line-height: 1.5;
}
.shb-welcome-start-wrap {
  position: relative;
  z-index: 1;
  margin-top: 20px;
}
.shb-welcome-start-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 18px;
  background: #fff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  transition: box-shadow 0.2s, transform 0.15s;
}
.shb-welcome-start-btn:hover {
  box-shadow: 0 6px 24px rgba(0,0,0,0.18);
  transform: translateY(-1px);
}
.shb-welcome-start-btn:active { transform: scale(0.98); }
.shb-welcome-start-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--shb-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.shb-welcome-start-text {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.shb-welcome-start-text strong {
  font-size: 14px;
  font-weight: 700;
  color: #111827;
}
.shb-welcome-start-text small {
  font-size: 11px;
  color: #6b7280;
  font-weight: 400;
}

/* ── Chat Main Container ──────────────────────────────────────────────────────── */
#shb-chat-main {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  position: relative;
  overflow: hidden;
  border-radius: inherit;
}

/* ── Email Capture Popup (centered overlay inside panel) ──────────────────────── */
#shb-email-popup {
  position: absolute;
  inset: 0;
  z-index: calc(var(--shb-z) + 2);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
  border-radius: inherit;
}

#shb-email-popup.shb-email-popup--visible {
  opacity: 1;
  pointer-events: auto;
  backdrop-filter: blur(5px);
}

.shb-email-popup-card {
  background: rgba(255, 255, 225, 0.85);
  border-radius: 16px;
  padding: 20px 20px;
  width:fit-content;
  width: 90%;
  max-width: 95%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  position: relative;
  animation: scbEmailIn 0.25s ease;
}
@keyframes scbEmailIn { from { opacity:0; transform:scale(0.95); } to { opacity:1; transform:scale(1); } }

.shb-email-popup-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: #9ca3af;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.shb-email-popup-close:hover { background: #f3f4f6; color: #374151; }

.shb-email-popup-title {
  font-size: 15px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 5px;
  padding-right: 24px;
  line-height: 1.35;
}

.shb-email-popup-sub {
  font-size: 12.5px;
  color: #6b7280;
  margin-bottom: 14px;
  line-height: 1.4;
}

.shb-email-popup-input {
  width: 100%;
  box-sizing: border-box;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13.5px;
  color: #111827;
  background: #f9fafb;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  margin-bottom: 4px;
}
.shb-email-popup-input:focus {
  border-color: var(--shb-primary);
  box-shadow: 0 0 0 3px rgba(26,107,60,0.1);
  background: #fff;
}
.shb-email-popup-input::placeholder { color: #b0b7c3; }

.shb-email-popup-error {
  font-size: 11.5px;
  color: #dc2626;
  margin-bottom: 6px;
  padding-left: 2px;
}

.shb-email-popup-submit {
  width: 100%;
  margin-top: 10px;
  padding: 10px 0;
  background: var(--shb-primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
}
.shb-email-popup-submit:hover  { opacity: 0.9; }
.shb-email-popup-submit:active { transform: scale(0.98); }

@media (max-width: 480px) {
  #shb-email-popup { width: 100%; }
  .shb-email-popup-card { width: 260px; }
}



/* ── WhatsApp Escalation Card ────────────────────────────────────────────────── */
.shb-wa-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border: 1.5px solid #86efac;
  border-radius: 12px;
  animation: shb-msg-in 0.3s ease;
}

.shb-wa-card--no-link {
  background: var(--shb-surface);
  border-color: var(--shb-border);
}

.shb-wa-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #25D366;
  box-shadow: 0 3px 12px rgba(37,211,102,0.35);
  flex-shrink: 0;
  align-self: flex-start;
}

.shb-wa-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.shb-wa-heading {
  font-size: 13.5px;
  font-weight: 700;
  color: #14532d;
  line-height: 1.4;
}

.shb-wa-subtext {
  font-size: 12.5px;
  color: #166534;
  line-height: 1.5;
  opacity: 0.85;
}

.shb-wa-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  background: #25D366;
  color: white !important;
  font-size: 13.5px;
  font-weight: 700;
  font-family: var(--shb-font);
  text-decoration: none !important;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  box-shadow: 0 3px 14px rgba(37,211,102,0.4);
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  letter-spacing: 0.01em;
}

.shb-wa-btn:hover {
  background: #1db954;
  transform: translateY(-1px);
  box-shadow: 0 5px 18px rgba(37,211,102,0.5);
}

.shb-wa-btn:active {
  transform: scale(0.97);
}

/* ── Mobile WhatsApp ─────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .shb-wa-card  { padding: 12px; gap: 8px; }
  .shb-wa-btn   { padding: 12px 14px; font-size: 14px; }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Contact Form — in-chatbot mini form
   ─────────────────────────────────────────────────────────────────────────── */

/* Header button to open the form */
.shb-cf-header-btn {
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 6px;
  color: #fff;
  font-size: 11px;
  padding: 4px 6px;
  cursor: pointer;
  margin-right: 2px;
  line-height: 1.4;
  white-space: nowrap;
  transition: background 0.15s;
  font-family: var(--shb-font);
}
.shb-cf-header-btn:hover { background: rgba(255,255,255,0.30); }

/* Card wrapper — sits inside a bot message bubble */
.shb-cf-card {
  font-size: 12px;
  line-height: 1.5;
  padding: 0;
}

.shb-cf-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--shb-primary, #1a6b3c);
  margin-bottom: 3px;
}

.shb-cf-desc {
  font-size: 11.5px;
  color: #666;
  margin: 0 0 10px;
  line-height: 1.4;
}

/* Fields wrapper */
.shb-cf-fields {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 10px;
}

.shb-cf-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.shb-cf-label {
  font-size: 11px;
  font-weight: 600;
  color: #444;
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: wrap;
}

.shb-cf-req {
  color: #d0342c;
  font-size: 11px;
}

.shb-cf-math-q {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--shb-primary, #1a6b3c);
  background: rgba(26,107,60,0.08);
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: 2px;
}

/* Input / textarea */
.shb-cf-input {
  font-size: 12px;
  font-family: var(--shb-font);
  padding: 5px 8px;
  border: 1px solid #d4d4d4;
  border-radius: 6px;
  background: #fff;
  color: #222;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
  box-sizing: border-box;
  -webkit-appearance: none;
}
.shb-cf-input:focus {
  border-color: var(--shb-primary, #1a6b3c);
  box-shadow: 0 0 0 2px rgba(26,107,60,0.12);
}

.shb-cf-textarea {
  resize: vertical;
  min-height: 52px;
  line-height: 1.4;
}

/* Error message */
.shb-cf-error {
  font-size: 11.5px;
  color: #c0392b;
  background: #fdecea;
  border: 1px solid #f5c6c3;
  border-radius: 5px;
  padding: 5px 8px;
  margin-bottom: 8px;
  line-height: 1.4;
}

/* Submit button */
.shb-cf-submit {
  width: 100%;
  background: var(--shb-primary, #1a6b3c);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 8px 12px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: var(--shb-font);
  cursor: pointer;
  letter-spacing: 0.01em;
  transition: background 0.15s, transform 0.1s;
}
.shb-cf-submit:hover:not(:disabled)  { filter: brightness(1.08); }
.shb-cf-submit:active:not(:disabled) { transform: scale(0.98); }
.shb-cf-submit:disabled              { opacity: 0.6; cursor: not-allowed; }

/* Success state */
.shb-cf-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 0 4px;
  text-align: center;
}
.shb-cf-success-icon { font-size: 26px; }
.shb-cf-success-msg  { font-size: 12.5px; color: #2d6a2d; font-weight: 600; line-height: 1.4; }

/* ── Category Action Buttons ─────────────────────────────────────────────────── */
.shb-cat-action-btns {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px;
  padding-top: 10px; border-top: 1px dashed var(--shb-border);
}
.shb-cat-action-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 8px 14px; background: var(--shb-primary); color: white;
  border: none; border-radius: 8px; cursor: pointer;
  font-size: 12.5px; font-weight: 600; font-family: var(--shb-font);
  box-shadow: 0 2px 6px rgba(26,107,60,0.2);
  transition: background .15s, transform .1s, box-shadow .15s;
}
.shb-cat-action-btn:hover { background: var(--shb-primary-light); transform: scale(1.02); box-shadow: 0 3px 10px rgba(26,107,60,0.25); }
.shb-cat-action-btn:active { transform: scale(0.97); }

/* ── Discount / offers handoff card ──────────────────────────────────────────── */
.shb-discount-card {
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px 15px; border-radius: 12px;
  background: linear-gradient(135deg, #fdf2f8 0%, #fef6f0 100%);
  border: 1px solid #f6d6e5;
}
.shb-discount-card .shb-dc-msg {
  font-size: 13.5px; line-height: 1.6; color: var(--shb-text);
}
.shb-discount-card .shb-dc-actions {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.shb-dc-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 15px; border: none; border-radius: 8px;
  color: #fff; text-decoration: none; cursor: pointer;
  font-size: 13px; font-weight: 600; font-family: var(--shb-font);
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
  transition: filter .15s, transform .1s;
}
.shb-dc-btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.shb-dc-btn:active { transform: translateY(0); }
.shb-dc-btn.wa   { background: #25d366; }
.shb-dc-btn.call { background: var(--shb-primary); }

/* ── Main Menu Button ────────────────────────────────────────────────────────── */
.shb-main-menu-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; background: white; border: 1.5px solid var(--shb-primary);
  border-radius: 20px; cursor: pointer; font-size: 13px; font-weight: 600;
  font-family: var(--shb-font); color: var(--shb-primary);
  transition: background .15s, transform .1s, box-shadow .15s;
}
.shb-main-menu-btn:hover { background: #f0faf4; box-shadow: 0 2px 8px rgba(26,107,60,0.15); transform: translateY(-1px); }
.shb-main-menu-btn:active { transform: scale(0.97); }

/* ── Live Agent Offer Card ───────────────────────────────────────────────────── */
.shb-live-offer {
  display: flex; flex-direction: column; gap: 8px; padding: 12px;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border: 1.5px solid #93c5fd; border-radius: 12px;
}
.shb-live-offer-text { font-size: 13px; color: #1e40af; line-height: 1.5; font-weight: 500; }
.shb-live-offer-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; background: #2563eb; color: white; border: none;
  border-radius: 8px; font-size: 13px; font-weight: 600; font-family: var(--shb-font);
  cursor: pointer; transition: background .15s, transform .1s;
}
.shb-live-offer-btn:hover { background: #1d4ed8; transform: scale(1.02); }
.shb-live-offer-btn:active { transform: scale(0.97); }
.shb-live-offer-btn:disabled { background: #93c5fd; cursor: not-allowed; }

/* Mobile tweaks.
   Every focusable field must be >= 16px on touch devices: iOS Safari auto-zooms
   the page when a smaller field receives focus, which widens the full-screen
   chat panel and pushes the send button off the right edge. */
@media (max-width: 480px) {
  .shb-cf-title        { font-size: 12.5px; }
  .shb-cf-input        { font-size: 16px; padding: 8px 10px; }
  .shb-cf-submit       { font-size: 14px; padding: 9px 14px; }
}
@media (max-width: 600px) {
  #shb-window input,
  #shb-window textarea,
  #shb-window select { font-size: 16px !important; }
}

