/* ═══════════════════════════════════════════════════════════════════
   SQLMentor Chat Widget — standalone stylesheet
   Include on any page: <link rel="stylesheet" href="css/chatbot.css">
   ═══════════════════════════════════════════════════════════════════ */

/* ── Container ───────────────────────────────────────────────────── */
.chat-widget {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  font-family: 'DM Sans', sans-serif;
}

/* ── Toggle button ────────────────────────────────────────────────── */
.chat-toggle {
  height: 52px;
  padding: 0 22px 0 16px;
  border-radius: 99px;
  background: linear-gradient(135deg, #d4a017, #b8860b);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 22px;
  box-shadow: 0 4px 24px rgba(212,160,23,0.5), 0 0 0 0 rgba(212,160,23,0.4);
  transition: transform .2s, box-shadow .2s;
  position: relative;
  animation: chatPulse 2.8s ease-in-out infinite;
}
.chat-toggle:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 32px rgba(212,160,23,0.65);
  animation: none;
}
.chat-toggle-icon { line-height: 1; flex-shrink: 0; }
.chat-toggle-text {
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: #0d0d1a;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
@keyframes chatPulse {
  0%   { box-shadow: 0 4px 24px rgba(212,160,23,0.5), 0 0 0 0 rgba(212,160,23,0.45); }
  60%  { box-shadow: 0 4px 24px rgba(212,160,23,0.5), 0 0 0 14px rgba(212,160,23,0); }
  100% { box-shadow: 0 4px 24px rgba(212,160,23,0.5), 0 0 0 0 rgba(212,160,23,0); }
}
.chat-toggle .chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  background: #4ade80;
  border-radius: 50%;
  border: 2px solid #0d0d1a;
  display: none;
}
.chat-toggle .chat-badge.show { display: block; }

/* ── Window ───────────────────────────────────────────────────────── */
.chat-window {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 390px;
  height: 545px;
  background: #111125;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 70px rgba(0,0,0,0.65);
  transform: scale(0.85) translateY(16px);
  transform-origin: bottom right;
  opacity: 0;
  pointer-events: none;
  transition: transform .25s ease, opacity .25s ease;
}
.chat-window.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}
@media (max-width: 480px) {
  .chat-window { width: calc(100vw - 24px); right: -8px; height: 76vh; bottom: 66px; }
  .chat-widget { bottom: 20px; right: 12px; }
  .chat-toggle { height: 46px; padding: 0 16px 0 12px; font-size: 18px; gap: 7px; }
  .chat-toggle-text { font-size: 13px; }
  .chat-chip { font-size: 11px; padding: 5px 10px; }
  .chat-bubble { font-size: 13px; padding: 9px 12px; }
  .chat-input { font-size: 13px; }
}
@media (max-width: 360px) {
  .chat-window { width: calc(100vw - 16px); right: -4px; height: 80vh; }
  .chat-widget { bottom: 16px; right: 8px; }
  .chat-suggestions { gap: 5px; padding: 0 10px 8px; }
}

/* ── Header ───────────────────────────────────────────────────────── */
.chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #1c1c38, #14142a);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}
.chat-head-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #d4a017, #b8860b);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.chat-head-info { flex: 1; line-height: 1.3; }
.chat-head-name  { font-weight: 600; font-size: 14px; color: #e8e8f0; }
.chat-head-sub {
  font-size: 11px;
  color: #8888aa;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}
.chat-online-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  flex-shrink: 0;
}
.chat-head-close {
  background: none;
  border: none;
  color: #8888aa;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 6px;
  transition: color .2s, background .2s;
}
.chat-head-close:hover { color: #e8e8f0; background: rgba(255,255,255,0.07); }

/* ── Messages area ────────────────────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

/* ── Message row ──────────────────────────────────────────────────── */
.chat-msg {
  display: flex;
  gap: 8px;
  animation: chatMsgIn .2s ease;
}
@keyframes chatMsgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-msg.user { flex-direction: row-reverse; }
.chat-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #d4a017, #b8860b);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 2px;
}
.chat-msg.user .chat-msg-avatar { background: linear-gradient(135deg, #4a4a7a, #2a2a5a); }
.chat-msg-body { max-width: 82%; display: flex; flex-direction: column; gap: 6px; }
.chat-msg.user .chat-msg-body { align-items: flex-end; }

/* ── Bubble ───────────────────────────────────────────────────────── */
.chat-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
}
.chat-msg.bot  .chat-bubble {
  background: #1c1c3a;
  color: #e0e0ee;
  border-radius: 4px 14px 14px 14px;
}
.chat-msg.user .chat-bubble {
  background: linear-gradient(135deg, #d4a017, #b8860b);
  color: #000;
  font-weight: 500;
  border-radius: 14px 4px 14px 14px;
}

/* ── Code blocks ──────────────────────────────────────────────────── */
.chat-bubble .chat-code-wrap {
  margin: 10px 0 4px;
  border-radius: 10px;
  overflow: hidden;
  background: #0d0d1a;
  border: 1px solid rgba(255,255,255,0.1);
}
.chat-bubble .chat-code-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background: #0a0a16;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.chat-bubble .chat-code-lang {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: #d4a017;
  font-weight: 600;
  letter-spacing: .06em;
}
.chat-bubble .chat-copy-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.12);
  color: #8888aa;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.chat-bubble .chat-copy-btn:hover { color: #e8e8f0; border-color: rgba(255,255,255,0.3); }
.chat-bubble pre {
  margin: 0;
  padding: 12px;
  overflow-x: auto;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12.5px;
  line-height: 1.55;
  color: #c8d3f5;
}
.chat-bubble pre::-webkit-scrollbar { height: 3px; }
.chat-bubble pre::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); }
.chat-bubble .chat-inline-code {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  background: rgba(255,255,255,0.08);
  padding: 1px 6px;
  border-radius: 4px;
  color: #c8d3f5;
}

