/* =========================================================================
   Roy K Group — Concierge chat widget
   Theme-aware: uses the shared design tokens (--accent, --card, --paper-2,
   --ink, --text, --line, --muted, --on-accent, --font-*), so it adapts to
   Editorial / Midnight / Blueprint automatically. Bottom-right (clear of the
   bottom-left theme switch).
   ========================================================================= */

.rkc{ --rkc-radius:16px; font-family:var(--font-sans); }

/* ---- Launcher button ---- */
.rkc-launch{ position:fixed; right:20px; bottom:20px; z-index:95; display:inline-flex; align-items:center; gap:10px;
  height:56px; padding:0 20px 0 18px; border:0; border-radius:999px; cursor:pointer;
  background:var(--accent); color:var(--on-accent); font-family:var(--font-logo); font-weight:700; font-size:.95rem;
  box-shadow:0 14px 34px -12px rgba(0,0,0,.5); transition:transform .25s cubic-bezier(.16,1,.3,1), box-shadow .25s, filter .2s; }
.rkc-launch:hover{ transform:translateY(-2px); box-shadow:0 20px 44px -14px rgba(0,0,0,.55); filter:brightness(1.04); }
.rkc-launch svg{ width:22px; height:22px; fill:none; stroke:currentColor; stroke-width:1.9; stroke-linecap:round; stroke-linejoin:round; }
.rkc-launch .rkc-launch-label{ white-space:nowrap; }
@media(max-width:520px){ .rkc-launch{ padding:0; width:56px; justify-content:center; } .rkc-launch .rkc-launch-label{ display:none; } }
.rkc.is-open .rkc-launch{ transform:scale(.9); opacity:0; pointer-events:none; }

/* ---- Panel ---- */
.rkc-panel{ position:fixed; right:20px; bottom:20px; z-index:96; width:380px; max-width:calc(100vw - 32px);
  height:560px; max-height:calc(100vh - 40px); display:flex; flex-direction:column; overflow:hidden;
  background:var(--card); border:1px solid var(--line); border-radius:var(--rkc-radius);
  box-shadow:0 32px 70px -28px rgba(0,0,0,.6); opacity:0; transform:translateY(16px) scale(.98);
  pointer-events:none; transition:opacity .26s cubic-bezier(.16,1,.3,1), transform .26s cubic-bezier(.16,1,.3,1); }
.rkc.is-open .rkc-panel{ opacity:1; transform:none; pointer-events:auto; }

/* ---- Header ---- */
.rkc-head{ display:flex; align-items:center; gap:12px; padding:14px 16px; background:var(--paper-2); border-bottom:1px solid var(--line); }
.rkc-avatar{ width:38px; height:38px; border-radius:50%; flex:none; display:flex; align-items:center; justify-content:center;
  background:var(--accent); color:var(--on-accent); font-family:var(--font-disp); font-weight:700; font-size:1rem; }
