/* chat.css — floating AI chat + support chat */
.chat-fab{
  /* FAB column: sits in the right-side vertical stack. */
  position:fixed;right:14px;bottom:144px;width:48px;height:48px;border-radius:50%;
  background:var(--cta-grad);color:#fff;
  display:grid;place-items:center;box-shadow:0 4px 16px rgba(0,89,186,.35);
  z-index:300;transition:transform .15s;
}
.chat-fab:hover{transform:scale(1.08)}
.chat-fab .ico{width:22px;height:22px}
.chat-panel{
  position:fixed;bottom:20px;right:20px;width:min(380px,calc(100vw - 30px));
  max-height:70vh;background:var(--surface);border:1px solid var(--border);
  border-radius:var(--radius-card);box-shadow:0 30px 60px rgba(15,23,42,.3);
  display:none;flex-direction:column;z-index:310;overflow:hidden;
}
.chat-panel.open{display:flex;animation:fadeIn .18s}
/* Hide the global TTS FAB when the chat panel is open so it doesn't
   overlap the chat messages area (bottom ~84px overlaps bottom:20px panel). */
body.chat-open #tts-toggle-fab{ display:none !important }
.chat-header{display:flex;justify-content:space-between;align-items:center;padding:12px 14px;border-bottom:1px solid var(--border);background:var(--surface2)}
.chat-header-title{font-weight:700;font-size:.95rem;color:var(--text);display:flex;align-items:center;gap:7px}
/* Agent avatar — always an ICON (never an image), colored by the picked hue. */
.chat-agent-av{
  width:30px;height:30px;border-radius:9px;flex:none;display:grid;place-items:center;color:#fff;
  background:linear-gradient(135deg,hsl(var(--av-hue,258) 76% 56%),hsl(calc(var(--av-hue,258) + 42) 72% 44%));
  box-shadow:0 2px 9px hsl(var(--av-hue,258) 70% 45% / .45);
  transition:transform .2s ease;animation:agentBeat 4s ease-in-out infinite;
}
.chat-agent-av:hover{transform:scale(1.1) rotate(-4deg)}
.chat-agent-av .ico{width:18px;height:18px}
@keyframes agentBeat{
  0%,70%,100%{transform:scale(1)}
  75%{transform:scale(1.12)}
  80%{transform:scale(1.02)}
  85%{transform:scale(1.09)}
  90%{transform:scale(1)}
}
@media (prefers-reduced-motion: reduce){ .chat-agent-av{animation:none} }

