:root{
  --ai-navy:#10182b;
  --ai-blue:#075fc4;
  --ai-teal:#0b7f88;
  --ai-gold:#c59631;
  --ai-soft:#f5f9fd;
  --ai-line:#d9e5ef;
  --ai-muted:#59657a;
}

.ai-assistant-shell,
.ai-assistant-shell *{
  box-sizing:border-box;
}

.ai-assistant-launcher{
  position:fixed;right:88px;bottom:22px;z-index:950;display:inline-flex;align-items:center;gap:10px;
  padding:13px 18px;border:1px solid rgba(197,150,49,.34);border-radius:999px;background:#fffdf8;color:var(--ai-navy);
  box-shadow:0 16px 38px rgba(18,22,38,.16);font:800 .9rem/1 "DM Sans",Inter,sans-serif;cursor:pointer
}
/* Glittering gradient border, the industry pattern for flagging "this is
   the AI feature" (Gemini, Notion AI, etc.). First attempt used a rotated
   conic-gradient, which looks right on a circle but on a wide, short pill
   reads as a bar sweeping across rather than a ring hugging the border -
   a rigid shape spinning behind an oblong mask doesn't trace the outline
   evenly. This version instead scrolls a linear gradient's *position*
   (not a rotating rigid layer) and uses mask-composite to cut out the
   inner content-box, leaving only a thin flowing ring that follows the
   pill's actual outline regardless of its aspect ratio - the standard
   technique for an animated gradient border on non-circular shapes.
   Brand colors (gold/blue/teal), not an arbitrary rainbow. */
