/* ==========================================================================
   Sales chatbot — floating button + panel.
   Uses the site's own tokens from styles.css (--panel, --card, --accent, --btn-bright, fonts).
   Self-contained: nothing here changes the look of any existing element.
   Stacking: bottom nav 60 · overlays 70 · cart drawer 80 · chat panel 90 · gallery 200.
   ========================================================================== */

.gc-root{ --gc-nav: var(--nav-h, 72px); --gc-gold: var(--btn-bright, linear-gradient(135deg,#ffe3a3 0%,#f9c866 55%,#f4a93d 100%)); }

/* ---------- Floating button (always bottom-right, above the bottom nav) ---------- */
.gc-fab{
  position:fixed; right:18px; bottom:calc(var(--gc-nav) + 16px + env(safe-area-inset-bottom, 0px)); z-index:55;
  width:56px; height:56px; border-radius:50%; border:0; padding:0; cursor:pointer;
  display:grid; place-items:center;
  background:var(--gc-gold); color:#2a1700;
  box-shadow:0 12px 28px -8px rgba(249,200,102,.55), 0 6px 16px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.55);
  transition:transform .22s var(--ease, ease), box-shadow .25s var(--ease, ease), filter .2s;
}
.gc-fab:hover{ transform:translateY(-3px) scale(1.04); filter:brightness(1.05); box-shadow:0 18px 34px -8px rgba(249,200,102,.75), 0 8px 18px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.6); }
.gc-fab:active{ transform:translateY(0) scale(.98); }
.gc-fab:focus-visible{ outline:2px solid var(--accent-hi, #f5dad5); outline-offset:4px; }
.gc-fab svg{ width:26px; height:26px; stroke:currentColor; fill:none; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; transition:transform .25s var(--ease, ease), opacity .2s; }
.gc-fab .gc-ic-close{ position:absolute; opacity:0; transform:rotate(-60deg) scale(.6); }
.gc-fab[aria-expanded="true"] .gc-ic-chat{ opacity:0; transform:rotate(60deg) scale(.6); }
.gc-fab[aria-expanded="true"] .gc-ic-close{ opacity:1; transform:none; }

/* ---------- Panel ---------- */
.gc-panel{
  position:fixed; right:18px; bottom:calc(var(--gc-nav) + 16px + 56px + 12px + env(safe-area-inset-bottom, 0px)); z-index:90;
  width:392px; max-width:calc(100vw - 24px);
  height:min(620px, calc(100dvh - var(--gc-nav) - 56px - 16px - 12px - 20px - env(safe-area-inset-bottom, 0px)));
  min-height:340px;
  display:flex; flex-direction:column; overflow:hidden;
  background:var(--panel, #1d1018); color:var(--cream, #f8eee9);
  border:1px solid var(--line, rgba(228,187,181,.24)); border-radius:10px;
  box-shadow:0 34px 80px -24px rgba(0,0,0,.9), 0 0 0 1px rgba(0,0,0,.4);
  transform-origin:bottom right;
  transition:opacity .22s var(--ease, ease), transform .26s var(--ease, ease), visibility 0s linear .26s;
  opacity:0; visibility:hidden; transform:translateY(14px) scale(.97); pointer-events:none;
}
.gc-panel.is-open{ opacity:1; visibility:visible; transform:none; pointer-events:auto; transition-delay:0s; }

/* header */
.gc-head{
  display:flex; align-items:center; gap:12px; padding:14px 14px 14px 16px; flex:none;
  background:linear-gradient(135deg, var(--plum, #592941) 0%, #3a1a2b 100%);
  border-bottom:1px solid var(--line, rgba(228,187,181,.24));
}
.gc-logo{ width:38px; height:38px; flex:none; border-radius:50%; object-fit:contain; background:rgba(20,11,17,.55); border:1px solid var(--line, rgba(228,187,181,.24)); padding:4px; }
.gc-titles{ flex:1; min-width:0; line-height:1.25; }
.gc-title{ display:block; font-family:var(--font-display, serif); font-size:16.5px; font-weight:600; color:var(--accent-hi, #f5dad5); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.gc-sub{ display:flex; align-items:center; gap:6px; font-size:12px; color:var(--cream-dim, rgba(248,238,233,.68)); }
.gc-sub::before{ content:""; width:7px; height:7px; border-radius:50%; background:#9be3a8; box-shadow:0 0 0 3px rgba(155,227,168,.18); flex:none; }
.gc-hbtn{
  flex:none; width:36px; height:36px; border-radius:50%; display:grid; place-items:center; cursor:pointer;
  background:rgba(248,238,233,.08); border:1px solid transparent; color:var(--cream, #f8eee9); padding:0;
  transition:background .2s, border-color .2s, color .2s;
}
.gc-hbtn:hover{ background:rgba(248,238,233,.16); border-color:var(--line, rgba(228,187,181,.24)); color:var(--accent-hi, #f5dad5); }
.gc-hbtn svg{ width:19px; height:19px; stroke:currentColor; fill:none; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; }
.gc-hbtn:focus-visible, .gc-send:focus-visible, .gc-chip:focus-visible, .gc-btn:focus-visible, .gc-log:focus-visible{ outline:2px solid var(--accent-hi, #f5dad5); outline-offset:2px; }

/* conversation */
.gc-log{
  flex:1; min-height:0; overflow-y:auto; overscroll-behavior:contain; -webkit-overflow-scrolling:touch;
  padding:16px 14px 8px; display:flex; flex-direction:column; gap:12px;
  scrollbar-width:thin; scrollbar-color:rgba(228,187,181,.3) transparent;
}
.gc-msg{ display:flex; flex-direction:column; gap:8px; max-width:100%; animation:gc-in .28s var(--ease, ease) both; }
.gc-msg--user{ align-items:flex-end; }
.gc-msg--bot{ align-items:flex-start; }
[dir="rtl"] .gc-msg--user{ align-items:flex-start; }
[dir="rtl"] .gc-msg--bot{ align-items:flex-end; }
.gc-bubble{
  max-width:88%; padding:10px 14px; font-size:14.5px; line-height:1.6; word-wrap:break-word; overflow-wrap:anywhere;
  border-radius:16px; unicode-bidi:plaintext;
}
.gc-msg--bot .gc-bubble{ background:var(--card, #2e1a27); border:1px solid var(--line-soft, rgba(247,237,233,.1)); color:var(--cream, #f8eee9); border-end-start-radius:4px; }
.gc-msg--user .gc-bubble{ background:var(--gc-gold); color:#2a1700; font-weight:500; border-end-end-radius:4px; }
.gc-msg--err .gc-bubble{ border-color:rgba(255,138,138,.45); }
.gc-bubble strong{ color:var(--accent-hi, #f5dad5); font-weight:700; }
.gc-msg--user .gc-bubble strong{ color:inherit; }

/* typing indicator */
.gc-typing{ display:inline-flex; gap:5px; align-items:center; padding:14px 16px; }
.gc-typing i{ width:7px; height:7px; border-radius:50%; background:var(--accent, #e4bbb5); opacity:.4; animation:gc-dot 1.1s infinite ease-in-out; }
.gc-typing i:nth-child(2){ animation-delay:.16s } .gc-typing i:nth-child(3){ animation-delay:.32s }
@keyframes gc-dot{ 0%,80%,100%{ transform:translateY(0); opacity:.35 } 40%{ transform:translateY(-4px); opacity:1 } }
@keyframes gc-in{ from{ opacity:0; transform:translateY(8px) } to{ opacity:1; transform:none } }

/* quick-start chips */
.gc-chips{ flex:none; display:flex; flex-wrap:wrap; gap:8px; padding:4px 14px 10px; }
.gc-chips:empty{ display:none; }
.gc-chip{
  font:inherit; font-size:13px; cursor:pointer; padding:7px 13px; border-radius:999px;
  background:transparent; color:var(--cream, #f8eee9); border:1px solid var(--line, rgba(228,187,181,.24));
  transition:background .2s, border-color .2s, color .2s;
}
.gc-chip:hover{ border-color:var(--accent, #e4bbb5); color:var(--accent-hi, #f5dad5); background:rgba(228,187,181,.08); }

/* product cards (compact) */
.gc-cards{ display:flex; flex-direction:column; gap:8px; width:100%; max-width:100%; }
.gc-card{
  display:flex; gap:12px; padding:10px; width:100%;
  background:linear-gradient(180deg, var(--card, #2e1a27) 0%, var(--panel-2, #26141f) 100%);
  border:1px solid var(--line, rgba(228,187,181,.24)); border-radius:8px;
}
.gc-card-img{ flex:none; width:78px; height:78px; border-radius:6px; overflow:hidden; background:var(--ink, #140b11); border:1px solid var(--line-soft, rgba(247,237,233,.1)); }
.gc-card-img img{ width:100%; height:100%; object-fit:cover; display:block; }
.gc-card-img img.is-logo{ object-fit:contain; padding:10px; }
.gc-card-body{ flex:1; min-width:0; display:flex; flex-direction:column; gap:3px; }
.gc-card-name{ font-family:var(--font-display, serif); font-size:15px; font-weight:600; line-height:1.3; color:var(--cream, #f8eee9); margin:0; }
.gc-card-meta{ font-size:12px; color:var(--cream-dim, rgba(248,238,233,.68)); line-height:1.4; }
.gc-card-price{ font-family:var(--font-display, serif); font-size:16px; font-weight:700; color:var(--accent-hi, #f5dad5); }
.gc-card-price.is-na{ font-family:var(--font-body); font-size:12.5px; font-weight:500; color:var(--cream-dim, rgba(248,238,233,.68)); }
.gc-card-actions{ display:flex; gap:8px; margin-top:6px; flex-wrap:wrap; }
.gc-btn{
  font:inherit; font-size:12.5px; font-weight:700; line-height:1; cursor:pointer; text-decoration:none; text-align:center;
  padding:8px 14px; border-radius:999px; border:1px solid var(--line, rgba(228,187,181,.24)); background:transparent; color:var(--cream, #f8eee9);
  display:inline-flex; align-items:center; justify-content:center; transition:transform .18s, filter .2s, border-color .2s, color .2s, background .2s;
}
.gc-btn:hover{ border-color:var(--accent, #e4bbb5); color:var(--accent-hi, #f5dad5); }
.gc-btn--solid{ background:var(--gc-gold); color:#2a1700; border-color:transparent; }
.gc-btn--solid:hover{ filter:brightness(1.06); transform:translateY(-1px); color:#2a1700; }
.gc-btn[disabled]{ opacity:.7; cursor:default; transform:none; }
.gc-wa-btn{ margin-top:2px; }

/* composer */
.gc-form{
  flex:none; display:flex; align-items:flex-end; gap:8px; padding:10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  border-top:1px solid var(--line-soft, rgba(247,237,233,.1)); background:var(--panel-2, #26141f);
}
.gc-input{
  flex:1; min-width:0; resize:none; max-height:120px; min-height:42px; padding:10px 14px; margin:0;
  font:inherit; font-size:16px; line-height:1.45; color:var(--cream, #f8eee9);   /* 16px stops iOS zooming into the field */
  background:var(--ink, #140b11); border:1px solid var(--line, rgba(228,187,181,.24)); border-radius:21px;
}
.gc-input::placeholder{ color:rgba(248,238,233,.5); }
.gc-input:focus{ outline:2px solid var(--accent-hi, #f5dad5); outline-offset:1px; border-color:transparent; }
.gc-send{
  flex:none; width:42px; height:42px; border-radius:50%; border:0; padding:0; cursor:pointer; display:grid; place-items:center;
  background:var(--gc-gold); color:#2a1700; transition:transform .18s, filter .2s, opacity .2s;
}
.gc-send:hover:not(:disabled){ filter:brightness(1.06); transform:translateY(-1px); }
.gc-send:disabled{ opacity:.45; cursor:default; }
.gc-send svg{ width:20px; height:20px; stroke:currentColor; fill:none; stroke-width:1.9; stroke-linecap:round; stroke-linejoin:round; }
[dir="rtl"] .gc-send svg{ transform:scaleX(-1); }
.gc-note{ margin:0; padding:0 14px 8px; font-size:11px; color:rgba(248,238,233,.5); text-align:center; background:var(--panel-2, #26141f); flex:none; }
.gc-sr{ position:absolute; width:1px; height:1px; margin:-1px; padding:0; overflow:hidden; clip:rect(0,0,0,0); border:0; white-space:nowrap; }

/* ---------- Phones: panel fills the screen, follows the keyboard ---------- */
@media (max-width:640px){
  .gc-fab{ right:14px; bottom:calc(var(--gc-nav) + 12px + env(safe-area-inset-bottom, 0px)); width:52px; height:52px; }
  .gc-panel{
    right:0; left:0; bottom:auto; top:var(--gc-top, 0px); width:100%; max-width:none; min-height:0;
    height:var(--gc-vh, 100dvh); border:0; border-radius:0; transform:translateY(24px);
  }
  .gc-panel.is-open{ transform:none; }
  .gc-head{ padding-top:calc(14px + env(safe-area-inset-top, 0px)); }
  .gc-bubble{ max-width:92%; }
  html.gc-lock, html.gc-lock body{ overflow:hidden; }
}
@media (max-height:520px) and (min-width:641px){ .gc-panel{ min-height:0; } }

/* ---------- Product highlighted when opened from a chat card (products.html?p=ID) ---------- */
.product-card.is-pinned{ border-color:var(--accent, #e4bbb5); box-shadow:0 0 0 1px var(--accent, #e4bbb5), 0 0 34px -6px rgba(249,200,102,.5); }

@media (prefers-reduced-motion:reduce){
  .gc-fab, .gc-panel, .gc-msg, .gc-typing i, .gc-fab svg{ animation:none !important; transition:none !important; }
}
