/* "Ask Hakim's AI" chat bubble — js/chat.js */
.chat-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 140;
  display: inline-flex; align-items: center; gap: 10px; padding: 12px 18px 12px 14px;
  font: 600 14px "Space Grotesk", system-ui, sans-serif; color: #fff; cursor: pointer;
  border: 1px solid rgba(255,45,85,.55); border-radius: 999px;
  background: linear-gradient(135deg, rgba(255,45,85,.95), rgba(255,122,69,.92));
  box-shadow: 0 18px 50px -14px rgba(255,45,85,.7), inset 0 1px 0 rgba(255,255,255,.25);
  opacity: 0; transform: translateY(16px) scale(.96); transition: opacity .35s, transform .35s, box-shadow .2s;
}
.chat-fab.in { opacity: 1; transform: none; }
.chat-fab:hover { box-shadow: 0 22px 60px -12px rgba(255,45,85,.85), inset 0 1px 0 rgba(255,255,255,.3); }
.chat-fab:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.chat-fab-dot { width: 9px; height: 9px; border-radius: 50%; background: #3dff9a; box-shadow: 0 0 0 0 rgba(61,255,154,.7); animation: chatPulse 2.2s infinite; }
.chat-fab-ico { font-size: 15px; }
.chat-fab.on .chat-fab-txt::after { content: " ×"; }
@keyframes chatPulse { 70% { box-shadow: 0 0 0 9px rgba(61,255,154,0); } 100% { box-shadow: 0 0 0 0 rgba(61,255,154,0); } }

.chat-panel {
  position: fixed; right: 22px; bottom: 84px; z-index: 141; width: min(390px, calc(100vw - 32px)); height: min(580px, calc(100vh - 120px));
  display: flex; flex-direction: column; overflow: hidden;
  border-radius: 20px; border: 1px solid rgba(255,255,255,.12);
  background: rgba(12,13,18,.94); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 40px 120px -30px rgba(0,0,0,.9), 0 0 0 1px rgba(255,45,85,.12);
  color: #e9ecf2; font: 14px/1.5 "Space Grotesk", system-ui, sans-serif;
  animation: chatIn .28s cubic-bezier(.2,.8,.2,1);
}
.chat-panel[hidden] { display: none; }
@keyframes chatIn { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid rgba(255,255,255,.08); background: linear-gradient(180deg, rgba(255,45,85,.12), transparent); }
.chat-ava { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; object-position: 50% 20%; box-shadow: 0 0 0 2px rgba(255,45,85,.6); }
.chat-head div { flex: 1; min-width: 0; display: grid; }
.chat-name { font-size: 15px; }
.chat-sub { font: 11px "JetBrains Mono", monospace; color: #9aa1ad; display: flex; align-items: center; gap: 6px; }
.chat-sub i { width: 6px; height: 6px; border-radius: 50%; background: #3dff9a; }
.chat-x { width: 32px; height: 32px; border-radius: 9px; border: 1px solid rgba(255,255,255,.12); background: transparent; color: #9aa1ad; cursor: pointer; }
.chat-x:hover { color: #fff; }

.chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.chat-msg { max-width: 86%; padding: 10px 13px; border-radius: 14px; font-size: 14px; overflow-wrap: anywhere; }
.chat-msg.bot { align-self: flex-start; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.07); border-bottom-left-radius: 5px; }
.chat-msg.me { align-self: flex-end; background: linear-gradient(135deg, #ff2d55, #ff5a3c); color: #fff; border-bottom-right-radius: 5px; white-space: pre-wrap; }
.chat-msg p { margin: 0; }
.chat-msg p + p, .chat-msg p + ul, .chat-msg ul + p { margin-top: 7px; }
.chat-msg ul { margin: 4px 0 0; padding-left: 18px; }
.chat-msg li { margin: 2px 0; }
.chat-msg li::marker { color: #ff2d55; }
.chat-msg b { color: #fff; }
.chat-msg a { color: #ff8aa1; text-decoration: underline; text-underline-offset: 2px; }
.chat-msg.typing { display: flex; gap: 5px; padding: 14px; }
.chat-msg.typing i { width: 7px; height: 7px; border-radius: 50%; background: #9aa1ad; animation: chatDot 1s infinite; }
.chat-msg.typing i:nth-child(2) { animation-delay: .15s; }
.chat-msg.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes chatDot { 50% { opacity: .25; transform: translateY(-3px); } }

.chat-sugg { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; }
.chat-sugg:empty { display: none; }
.chat-chip { font: 500 12.5px "Space Grotesk", sans-serif; color: #ffd0da; background: rgba(255,45,85,.1); border: 1px solid rgba(255,45,85,.4); border-radius: 999px; padding: 6px 11px; cursor: pointer; text-align: left; }
.chat-chip:hover { background: rgba(255,45,85,.2); color: #fff; }
.chat-form { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px; border-top: 1px solid rgba(255,255,255,.08); }
.chat-form textarea { flex: 1; resize: none; overflow-y: auto; scrollbar-width: none; max-height: 120px; font: 14px/1.45 "Space Grotesk", sans-serif; color: #fff; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.12); border-radius: 12px; padding: 10px 12px; }
.chat-form textarea:focus { outline: none; border-color: rgba(255,45,85,.6); }
.chat-send { flex: none; width: 42px; height: 42px; border-radius: 12px; border: 0; background: #ff2d55; color: #fff; font-size: 16px; cursor: pointer; }
.chat-send:hover { background: #ff4a6c; }
.chat-note { margin: 0; padding: 0 14px 10px; font: 10.5px/1.4 "JetBrains Mono", monospace; color: #646b78; }

@media (max-width: 560px) {
  .chat-fab { right: 14px; bottom: 14px; padding: 11px 15px 11px 12px; }
  .chat-panel { right: 8px; left: 8px; bottom: 74px; width: auto; height: calc(100dvh - 92px); }
}
@media (prefers-reduced-motion: reduce) { .chat-fab, .chat-panel, .chat-fab-dot { animation: none; transition: none; } }
@media print { .chat-fab, .chat-panel { display: none !important; } }
html.arcade-fs .chat-fab, html.arcade-fs .chat-panel { display: none !important; }