.ai-assistant-launcher::before{
  content:"";position:absolute;inset:-3px;border-radius:inherit;padding:3px;
  background:linear-gradient(90deg,var(--ai-gold),var(--ai-blue),var(--ai-teal),var(--ai-gold),var(--ai-gold));
  background-size:300% 100%;
  -webkit-mask:linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0);
  -webkit-mask-composite:xor;mask-composite:exclude;
  animation:ai-border-flow 3.2s linear infinite
}
@keyframes ai-border-flow{to{background-position:300% 0}}
.ai-assistant-launcher:hover{transform:translateY(-1px);box-shadow:0 20px 44px rgba(18,22,38,.20)}
.ai-assistant-launcher:focus-visible{outline:2px solid #317fc4;outline-offset:3px}
.ai-assistant-launcher .ai-spark{width:29px;height:29px;border-radius:50%;display:grid;place-items:center;background:linear-gradient(135deg,#fff2cf,#f7d88c);color:#845d14;font-size:1rem;flex:none}
.ai-assistant-launcher small{display:block;font-weight:700;color:#7b6a43;font-size:.68rem;margin-top:2px}

.ai-assistant-shell{position:fixed;inset:0;z-index:2600;display:none;pointer-events:none;isolation:isolate;contain:layout style}
.ai-assistant-shell.open{display:block;pointer-events:auto}
.ai-assistant-backdrop{position:absolute;inset:0;background:rgba(8,14,28,.26);backdrop-filter:blur(2px)}

/* Panel: fixed right-side card on desktop, flex column so header/composer stay
   put and only the transcript scrolls. width is always clamped to the viewport
   so the panel itself can never force page-level horizontal scroll. */
.ai-assistant-panel{
  position:absolute;
  right:18px;bottom:18px;
  width:min(460px,calc(100vw - 32px));
  max-width:calc(100vw - 32px);
  height:min(86vh,760px);
  max-height:calc(100vh - 32px);
  display:flex;flex-direction:column;
  min-width:0;
  background:#fff;border:1px solid var(--ai-line);border-radius:22px;
  box-shadow:0 28px 80px rgba(11,21,38,.28);
  overflow:hidden;
}

.ai-assistant-header{
  flex:0 0 auto;display:flex;align-items:center;justify-content:space-between;gap:14px;
  padding:14px 16px;border-bottom:1px solid #e6edf4;background:linear-gradient(135deg,#fffaf1,#f7fbff);min-width:0
}
.ai-assistant-title{display:flex;gap:10px;align-items:center;min-width:0}
/* Exact match to the launcher's .ai-spark (same width/height/border-radius/
   gradient/color/font-size) - first attempt matched most properties but
   missed font-size (so the glyph itself rendered a different size despite
   the circle matching) and added a ring directly on the icon, which the
   launcher doesn't have - its ring sits on the outer pill, not the small
   spark circle, so adding one here was a new mismatch, not a fix. */
.ai-assistant-avatar{width:29px;height:29px;border-radius:50%;display:grid;place-items:center;background:linear-gradient(135deg,#fff2cf,#f7d88c);color:#845d14;font-size:1rem;flex:none}
/* display:block on the svg avoids inline-SVG's default text-baseline
   alignment, which can read as a few px off-center within the grid cell
   even with place-items:center on the parent. */
.ai-spark svg,.ai-assistant-avatar svg{display:block}
.ai-assistant-title strong{display:block;color:var(--ai-navy);font-size:.96rem;overflow-wrap:break-word}
.ai-assistant-title span{display:block;color:#6b7487;font-size:.74rem;margin-top:1px}
.ai-assistant-close{width:34px;height:34px;flex:none;border:0;border-radius:50%;background:#eef4f9;color:#243047;font-size:1.25rem;cursor:pointer}
.ai-assistant-close:hover{background:#e3ecf3}

.ai-context-pill{
  flex:0 0 auto;margin:10px 16px 0;padding:6px 12px;border-radius:999px;background:#f1f7fb;border:1px solid #dbe8f0;
  color:#3a5674;font:700 .72rem/1.3 "DM Sans",Inter,sans-serif;overflow-wrap:break-word;
}
.ai-context-pill[hidden]{display:none}

/* Transcript: the ONLY region that scrolls. flex:1 + min-height:0 is what lets
   it shrink correctly inside the flex column instead of forcing the panel to
   grow past its max-height. overflow-x is explicitly hidden here — horizontal
   overflow inside a message is a bug to fix at the message level, never
   something to scroll past. */
.ai-assistant-messages{
  flex:1 1 auto;min-height:0;min-width:0;
  overflow-y:auto;overflow-x:hidden;
  padding:16px;display:flex;flex-direction:column;gap:12px;
  background:linear-gradient(180deg,#fbfdff,#fff);
  overscroll-behavior:contain;
}

.ai-welcome{padding:6px 4px 4px;min-width:0}
.ai-welcome h3{margin:0 0 12px;color:var(--ai-navy);font:800 1.05rem/1.3 "DM Sans",Inter,sans-serif}
.ai-welcome p{margin:0;color:#4c5668;font-size:.86rem;line-height:1.55;overflow-wrap:break-word}
/* Starter chips live inside the welcome content itself, immediately below the
   intro copy, so they scroll away naturally once a conversation starts
   instead of sitting in a permanent footer competing with the composer and
   keyboard for space. */
.ai-welcome .ai-suggestions{display:flex;flex-wrap:wrap;gap:8px;margin:20px 0 0;min-width:0}
.ai-ask-cue{margin:20px 0 0;color:#8d96a8;font-size:.78rem;font-style:italic}

/* Message row + bubble: min-width:0 on every link in the chain is what stops a
   long word/answer from forcing the row wider than its max-width. */
.ai-message{max-width:92%;min-width:0;display:flex;flex-direction:column;gap:7px}
.ai-message.user{align-self:flex-end;max-width:85%}
.ai-message.assistant{align-self:flex-start;max-width:92%}
.ai-bubble{
  min-width:0;max-width:100%;
  padding:11px 14px;border-radius:16px;font-size:.9rem;line-height:1.55;
  white-space:pre-wrap;overflow-wrap:break-word;word-break:break-word
}
.ai-message.user .ai-bubble{background:#0d68c8;color:#fff;border-bottom-right-radius:5px}
.ai-message.assistant .ai-bubble{background:#f3f7fb;color:#29344a;border:1px solid #e0e9f1;border-bottom-left-radius:5px}

.ai-sources{display:flex;flex-wrap:wrap;gap:6px;min-width:0}
.ai-source{display:inline-flex;align-items:center;max-width:100%;padding:6px 9px;border:1px solid #d7e5ef;border-radius:999px;background:#fff;color:#0b62bb;font-size:.71rem;font-weight:800;overflow-wrap:break-word}
.ai-source:hover{background:#eef7ff}

.ai-actions{display:flex;flex-wrap:wrap;gap:8px;min-width:0}
.ai-action{display:inline-flex;align-items:center;justify-content:center;max-width:100%;padding:8px 11px;border-radius:999px;border:1px solid #cbddeb;background:#fff;color:#134f8a;font-size:.75rem;font-weight:800;text-align:center;overflow-wrap:break-word}
.ai-action.primary{background:#fff7e4;border-color:#ead29e;color:#71531b}
.ai-quick-reply{border:1px solid #c8dceb;background:#fff;color:#134f83;cursor:pointer;font:700 .77rem/1.2 "DM Sans",Inter,sans-serif}
.ai-quick-reply:hover,.ai-quick-reply:focus-visible{background:#eef7ff;border-color:#86b8de;outline:none}

.ai-feedback{display:flex;align-items:center;gap:6px;color:#8d96a8;font-size:.68rem}
.ai-feedback button{border:1px solid #dde6ed;background:#fff;border-radius:999px;padding:4px 7px;cursor:pointer;line-height:1}
.ai-feedback button.selected{background:#eaf5ff;border-color:#b9d7ef}
.ai-feedback button:focus-visible{outline:2px solid #317fc4;outline-offset:2px}

.ai-consultation-card{margin-top:8px;padding:14px;border:1px solid #d6e3ec;border-radius:16px;background:linear-gradient(180deg,#fff,#f8fbfd);box-shadow:0 8px 20px rgba(18,34,52,.06);min-width:0}
.ai-consultation-kicker{font:800 .72rem/1.2 "DM Sans",Inter,sans-serif;text-transform:uppercase;letter-spacing:.08em;color:var(--ai-teal);margin-bottom:9px}
.ai-consultation-card dl{display:grid;gap:8px;margin:0 0 12px}
.ai-consultation-card dl>div{display:grid;grid-template-columns:96px 1fr;gap:10px;align-items:start;min-width:0}
.ai-consultation-card dt{font:700 .72rem/1.35 "DM Sans",Inter,sans-serif;color:var(--ai-muted)}
.ai-consultation-card dd{margin:0;font:600 .78rem/1.4 "DM Sans",Inter,sans-serif;color:#1b2a3e;min-width:0;overflow-wrap:break-word}
.ai-consultation-card .ai-action{display:inline-flex;margin-top:2px}
.ai-consultation-card small{display:block;margin-top:9px;color:#778196;font-size:.67rem;line-height:1.35}

.ai-typing{display:inline-flex;align-items:center;gap:8px;padding:11px 13px;border-radius:16px;background:#f3f7fb;border:1px solid #e0e9f1;width:max-content;max-width:100%}
.ai-typing-label{color:#59657a;font-size:.78rem;font-weight:700;overflow-wrap:break-word}
.ai-typing i{width:6px;height:6px;flex:none;border-radius:50%;background:#75869a;animation:ai-bounce 1s infinite alternate}
.ai-typing i:nth-child(2){animation-delay:.16s}
.ai-typing i:nth-child(3){animation-delay:.32s}
@keyframes ai-bounce{to{transform:translateY(-4px);opacity:.55}}
.ai-assistant-error{padding:10px 12px;border-radius:12px;background:#fff5f2;color:#8a3a2d;border:1px solid #f0d0c8;font-size:.8rem;overflow-wrap:break-word}

/* Footer: fixed, non-scrolling. Chips wrap instead of scrolling off-screen;
   the composer's own min-width:0 stops the textarea from ever forcing the
   footer (and therefore the panel) wider than the viewport allows. */
.ai-assistant-footer{flex:0 0 auto;border-top:1px solid #e5edf4;padding:10px 14px 12px;background:#fff;min-width:0}
.ai-suggestion{
  white-space:normal;max-width:100%;border:1px solid #dbe7f0;background:#f8fbfd;color:#36445a;
  border-radius:999px;padding:7px 12px;font-size:.73rem;font-weight:800;cursor:pointer;line-height:1.25
}
.ai-suggestion:hover,.ai-suggestion:focus-visible{background:#eef7ff;border-color:#9dc4e6;outline:none}

.ai-assistant-form{display:flex;align-items:flex-end;gap:8px;min-width:0}
.ai-assistant-form textarea{
  flex:1 1 auto;min-width:0;max-width:100%;width:100%;
  resize:none;overflow-y:auto;
  min-height:44px;max-height:120px;
  padding:11px 12px;border:1px solid #cfdde8;border-radius:15px;
  font:500 .82rem/1.4 "DM Sans",Inter,sans-serif;color:#1d273a;outline:none
}
/* The placeholder is one line (rows="1", fixed min-height) but ordinary
   placeholder text wraps like typed content - on the narrower panel widths
   it wrapped to a second line that then got clipped by the fixed height,
   showing "appointment" cut off mid-glyph. Truncating with an ellipsis
   instead of wrapping is the graceful fallback regardless of exact width;
   the smaller font/padding above means it usually fits in full anyway. */
.ai-assistant-form textarea::placeholder{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.ai-assistant-form textarea:focus-visible{border-color:#7eb5e2;box-shadow:0 0 0 3px rgba(7,95,196,.12)}
.ai-send{flex:0 0 auto;width:44px;height:44px;border:0;border-radius:14px;background:var(--ai-blue);color:#fff;font-weight:900;cursor:pointer;display:grid;place-items:center}
.ai-send:hover:not(:disabled){background:#0a56ad}
.ai-send:focus-visible{outline:2px solid #317fc4;outline-offset:2px}
.ai-send:disabled{opacity:.55;cursor:wait}

.ai-disclaimer{display:flex;align-items:baseline;flex-wrap:wrap;gap:4px 8px;margin-top:8px;font-size:.68rem;line-height:1.4;color:#778196;min-width:0}
.ai-disclaimer-toggle{border:0;background:transparent;color:#5a7794;font:700 .68rem/1.4 "DM Sans",Inter,sans-serif;padding:0;cursor:pointer;text-decoration:underline;text-underline-offset:2px}
.ai-disclaimer-toggle:hover,.ai-disclaimer-toggle:focus-visible{color:var(--ai-blue);outline:none}
.ai-disclaimer-full{flex-basis:100%;margin-top:2px;color:#7b8496;overflow-wrap:break-word}
.ai-disclaimer-full[hidden]{display:none}

/* Composing state: while the keyboard is up, reclaim the disclaimer's row
   for the conversation instead of leaving it permanently docked. */
.ai-assistant-panel.composer-active .ai-disclaimer{display:none}

body.ai-panel-open{overflow:hidden}

.ai-assistant-header-actions{display:flex;align-items:center;gap:4px;flex:none}
.ai-assistant-clear{border:0;background:transparent;color:var(--ai-muted);font:700 .7rem/1 "DM Sans",Inter,sans-serif;padding:8px 7px;border-radius:9px;cursor:pointer;white-space:nowrap}
.ai-assistant-clear:hover,.ai-assistant-clear:focus-visible{background:#eef4f8;color:var(--ai-navy);outline:none}

.ai-assistant-panel :focus-visible{outline:2px solid #317fc4;outline-offset:2px}

@media(max-width:760px){
  /* 220px was sized to clear the old 4-icon floating-actions stack
     (WhatsApp/IG/FB/call, ~254px tall). IG/FB were removed from mobile in
     the previous change, leaving only WhatsApp+call (~100px tall at
     bottom:12px, gap:8px, 46px icons) - 220px left 100px+ of dead space
     above a 2-icon stack. Tightened to clear the shorter stack with a
     normal ~18px gap instead. */
  /* Showing the label (below) made the pill noticeably wider than the old
     icon-only circle - compacting padding/gap/font-size/icon so it reads
     clearly without eating into the page content next to it. */
  .ai-assistant-launcher{right:12px;bottom:130px;padding:9px 12px;gap:7px;font-size:.78rem}
  .ai-assistant-launcher .ai-spark{width:24px;height:24px;font-size:.84rem}
  /* Previously hid the whole label, leaving a bare sparkle circle that
     visually blended into the WhatsApp/IG/FB/call stack below it - no
     indication this was the chat assistant, not another social icon.
     Keeping the subtext hidden still (not the "Treatments · doctors ·
     appointments" line) so the pill stays compact on small screens. */
  .ai-assistant-launcher small{display:none}
  .ai-assistant-panel{
    right:0;left:0;bottom:0;
    width:100%;max-width:100vw;
    height:90vh;height:90dvh;max-height:none;
    border-radius:20px 20px 0 0;border-left:0;border-right:0;border-bottom:0;
    padding-bottom:env(safe-area-inset-bottom,0px)
  }
  .ai-assistant-header{padding-top:calc(14px + env(safe-area-inset-top,0px))}
  .ai-assistant-backdrop{background:rgba(8,14,28,.35)}
  .ai-consultation-card dl>div{grid-template-columns:84px 1fr}
  .ai-assistant-clear{font-size:.68rem}
}

@media(prefers-reduced-motion:reduce){
  .ai-assistant-launcher,.ai-typing i{transition:none;animation:none}
  /* Keeps the gradient ring visible (still reads as "the AI feature") but
     freezes the rotation - motion is what reduced-motion users are opting
     out of, not the visual treatment itself. */
  .ai-assistant-launcher::before{animation:none}
}