/* ---- messaging-style rows: avatar + name on both sides ---- */
.chat-row{display:flex;gap:7px;align-items:flex-end;max-width:100%;animation:itemIn var(--dur-base,220ms) var(--ease-decel,cubic-bezier(.2,.8,.3,1))}
.chat-row.user{align-self:flex-end}
.chat-row.ai,.chat-row.admin{align-self:flex-start}
.chat-col{display:flex;flex-direction:column;gap:3px;min-width:0;max-width:78%}
.chat-row.user .chat-col{align-items:flex-end}
.chat-who{font-size:.66rem;font-weight:700;color:var(--text3);padding:0 5px;letter-spacing:.02em}
.chat-av{
  width:26px;height:26px;border-radius:50%;flex:none;display:grid;place-items:center;overflow:hidden;
  background:var(--surface2);border:1px solid var(--border);font-size:.7rem;font-weight:800;color:#fff;
}
.chat-av .ico{width:15px;height:15px}
.chat-av img{width:100%;height:100%;object-fit:cover}
.chat-av-agent{
  background:linear-gradient(135deg,hsl(var(--av-hue,258) 78% 58%),hsl(calc(var(--av-hue,258) + 42) 72% 46%));
  border-color:transparent;box-shadow:0 1px 5px hsl(var(--av-hue,258) 70% 45% / .4);
}
.chat-av-support{background:linear-gradient(135deg,#0ea5e9,#2563eb);border-color:transparent}
.chat-av-user{background:linear-gradient(135deg,var(--accent,#6366f1),#2563eb);border-color:transparent}
.chat-row .chat-msg{max-width:100%}

/* ---- bubble styles (Bot settings → Chat bubble style) ---- */
.chat-panel[data-bubble="rounded"] .chat-msg{border-radius:18px}
.chat-panel[data-bubble="rounded"] .chat-msg.user{border-bottom-right-radius:5px}
.chat-panel[data-bubble="rounded"] .chat-msg.ai,
.chat-panel[data-bubble="rounded"] .chat-msg.admin{border-bottom-left-radius:5px}
.chat-panel[data-bubble="square"] .chat-msg{border-radius:4px}
.chat-panel[data-bubble="outline"] .chat-msg{background:transparent;border:1.5px solid var(--border)}
.chat-panel[data-bubble="outline"] .chat-msg.user{border-color:var(--accent)}
.chat-panel[data-bubble="outline"] .chat-msg.ai,
.chat-panel[data-bubble="outline"] .chat-msg.admin{border-color:hsl(258 75% 55% / .55)}

/* ---- Bot settings menu (name / avatar icon / color / bubble) ---- */
.agent-setup-modal{width:min(430px,94vw);max-height:88vh;display:flex;flex-direction:column}
.agent-setup-body{padding:16px 18px;overflow-y:auto;display:flex;flex-direction:column;gap:15px}
.agent-preview{display:flex;gap:12px;align-items:center;padding:12px;border-radius:12px;background:var(--surface2);border:1px solid var(--border)}
.agent-preview .chat-av{width:44px;height:44px}
.agent-preview .chat-av .ico{width:22px;height:22px}
.agent-preview-name{font-weight:800;font-size:1rem;color:var(--text)}
.agent-field-label{font-size:.78rem;font-weight:700;color:var(--text2);margin-bottom:7px}
.agent-input{
  width:100%;padding:9px 12px;border-radius:10px;border:1px solid var(--border);
  background:var(--surface);color:var(--text);font-size:.9rem;outline:none;transition:border-color .15s;
}
.agent-input:focus{border-color:var(--accent)}
.agent-icon-grid{display:grid;grid-template-columns:repeat(6,1fr);gap:7px}
.agent-icon{
  aspect-ratio:1;border-radius:10px;border:1.5px solid var(--border);background:var(--surface2);
  color:var(--text2);display:grid;place-items:center;cursor:pointer;transition:transform .15s,border-color .15s,color .15s;
}
.agent-icon .ico{width:18px;height:18px}
.agent-icon:hover{border-color:var(--accent);transform:translateY(-2px)}
.agent-icon.active{border-color:var(--accent);background:var(--accent-soft,rgba(99,102,241,.14));color:var(--accent)}
.agent-hue-row{display:flex;gap:9px;flex-wrap:wrap}
.agent-hue{
  width:26px;height:26px;border-radius:50%;border:2px solid transparent;cursor:pointer;
  background:hsl(var(--h) 75% 55%);transition:transform .15s,border-color .15s;
}
.agent-hue:hover{transform:scale(1.12)}
.agent-hue.active{border-color:var(--text);transform:scale(1.18)}
.agent-style-row{display:grid;grid-template-columns:repeat(4,1fr);gap:7px}
.agent-style{
  display:flex;flex-direction:column;align-items:center;gap:6px;padding:9px 4px;border-radius:10px;
  border:1.5px solid var(--border);background:var(--surface2);color:var(--text2);
  font-size:.66rem;font-weight:700;cursor:pointer;transition:border-color .15s,color .15s,background .15s;
}
.agent-style.active{border-color:var(--accent);color:var(--accent);background:var(--accent-soft,rgba(99,102,241,.12))}
.agent-bubble-demo{width:34px;height:16px;background:var(--accent);opacity:.85}
.agent-bubble-demo.d-soft{border-radius:7px}
.agent-bubble-demo.d-rounded{border-radius:8px 8px 8px 2px}
.agent-bubble-demo.d-square{border-radius:2px}
.agent-bubble-demo.d-outline{background:transparent;border:2px solid var(--accent);opacity:1}
@media (max-width:420px){
  .agent-icon-grid{grid-template-columns:repeat(4,1fr)}
  .agent-style-row{grid-template-columns:repeat(2,1fr)}
}

.chat-tabs{display:flex;gap:4px;padding:8px;background:var(--surface2);border-bottom:1px solid var(--border)}
.chat-tab{flex:1;padding:6px;border-radius:8px;font-size:.75rem;font-weight:700;color:var(--text2);background:transparent;transition:background .15s,color .15s}
.chat-tab.active{background:var(--surface);color:var(--accent);box-shadow:0 4px 8px rgba(15,23,42,.06)}
.chat-messages{flex:1;overflow-y:auto;padding:12px;display:flex;flex-direction:column;gap:8px}
.chat-msg{padding:8px 12px;border-radius:var(--radius-control);max-width:85%;font-size:.86rem;line-height:1.5;word-wrap:break-word;animation:itemIn var(--dur-base) var(--ease-decel)}
.chat-msg.user{background:var(--chat-user);align-self:flex-end;color:var(--text)}
.chat-msg.ai{background:var(--chat-ai);align-self:flex-start;color:var(--text)}
.chat-msg.system{background:var(--surface2);color:var(--text3);font-size:.78rem;text-align:center;align-self:center;border:1px dashed var(--border)}
.chat-msg.admin{background:linear-gradient(135deg,rgba(0,89,186,.12),rgba(0,89,186,.08));align-self:flex-start;border-left:3px solid var(--accent3)}
.ai-label{font-size:.7rem;color:var(--accent2);font-weight:700;margin-bottom:3px;display:flex;align-items:center;gap:4px}
.chat-input-area{display:flex;gap:6px;padding:10px;border-top:1px solid var(--border);background:var(--surface2)}
.chat-input{flex:1;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-control);padding:8px 12px;font-size:.88rem;color:var(--text);outline:none;transition:border-color .15s}
.chat-input:focus{border-color:var(--accent)}
.chat-send{
  width:38px;height:38px;border-radius:50%;
  background:var(--cta-grad);color:#fff;
  display:grid;place-items:center;transition:transform .15s;
}
.chat-send:hover{transform:scale(1.05)}
.chat-send .ico{width:18px;height:18px}
.chat-send:disabled{opacity:.5;pointer-events:none}

/* Command dropdown (/ commands) */
.command-dropdown{animation:fadeIn .15s}
.command-item:hover{background:var(--bg-hover, #f0f7ff)}
.command-item:active{background:var(--bg-active, #e0ecff)}

/* Mention dropdown (@ mentions) */
.mention-dropdown{animation:fadeIn .15s}
.mention-item:hover{background:var(--bg-hover, #f0f7ff)}
.mention-item:active{background:var(--bg-active, #e0ecff)}

@keyframes fadeIn{
  from{opacity:0;transform:translateY(4px)}
  to{opacity:1;transform:translateY(0)}
}
