/**
 * Chat widget. Uses the theme's design tokens so it inherits any palette change.
 */

.kou-chat{position:fixed;right:20px;bottom:20px;z-index:9990;font-family:var(--font-primary,-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif)}

/* Launcher ---------------------------------------------------------------- */
.kou-chat__launcher{display:inline-flex;align-items:center;gap:.55rem;padding:.85rem 1.25rem;border:0;border-radius:var(--radius-full,50px);background:var(--gradient-primary,linear-gradient(135deg,#FF6B35 0%,#FF8C42 100%));color:#fff;font-family:var(--font-heading,inherit);font-size:.95rem;font-weight:700;cursor:pointer;box-shadow:0 8px 24px rgba(255,107,53,.35);transition:transform .15s ease,box-shadow .15s ease}
.kou-chat__launcher:hover{transform:translateY(-2px);box-shadow:0 12px 30px rgba(255,107,53,.45)}
.kou-chat__launcher:focus-visible{outline:3px solid #1A1A1A;outline-offset:3px}
.kou-chat__launcher svg{width:22px;height:22px;fill:currentColor;flex:none}
.kou-chat__close-icon{display:none}
.kou-chat[data-open="true"] .kou-chat__launcher-icon,
.kou-chat[data-open="true"] .kou-chat__launcher-label{display:none}
.kou-chat[data-open="true"] .kou-chat__close-icon{display:block}
.kou-chat[data-open="true"] .kou-chat__launcher{padding:.9rem;border-radius:50%}

/* Panel ------------------------------------------------------------------- */
/* A class selector beats the UA stylesheet's [hidden]{display:none}, so the
   panel has to opt back out explicitly or it renders open on first paint. */
.kou-chat__panel[hidden]{display:none}
.kou-chat__panel{position:absolute;right:0;bottom:calc(100% + 12px);width:min(400px,calc(100vw - 40px));height:min(580px,calc(100vh - 120px));display:flex;flex-direction:column;background:#fff;border-radius:16px;box-shadow:0 24px 60px rgba(0,0,0,.22);overflow:hidden;animation:kou-chat-in .2s ease both}
@keyframes kou-chat-in{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:none}}
@media (prefers-reduced-motion:reduce){.kou-chat__panel{animation:none}}

.kou-chat__head{display:flex;align-items:center;justify-content:space-between;gap:.75rem;padding:1rem 1.1rem;background:var(--gradient-dark,linear-gradient(135deg,#1A1A1A 0%,#333 100%));color:#fff}
.kou-chat__head-text{display:flex;flex-direction:column;line-height:1.3;min-width:0}
.kou-chat__head-text strong{font-family:var(--font-heading,inherit);font-size:1rem}
.kou-chat__head-text span{font-size:.75rem;color:rgba(255,255,255,.6)}
.kou-chat__dismiss{background:none;border:0;padding:.35rem;color:rgba(255,255,255,.7);cursor:pointer;border-radius:6px;flex:none}
.kou-chat__dismiss:hover{color:#fff}
.kou-chat__dismiss svg{width:20px;height:20px;fill:currentColor;display:block}

/* Log --------------------------------------------------------------------- */
.kou-chat__log{flex:1;overflow-y:auto;padding:1.1rem;background:#F8F9FA;display:flex;flex-direction:column;gap:.85rem;overscroll-behavior:contain}
.kou-msg{max-width:88%;font-size:.9rem;line-height:1.6}
.kou-msg--bot{align-self:flex-start}
.kou-msg--user{align-self:flex-end}
.kou-msg__bubble{padding:.75rem .95rem;border-radius:14px;white-space:pre-wrap;word-wrap:break-word;overflow-wrap:anywhere}
.kou-msg--bot .kou-msg__bubble{background:#fff;color:var(--text-dark,#212529);border:1px solid var(--medium-gray,#E9ECEF);border-bottom-left-radius:4px}
.kou-msg--user .kou-msg__bubble{background:var(--secondary,#1A1A1A);color:#fff;border-bottom-right-radius:4px}

.kou-msg__note{margin-top:.5rem;padding:.6rem .75rem;background:#FFF6F1;border-left:3px solid var(--primary,#FF6B35);border-radius:0 6px 6px 0;font-size:.78rem;line-height:1.55;color:var(--text-muted,#4A5568)}

.kou-msg__links{margin-top:.6rem;display:flex;flex-direction:column;gap:.3rem}
.kou-msg__links a{display:inline-flex;align-items:flex-start;gap:.4rem;font-size:.82rem;font-weight:600;color:var(--primary-dark,#E55A2B);text-decoration:none;line-height:1.45}
.kou-msg__links a:hover{text-decoration:underline}
.kou-msg__links a::before{content:"→";flex:none}

/* Product cards ----------------------------------------------------------- */
.kou-msg__products{margin-top:.7rem;display:flex;flex-direction:column;gap:.5rem}
.kou-chatprod{display:block;padding:.7rem .85rem;background:#fff;border:1px solid var(--medium-gray,#E9ECEF);border-radius:10px;text-decoration:none;transition:border-color .15s ease,box-shadow .15s ease}
.kou-chatprod:hover{border-color:var(--primary,#FF6B35);box-shadow:0 4px 12px rgba(0,0,0,.06)}
.kou-chatprod__top{display:flex;align-items:baseline;justify-content:space-between;gap:.5rem}
.kou-chatprod__name{font-family:var(--font-heading,inherit);font-weight:700;font-size:.87rem;color:var(--text-dark,#212529)}
.kou-chatprod__price{font-weight:700;font-size:.85rem;color:var(--primary,#FF6B35);white-space:nowrap}
.kou-chatprod__blurb{margin:.3rem 0 0;font-size:.79rem;line-height:1.5;color:var(--text-muted,#4A5568)}

/* Chips ------------------------------------------------------------------- */
.kou-chips{display:flex;flex-wrap:wrap;gap:.4rem;margin-top:.7rem}
.kou-chip{padding:.42rem .75rem;background:#fff;border:1px solid var(--medium-gray,#E9ECEF);border-radius:50px;font-family:inherit;font-size:.78rem;font-weight:600;color:var(--text-muted,#4A5568);cursor:pointer;transition:all .15s ease}
.kou-chip:hover{border-color:var(--primary,#FF6B35);color:var(--primary-dark,#E55A2B)}

/* Typing ------------------------------------------------------------------ */
.kou-typing{display:inline-flex;gap:4px;padding:.85rem .95rem}
.kou-typing span{width:7px;height:7px;border-radius:50%;background:#B8C0CC;animation:kou-bounce 1.2s infinite}
.kou-typing span:nth-child(2){animation-delay:.15s}
.kou-typing span:nth-child(3){animation-delay:.3s}
@keyframes kou-bounce{0%,60%,100%{transform:translateY(0);opacity:.55}30%{transform:translateY(-5px);opacity:1}}

/* Form -------------------------------------------------------------------- */
.kou-chat__form{display:flex;gap:.5rem;padding:.75rem;border-top:1px solid var(--medium-gray,#E9ECEF);background:#fff}
.kou-chat__input{flex:1;min-width:0;padding:.7rem .9rem;border:1px solid var(--medium-gray,#E9ECEF);border-radius:50px;font-family:inherit;font-size:.88rem;color:var(--text-dark,#212529);background:#F8F9FA}
.kou-chat__input:focus{outline:0;border-color:var(--primary,#FF6B35);background:#fff}
.kou-chat__send{flex:none;width:40px;height:40px;display:grid;place-items:center;border:0;border-radius:50%;background:var(--gradient-primary,linear-gradient(135deg,#FF6B35 0%,#FF8C42 100%));color:#fff;cursor:pointer}
.kou-chat__send:disabled{opacity:.5;cursor:not-allowed}
.kou-chat__send svg{width:18px;height:18px;fill:currentColor}

.kou-chat__foot{margin:0;padding:.5rem .75rem .7rem;background:#fff;text-align:center;font-size:.7rem;color:var(--text-subtle,#5A6578)}
.kou-chat__foot a{color:var(--primary-dark,#E55A2B)}

/* Mobile ------------------------------------------------------------------ */
@media (max-width:600px){
.kou-chat{right:14px;bottom:14px}
.kou-chat__launcher-label{display:none}
.kou-chat__launcher{padding:.9rem;border-radius:50%}
.kou-chat__panel{position:fixed;inset:0;width:100%;height:100%;max-height:100%;border-radius:0}
}

/* The age gate owns the screen until it is cleared. */
html.kou-ag-locked .kou-chat{display:none}
