/* ── MSK AI Chat Widget ─────────────────────────────── */

#ai-chat-widget {
  position: fixed;
  bottom: 96px;
  right: 24px;
  z-index: 9000;
  font-family: var(--sans, 'Space Grotesk', sans-serif);
  --ai-accent: var(--accent, #c8e21f);
}

/* ── Toggle Button ── */
#ai-chat-toggle {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--ai-accent, var(--accent, #c8e21f));
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 21px;
  color: #111;
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  outline: none;
}
#ai-chat-toggle:hover {
  transform: scale(1.1) translateY(-2px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}
#ai-chat-toggle:focus-visible {
  outline: 2px solid var(--accent, #c8e21f);
  outline-offset: 3px;
}

.ai-chat-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  background: #e63946;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 8px;
  font-family: var(--mono, 'JetBrains Mono', monospace);
  letter-spacing: 0.3px;
  line-height: 1.2;
  pointer-events: none;
}

/* ── Chat Window ── */
#ai-chat-window {
  position: absolute;
  bottom: 66px;
  right: 0;
  width: 358px;
  height: 520px;
  background: var(--surface, #161616);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 18px;
  box-shadow: 0 16px 56px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  animation: ai-chat-appear 0.22s cubic-bezier(0.34, 1.46, 0.64, 1);
}
@keyframes ai-chat-appear {
  from { opacity: 0; transform: scale(0.88) translateY(12px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

/* ── Header ── */
#ai-chat-header {
  padding: 14px 16px 13px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  background: var(--surface, #161616);
}
.ai-chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ai-chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent, #c8e21f) 0%, rgba(200, 226, 31, 0.35) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #111;
  flex-shrink: 0;
}
.ai-chat-name-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ai-chat-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text, #f0f0f0);
  line-height: 1.2;
  letter-spacing: 0.1px;
}
.ai-chat-status {
  font-size: 11px;
  color: var(--muted, #666);
  font-family: var(--mono, 'JetBrains Mono', monospace);
  display: flex;
  align-items: center;
  gap: 5px;
}
.ai-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade80;
  display: inline-block;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.25);
}
#ai-chat-close {
  background: none;
  border: none;
  color: var(--muted, #555);
  cursor: pointer;
  font-size: 15px;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.18s, background 0.18s;
  flex-shrink: 0;
}
#ai-chat-close:hover {
  color: var(--text, #f0f0f0);
  background: rgba(255, 255, 255, 0.07);
}

/* ── Messages ── */
#ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}
#ai-chat-messages::-webkit-scrollbar { width: 3px; }
#ai-chat-messages::-webkit-scrollbar-track { background: transparent; }
#ai-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
}

.ai-msg {
  display: flex;
  max-width: 87%;
}
.ai-msg-user  { align-self: flex-end; }
.ai-msg-bot   { align-self: flex-start; }

.ai-msg-bubble {
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.6;
  word-break: break-word;
}
.ai-msg-user .ai-msg-bubble {
  background: var(--accent, #c8e21f);
  color: #111;
  border-bottom-right-radius: 4px;
  font-weight: 500;
}
.ai-msg-bot .ai-msg-bubble {
  background: rgba(255, 255, 255, 0.055);
  color: var(--text, #e2e2e2);
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.055);
}

/* ── Typing Indicator ── */
#ai-chat-typing {
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  height: 30px;
}
.ai-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted, #555);
  animation: ai-bounce 1.35s ease-in-out infinite;
}
.ai-typing-dot:nth-child(2) { animation-delay: 0.18s; }
.ai-typing-dot:nth-child(3) { animation-delay: 0.36s; }
@keyframes ai-bounce {
  0%, 80%, 100% { transform: scale(0.65); opacity: 0.4; }
  40%           { transform: scale(1);    opacity: 1; }
}

/* ── Input Area ── */
#ai-chat-input-area {
  padding: 11px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}
#ai-chat-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 22px;
  padding: 9px 14px;
  font-size: 13.5px;
  color: var(--text, #e2e2e2);
  font-family: var(--sans, 'Space Grotesk', sans-serif);
  outline: none;
  transition: border-color 0.2s;
  min-width: 0;
}
#ai-chat-input:focus { border-color: var(--accent, #c8e21f); }
#ai-chat-input::placeholder { color: var(--muted, #555); }
#ai-chat-input:disabled { opacity: 0.45; cursor: not-allowed; }

#ai-chat-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent, #c8e21f);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #111;
  flex-shrink: 0;
  transition: opacity 0.2s, transform 0.15s;
}
#ai-chat-send:hover:not(:disabled) { transform: scale(1.1); }
#ai-chat-send:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }

/* ── Light Mode ── */
:root.light #ai-chat-toggle {
  background: var(--blue, #007bff);
  color: #fff;
  box-shadow: 0 4px 24px rgba(0, 123, 255, 0.35);
}
:root.light #ai-chat-toggle:hover {
  box-shadow: 0 8px 32px rgba(0, 123, 255, 0.5);
}
:root.light #ai-chat-window {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 16px 56px rgba(0, 0, 0, 0.14);
}
:root.light #ai-chat-header {
  background: #f7f8fa;
  border-bottom-color: rgba(0, 0, 0, 0.08);
}
:root.light .ai-chat-title  { color: #111; }
:root.light .ai-chat-status { color: #888; }
:root.light #ai-chat-close  { color: #999; }
:root.light #ai-chat-close:hover { color: #333; background: rgba(0,0,0,0.06); }
:root.light #ai-chat-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); }
:root.light .ai-msg-user .ai-msg-bubble { background: var(--blue,#007bff); color:#fff; }
:root.light .ai-msg-bot  .ai-msg-bubble { background: #f0f2f5; color:#1a1a1a; border-color:rgba(0,0,0,0.07); }
:root.light .ai-typing-dot { background: #bbb; }
:root.light #ai-chat-input-area { border-top-color: rgba(0,0,0,0.08); }
:root.light #ai-chat-input {
  background: #fff;
  border-color: rgba(0,0,0,0.14);
  color: #1a1a1a;
}
:root.light #ai-chat-input:focus { border-color: var(--blue,#007bff); }
:root.light #ai-chat-input::placeholder { color: #aaa; }
:root.light #ai-chat-send { background: var(--blue,#007bff); color:#fff; }
:root.light .ai-chat-avatar {
  background: linear-gradient(135deg, var(--blue,#007bff) 0%, rgba(0,123,255,0.35) 100%);
  color: #fff;
}

/* ── Suggested Questions ── */
#ai-sq-chips {
  padding: 8px 0 4px;
  display: flex;
  flex-direction: column;
}
.ai-sq-chip {
  display: block;
  width: 100%;
  text-align: left;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-left: 3px solid var(--ai-accent, var(--accent, #c8e21f));
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 12.5px;
  color: var(--text, #e2e2e2);
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s;
  margin-bottom: 5px;
  font-family: var(--sans, 'Space Grotesk', sans-serif);
  line-height: 1.4;
}
.ai-sq-chip:hover {
  background: rgba(255, 255, 255, 0.08);
}
:root.light .ai-sq-chip {
  background: #f5f5f5;
  border-color: rgba(0, 0, 0, 0.1);
  border-left-color: var(--ai-accent, var(--blue, #007bff));
  color: #1a1a1a;
}
:root.light .ai-sq-chip:hover {
  background: #eee;
}

/* ── Mobile ── */
@media (max-width: 500px) {
  #ai-chat-widget { bottom: 140px; right: 14px; }
  #ai-chat-window {
    width: calc(100vw - 28px);
    right: -14px;
    height: 440px;
    border-radius: 14px;
  }
}