.rkc-titles{ flex:1; min-width:0; }
.rkc-title{ font-family:var(--font-disp); font-weight:700; font-size:1rem; color:var(--ink); line-height:1.2; }
.rkc-sub{ font-size:.78rem; color:var(--muted); display:flex; align-items:center; gap:6px; }
.rkc-dot{ width:7px; height:7px; border-radius:50%; background:#34C759; box-shadow:0 0 0 0 rgba(52,199,89,.5); animation:rkcPulse 2.4s infinite; }
@keyframes rkcPulse{ 0%{ box-shadow:0 0 0 0 rgba(52,199,89,.5);} 70%{ box-shadow:0 0 0 7px rgba(52,199,89,0);} 100%{ box-shadow:0 0 0 0 rgba(52,199,89,0);} }
.rkc-close{ appearance:none; background:none; border:0; cursor:pointer; color:var(--muted); font-size:1.5rem; line-height:1; padding:4px 6px; border-radius:8px; }
.rkc-close:hover{ color:var(--ink); background:rgba(127,127,127,.12); }

/* ---- Messages ---- */
.rkc-msgs{ flex:1; overflow-y:auto; padding:18px 16px; display:flex; flex-direction:column; gap:12px; scroll-behavior:smooth; }
.rkc-msg{ max-width:86%; padding:10px 14px; border-radius:14px; font-size:.92rem; line-height:1.5; word-wrap:break-word; }
.rkc-msg a{ color:inherit; text-decoration:underline; text-underline-offset:2px; }
.rkc-msg.bot{ align-self:flex-start; background:var(--paper-2); color:var(--text); border:1px solid var(--line); border-bottom-left-radius:5px; }
.rkc-msg.bot strong{ color:var(--ink); }
.rkc-msg.user{ align-self:flex-end; background:var(--accent); color:var(--on-accent); border-bottom-right-radius:5px; }
.rkc-msg.user a{ color:var(--on-accent); }

/* typing dots */
.rkc-typing{ display:inline-flex; gap:5px; align-items:center; }
.rkc-typing i{ width:7px; height:7px; border-radius:50%; background:var(--muted); display:inline-block; animation:rkcBounce 1.2s infinite; }
.rkc-typing i:nth-child(2){ animation-delay:.15s; } .rkc-typing i:nth-child(3){ animation-delay:.3s; }
@keyframes rkcBounce{ 0%,60%,100%{ transform:translateY(0); opacity:.5;} 30%{ transform:translateY(-5px); opacity:1;} }

/* ---- Suggestion chips ---- */
.rkc-chips{ display:flex; flex-wrap:wrap; gap:8px; padding:0 16px 4px; }
.rkc-chip{ appearance:none; cursor:pointer; font-family:var(--font-sans); font-size:.82rem; font-weight:500;
  padding:7px 12px; border-radius:999px; background:var(--accent-100); color:var(--accent-600);
  border:1px solid var(--line); transition:background .2s, border-color .2s, transform .15s; }
.rkc-chip:hover{ border-color:var(--accent); transform:translateY(-1px); }

/* ---- Composer ---- */
.rkc-compose{ display:flex; gap:8px; align-items:flex-end; padding:12px 12px 14px; border-top:1px solid var(--line); background:var(--card); }
.rkc-input{ flex:1; resize:none; max-height:120px; min-height:42px; padding:10px 12px; border:1px solid var(--line-2);
  border-radius:12px; font:inherit; font-size:.92rem; color:var(--ink); background:var(--paper); line-height:1.4; transition:border-color .15s, box-shadow .15s; }
.rkc-input::placeholder{ color:var(--muted); }
.rkc-input:focus{ outline:none; border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-100); }
.rkc-send{ flex:none; width:42px; height:42px; border:0; border-radius:12px; cursor:pointer; display:flex; align-items:center; justify-content:center;
  background:var(--accent); color:var(--on-accent); transition:transform .15s, filter .2s; }
.rkc-send:hover{ filter:brightness(1.05); transform:translateY(-1px); }
.rkc-send:disabled{ opacity:.5; pointer-events:none; }
.rkc-send svg{ width:20px; height:20px; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }
.rkc-foot{ text-align:center; font-size:.7rem; color:var(--muted); padding:0 16px 10px; }

/* ---- Header actions (export / clear / close) ---- */
.rkc-head-actions{ display:flex; align-items:center; gap:2px; }
.rkc-act{ appearance:none; background:none; border:0; cursor:pointer; color:var(--muted); padding:6px; border-radius:8px;
  display:inline-flex; align-items:center; justify-content:center; transition:color .2s, background .2s; }
.rkc-act:hover{ color:var(--ink); background:rgba(127,127,127,.14); }
.rkc-act svg{ width:18px; height:18px; fill:none; stroke:currentColor; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; }

/* ---- In-bubble links (clickable product/page names) ---- */
.rkc-link{ color:var(--accent-600); text-decoration:underline; text-underline-offset:2px; font-weight:600; }
.rkc-msg.user .rkc-link{ color:var(--on-accent); }
.rkc-msg.bot strong .rkc-link, .rkc-msg.bot .rkc-link{ color:var(--accent-600); }

/* ---- "Talk to a human" action bar — hidden until the visitor signals intent ---- */
.rkc-actionbar{ display:none; gap:8px; padding:0 16px 6px; }
#rkc.human-on .rkc-actionbar{ display:flex; }
.rkc-human{ appearance:none; cursor:pointer; display:inline-flex; align-items:center; gap:7px;
  font-family:var(--font-logo); font-size:.82rem; font-weight:600; color:var(--accent-600);
  background:var(--accent-100); border:1px solid var(--gold-line); border-radius:999px; padding:7px 13px; transition:border-color .2s, transform .15s; }
.rkc-human:hover{ border-color:var(--accent); transform:translateY(-1px); }
.rkc-human svg{ width:15px; height:15px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }

/* ---- Escalation form ---- */
.rkc-escalate{ margin:0 16px 10px; padding:14px; border:1px solid var(--gold-line); border-radius:12px; background:var(--paper-2); }
.rkc-escalate[hidden]{ display:none; }
.rkc-esc-title{ font-family:var(--font-disp); font-weight:700; font-size:.98rem; color:var(--ink); margin-bottom:4px; }
.rkc-esc-sub{ font-size:.82rem; color:var(--muted); margin-bottom:10px; }
.rkc-escalate input, .rkc-escalate textarea{ width:100%; padding:9px 11px; border:1px solid var(--line-2); border-radius:9px;
  font:inherit; font-size:.9rem; color:var(--ink); background:var(--card); margin-bottom:8px; }
.rkc-escalate input::placeholder, .rkc-escalate textarea::placeholder{ color:var(--muted); }
.rkc-escalate input:focus, .rkc-escalate textarea:focus{ outline:none; border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-100); }
.rkc-escalate textarea{ min-height:58px; resize:vertical; }
.rkc-esc-err{ color:#e06a55; font-size:.8rem; min-height:1em; margin-bottom:6px; }
.rkc-esc-row{ display:flex; gap:8px; }
.rkc-esc-send{ flex:1; cursor:pointer; border:0; border-radius:9px; padding:9px; font-family:var(--font-logo); font-weight:700; font-size:.85rem;
  background:var(--accent); color:var(--on-accent); }
.rkc-esc-send:hover{ filter:brightness(1.05); }
.rkc-esc-send:disabled{ opacity:.6; pointer-events:none; }
.rkc-esc-cancel{ cursor:pointer; border:1px solid var(--line-2); background:transparent; color:var(--muted); border-radius:9px; padding:9px 14px; font-family:var(--font-logo); font-weight:600; font-size:.85rem; }
.rkc-esc-cancel:hover{ color:var(--ink); border-color:var(--ink); }

/* ---- Inline confirm (Clear / Export) ---- */
.rkc-confirm{ margin:0 16px 10px; padding:12px 14px; border:1px solid var(--line-2); border-radius:12px;
  background:var(--paper-2); display:flex; flex-direction:column; gap:10px; }
.rkc-confirm[hidden]{ display:none; }
.rkc-confirm-msg{ font-size:.9rem; color:var(--ink); }
.rkc-confirm-btns{ display:flex; gap:8px; }
.rkc-confirm-yes{ cursor:pointer; border:0; border-radius:9px; padding:8px 14px; font-family:var(--font-logo); font-weight:700; font-size:.84rem; background:var(--accent); color:var(--on-accent); }
.rkc-confirm-yes:hover{ filter:brightness(1.05); }
.rkc-confirm-no{ cursor:pointer; border:1px solid var(--line-2); background:transparent; color:var(--muted); border-radius:9px; padding:8px 14px; font-family:var(--font-logo); font-weight:600; font-size:.84rem; }
.rkc-confirm-no:hover{ color:var(--ink); border-color:var(--ink); }

/* ---- Ended (handed-off) state — input locked until cleared ---- */
.rkc-ended{ margin:0 16px 8px; padding:11px 13px; border:1px solid var(--gold-line); border-radius:10px;
  background:var(--accent-100); color:var(--accent-600); font-size:.82rem; line-height:1.45; }
.rkc-ended[hidden]{ display:none; }
#rkc.is-ended .rkc-compose{ opacity:.55; }
#rkc.is-ended .rkc-input{ cursor:not-allowed; }
#rkc.is-ended .rkc-actionbar, #rkc.is-ended .rkc-chips{ display:none; }

/* ---- Composer placeholder fix (no wrap/cutoff) ---- */
.rkc-input{ white-space:nowrap; overflow-x:hidden; text-overflow:ellipsis; }
.rkc-input:focus{ white-space:pre-wrap; overflow:auto; }

/* ---- Mobile: full-screen sheet ---- */
@media (max-width:560px){
  .rkc-panel{ top:8px; left:8px; right:8px; bottom:8px; width:auto; max-width:none; height:auto; max-height:none; border-radius:16px; }
  .rkc-msg{ max-width:90%; }
  .rkc-launch{ right:14px; bottom:14px; }
}

@media (prefers-reduced-motion: reduce){
  .rkc-launch, .rkc-panel, .rkc-dot, .rkc-typing i{ transition:none !important; animation:none !important; }
}
