/* =========================================================
   Dr. Siha — roaming robot doctor + support chat
   .sb is a click-through overlay; only the robot, bubble and
   panel receive pointer events.
   ========================================================= */
.sb { --sb-teal: var(--brand-700, #0a6672); --sb-w: 76px; --sb-h: 89px; position: fixed; inset: 0; z-index: 70; pointer-events: none; font-family: var(--font-body, system-ui, sans-serif); }

/* ---------- the flying robot ---------- */
.sb-mover { position: absolute; top: 0; left: 0; width: var(--sb-w); height: var(--sb-h); will-change: transform; transform: translate3d(calc(100vw - var(--sb-w) - 22px), calc(100vh - var(--sb-h) - 96px), 0); }
.sb-launch { pointer-events: auto; position: relative; display: block; width: 100%; height: 100%; padding: 0; border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.sb-launch:focus-visible { outline: 3px solid var(--brand-500, #1495a3); outline-offset: 4px; border-radius: 20px; }
.sb-tilt { display: block; width: 100%; height: 100%; transform: rotate(var(--bank, 0deg)); transition: transform .25s ease-out; }
.sb-robot { width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 10px 14px rgba(5,47,53,.3)); }
.sb-float { animation: sb-bob 3.2s ease-in-out infinite; }
.sb-shadow { transform-box: fill-box; transform-origin: center; animation: sb-shadow 3.2s ease-in-out infinite; }
.sb-eyes { transition: transform .25s ease-out; }
.sb-eye { transform-box: fill-box; transform-origin: center; animation: sb-blink 5s infinite; }
.sb-antenna { animation: sb-pulse 2s ease-in-out infinite; }
.sb-arm--r { transform-box: fill-box; transform-origin: 50% 8%; transition: transform .4s var(--ease, ease); }
.sb.is-waving .sb-arm--r { animation: sb-wave 1.1s ease-in-out 2; }
.sb-launch:hover .sb-arm--r { animation: sb-wave 1.1s ease-in-out infinite; }
.sb-launch:hover .sb-mouth { d: path("M51 63q9 8 18 0"); }
/* tiny jet flame while flying */
.sb-jet { position: absolute; left: 50%; bottom: -4px; width: 14px; height: 18px; margin-left: -7px; border-radius: 50% 50% 50% 50% / 30% 30% 70% 70%; background: radial-gradient(ellipse at 50% 20%, #fff 0 18%, #7fe0e4 40%, rgba(20,149,163,0) 72%); opacity: 0; transform: scaleY(.4); transform-origin: 50% 0; transition: opacity .25s, transform .25s; pointer-events: none; }
.sb.is-flying .sb-jet { opacity: .95; transform: scaleY(1); animation: sb-jet .12s linear infinite alternate; }
.sb.is-flying .sb-shadow { opacity: 0; animation: none; }
.sb-ring { position: absolute; left: 50%; top: 46%; width: 70px; height: 70px; margin: -35px 0 0 -35px; border-radius: 50%; background: radial-gradient(circle, rgba(127,224,228,.35), transparent 65%); animation: sb-ring 2.6s ease-out infinite; pointer-events: none; z-index: -1; }
.sb.is-open .sb-ring, .sb.is-flying .sb-ring { display: none; }

@keyframes sb-bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes sb-shadow { 0%,100% { transform: scaleX(1); opacity: .18; } 50% { transform: scaleX(.78); opacity: .1; } }
@keyframes sb-blink { 0%,92%,100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes sb-pulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }
@keyframes sb-wave { 0%,100% { transform: rotate(0deg); } 25% { transform: rotate(-150deg); } 50% { transform: rotate(-120deg); } 75% { transform: rotate(-155deg); } }
@keyframes sb-ring { 0% { transform: scale(.7); opacity: .9; } 100% { transform: scale(1.35); opacity: 0; } }
@keyframes sb-jet { from { transform: scaleY(.85); } to { transform: scaleY(1.15); } }

/* ---------- speech bubble (flips to whichever side has room) ---------- */
.sb-tip { position: absolute; right: calc(100% + 6px); top: 4px; width: max-content; max-width: min(230px, 62vw); padding: 10px 30px 10px 13px; border-radius: 16px 16px 4px 16px; background: #fff; color: var(--ink, #0f2227); font: 500 .85rem/1.4 var(--font-body, system-ui); box-shadow: 0 16px 36px -14px rgba(5,47,53,.45); border: 1px solid var(--line, #e2ecec); opacity: 0; transform: translateX(8px) scale(.94); transform-origin: 100% 50%; pointer-events: none; transition: opacity .3s, transform .35s var(--ease, ease); cursor: pointer; }
.sb.is-flip .sb-tip { right: auto; left: calc(100% + 6px); border-radius: 16px 16px 16px 4px; transform: translateX(-8px) scale(.94); transform-origin: 0 50%; }
.sb-tip.is-on, .sb.is-flip .sb-tip.is-on { opacity: 1; transform: none; pointer-events: auto; }
.sb-tip__x { position: absolute; top: 6px; right: 6px; width: 20px; height: 20px; border: 0; border-radius: 50%; background: var(--brand-50, #eef7f6); color: var(--sb-teal); font: 700 13px/1 system-ui; cursor: pointer; }

/* ---------- chat panel ---------- */
.sb-panel { pointer-events: none; position: absolute; right: 20px; bottom: 96px; width: min(380px, calc(100vw - 32px)); height: min(540px, calc(100vh - 230px)); display: flex; flex-direction: column; background: #fff; border-radius: 22px; overflow: hidden; box-shadow: 0 30px 70px -20px rgba(5,47,53,.45); border: 1px solid var(--line, #e2ecec); opacity: 0; visibility: hidden; transform: translateY(16px) scale(.97); transform-origin: 100% 100%; transition: opacity .25s, transform .3s var(--ease, ease), visibility 0s .3s; }
.sb.is-open .sb-panel { pointer-events: auto; opacity: 1; visibility: visible; transform: none; transition: opacity .25s, transform .3s var(--ease, ease); }
.sb-head { display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 16px; background: linear-gradient(120deg, var(--brand-700, #0a6672), var(--brand-900, #052f35)); color: #fff; }
.sb-head__avatar { width: 42px; height: 42px; flex-shrink: 0; border-radius: 14px; background: rgba(255,255,255,.12); display: grid; place-items: center; }
.sb-head__avatar svg { width: 34px; height: 34px; }
.sb-head__txt { flex: 1; min-width: 0; }
.sb-head__txt strong { display: block; font: 700 1rem/1.2 var(--font-head, system-ui); }
.sb-head__txt span { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; color: #b9dfe1; }
.sb-head__txt span::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #3ee08f; box-shadow: 0 0 0 3px rgba(62,224,143,.25); }
.sb-icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 10px; background: rgba(255,255,255,.12); color: #fff; cursor: pointer; transition: background .2s; }
.sb-icon-btn:hover { background: rgba(255,255,255,.22); }
.sb-icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.sb-log { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 16px 14px 8px; background: var(--brand-50, #eef7f6); display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; }
.sb-msg { max-width: 86%; padding: 10px 13px; border-radius: 16px; font-size: .9rem; line-height: 1.5; word-wrap: break-word; animation: sb-in .3s var(--ease, ease); }
.sb-msg--bot { align-self: flex-start; background: #fff; color: var(--ink, #0f2227); border-bottom-left-radius: 5px; box-shadow: 0 2px 6px -3px rgba(5,47,53,.2); }
.sb-msg--user { align-self: flex-end; background: var(--brand-700, #0a6672); color: #fff; border-bottom-right-radius: 5px; }
.sb-msg a { color: var(--brand-600, #0d7a87); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.sb-msg--user a { color: #fff; }
.sb-msg ul { margin: 4px 0; padding-left: 18px; }
.sb-msg p { margin: 0 0 6px; } .sb-msg p:last-child { margin: 0; }
.sb-typing { display: inline-flex; gap: 4px; padding: 14px 16px; }
.sb-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--brand-500, #1495a3); animation: sb-dot 1.2s infinite; }
.sb-typing i:nth-child(2) { animation-delay: .15s; } .sb-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes sb-dot { 0%,60%,100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-5px); opacity: 1; } }
@keyframes sb-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.sb-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 14px 10px; background: var(--brand-50, #eef7f6); }
.sb-chip { padding: 7px 12px; border-radius: 999px; border: 1px solid rgba(10,102,114,.25); background: #fff; color: var(--brand-700, #0a6672); font: 600 .78rem/1 var(--font-head, system-ui); cursor: pointer; transition: background .2s, color .2s; }
.sb-chip:hover { background: var(--brand-700, #0a6672); color: #fff; }

.sb-form { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line, #e2ecec); background: #fff; }
.sb-form textarea { flex: 1; resize: none; overflow-y: hidden; height: 42px; max-height: 110px; padding: 10px 12px; border: 1px solid var(--line, #e2ecec); border-radius: 12px; font: 400 .92rem/1.4 var(--font-body, system-ui); color: var(--ink, #0f2227); background: var(--brand-50, #eef7f6); outline: none; }
.sb-form textarea:focus { border-color: var(--brand-500, #1495a3); background: #fff; }
.sb-send { width: 42px; height: 42px; flex-shrink: 0; display: grid; place-items: center; border: 0; border-radius: 12px; background: var(--brand-700, #0a6672); color: #fff; cursor: pointer; transition: background .2s, transform .2s; }
.sb-send:hover { background: var(--brand-600, #0d7a87); }
.sb-send:disabled { opacity: .5; cursor: default; }
.sb-send svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.sb-foot { padding: 0 14px 10px; background: #fff; font-size: .75rem; line-height: 1.4; color: #6b8285; text-align: center; }
.sb-foot a { color: #c0392b; font-weight: 600; }

/* ---------- mobile ---------- */
@media (max-width: 600px) {
  .sb { --sb-w: 58px; --sb-h: 68px; }
  .sb-tip { top: 0; max-width: min(200px, 58vw); font-size: .8rem; padding-right: 38px; }
  .sb-tip__x { width: 30px; height: 30px; top: 2px; right: 2px; }
  .sb.is-open { pointer-events: auto; background: rgba(5,47,53,.45); }
  .sb.is-open .sb-mover { display: none; }
  .sb-panel { inset: auto 0 0 0; width: 100%; height: 88dvh; border-radius: 22px 22px 0 0; }
}
@media (prefers-reduced-motion: reduce) {
  .sb-float, .sb-shadow, .sb-eye, .sb-antenna, .sb-ring, .sb.is-waving .sb-arm--r, .sb-launch:hover .sb-arm--r { animation: none; }
}
/* keep out of the way while the mobile menu is open */
body:has(.nav.is-open) .sb { display: none; }