/* ── Query results ────────────────────────────────────────────────── */
.chat-results {
  margin-top: 10px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.1);
}
.chat-results-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(74,222,128,0.1);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: #4ade80;
  font-weight: 600;
}
.chat-results-scroll { overflow-x: auto; max-height: 200px; overflow-y: auto; }
.chat-results-scroll::-webkit-scrollbar { height: 3px; width: 3px; }
.chat-results-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); }
.chat-results-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.chat-results-table th {
  padding: 7px 10px;
  text-align: left;
  background: rgba(255,255,255,0.04);
  color: #8888aa;
  font-weight: 600;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  white-space: nowrap;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.chat-results-table td {
  padding: 6px 10px;
  color: #e0e0ee;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  white-space: nowrap;
  font-family: 'IBM Plex Mono', monospace;
}
.chat-results-table tr:last-child td { border-bottom: none; }
.chat-results-table tr:hover td { background: rgba(255,255,255,0.02); }
.chat-query-error {
  margin-top: 8px;
  padding: 10px 12px;
  background: rgba(248,113,113,0.1);
  border: 1px solid rgba(248,113,113,0.2);
  border-radius: 8px;
  font-size: 12.5px;
  color: #f87171;
}

/* ── Typing indicator ─────────────────────────────────────────────── */
.chat-typing .chat-bubble {
  padding: 12px 16px;
  display: flex;
  gap: 5px;
  align-items: center;
}
.chat-typing-dot {
  width: 7px;
  height: 7px;
  background: #8888aa;
  border-radius: 50%;
  animation: chatBounce 1.2s infinite;
}
.chat-typing-dot:nth-child(2) { animation-delay: .2s; }
.chat-typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes chatBounce {
  0%,80%,100% { transform: translateY(0); }
  40%         { transform: translateY(-6px); }
}

/* ── Suggestion chips ─────────────────────────────────────────────── */
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 0 14px 10px;
}
.chat-chip {
  font-size: 12px;
  padding: 5px 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 99px;
  cursor: pointer;
  color: #8888aa;
  font-family: 'DM Sans', sans-serif;
  transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap;
}
.chat-chip:hover {
  background: rgba(212,160,23,0.12);
  border-color: rgba(212,160,23,0.35);
  color: #d4a017;
}

/* ── Input bar ────────────────────────────────────────────────────── */
.chat-input-bar {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(255,255,255,0.07);
  background: #0f0f22;
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  color: #e8e8f0;
  font-size: 13.5px;
  font-family: 'DM Sans', sans-serif;
  padding: 9px 13px;
  outline: none;
  transition: border-color .2s;
}
.chat-input:focus { border-color: rgba(212,160,23,0.5); }
.chat-input::placeholder { color: #8888aa; }
.chat-send {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #d4a017, #b8860b);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  transition: opacity .2s, transform .15s;
}
.chat-send:hover:not(:disabled) { opacity: .85; transform: scale(1.05); }
.chat-send:disabled { opacity: .35; cursor: not-allowed; }
