/* ═══════════════════════════════════════════════════════════════
   GOD MODE CHAT — MemeHouse AI Assistant
   ═══════════════════════════════════════════════════════════════ */

/* ── Floating Action Button ─────────────────────────────────────── */
#chat-bubble-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

#chat-fab {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #C9A84C;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(201,168,76,0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  flex-shrink: 0;
}
#chat-fab:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(201,168,76,0.55); }
#chat-fab.active { background: #111; box-shadow: 0 4px 20px rgba(0,0,0,0.5); }
.chat-fab-icon { font-size: 20px; line-height: 1; }
.chat-fab-pulse {
  position: absolute;
  top: -2px; right: -2px;
  width: 10px; height: 10px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid #0a0a0a;
  animation: chatPulse 2s ease-in-out infinite;
}
@keyframes chatPulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.2); }
}

/* ── Chat Panel (bubble) ─────────────────────────────────────────── */
#chat-panel {
  width: 420px;
  height: 560px;
  background: #111;
  border: 1px solid #222;
  border-radius: 16px;
  display: none;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.7);
  transform: translateY(12px) scale(0.97);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
}
#chat-panel.open {
  display: flex;
  opacity: 1;
  transform: translateY(0) scale(1);
}

.chat-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid #1e1e1e;
  background: #0d0d0d;
  flex-shrink: 0;
}
.chat-panel-title {
  font-size: 13px;
  font-weight: 600;
  color: #C9A84C;
  letter-spacing: 0.02em;
}
.chat-panel-header-right { display: flex; gap: 4px; }
.chat-header-btn {
  width: 26px; height: 26px;
  border-radius: 6px;
  border: none;
  background: #1a1a1a;
  color: #888;
  cursor: pointer;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.chat-header-btn:hover { background: #252525; color: #ccc; }

.chat-panel-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar (conversation list) ────────────────────────────────── */
.chat-panel-sidebar {
  width: 140px;
  border-right: 1px solid #1a1a1a;
  overflow-y: auto;
  padding: 8px 0;
  flex-shrink: 0;
}
.chat-panel-sidebar::-webkit-scrollbar { width: 3px; }
.chat-panel-sidebar::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 2px; }

.chat-sidebar-list { display: flex; flex-direction: column; gap: 1px; padding: 0 6px; }
.chat-sidebar-item {
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  position: relative;
  transition: background 0.15s;
}
.chat-sidebar-item:hover { background: #1a1a1a; }
.chat-sidebar-item.active { background: #1e1a10; border: 1px solid #2e2510; }
.chat-sidebar-title {
  font-size: 11px;
  color: #bbb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}
.chat-sidebar-item.active .chat-sidebar-title { color: #C9A84C; }
.chat-sidebar-meta { font-size: 10px; color: #555; margin-top: 2px; }
.chat-sidebar-delete {
  position: absolute;
  top: 4px; right: 4px;
  width: 16px; height: 16px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: #555;
  cursor: pointer;
  font-size: 12px;
  display: none;
  align-items: center; justify-content: center;
}
.chat-sidebar-item:hover .chat-sidebar-delete { display: flex; }
.chat-sidebar-delete:hover { background: #3a1a1a; color: #ff6b6b; }
.chat-sidebar-empty { font-size: 11px; color: #444; padding: 12px 8px; text-align: center; }

/* ── Main chat area ──────────────────────────────────────────────── */
.chat-panel-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 2px; }

/* ── Welcome screen ─────────────────────────────────────────────── */
.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 20px;
}
.chat-welcome-icon { font-size: 32px; margin-bottom: 10px; }
.chat-welcome-title { font-size: 15px; font-weight: 600; color: #C9A84C; margin-bottom: 6px; }
.chat-welcome-sub { font-size: 12px; color: #555; margin-bottom: 16px; }
.chat-welcome-hints { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.chat-welcome-hints span {
  padding: 7px 10px;
  background: #1a1a1a;
  border: 1px solid #222;
  border-radius: 8px;
  font-size: 11px;
  color: #888;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
.chat-welcome-hints span:hover { background: #222; color: #C9A84C; }

/* ── Message bubbles ────────────────────────────────────────────── */
.chat-msg {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.chat-msg.user { flex-direction: row-reverse; }

.chat-msg-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}
.chat-msg.user .chat-msg-avatar { background: #C9A84C; color: #000; }
.chat-msg.assistant .chat-msg-avatar { background: #1a1a1a; color: #C9A84C; font-size: 14px; }

.chat-msg-body { max-width: 80%; display: flex; flex-direction: column; gap: 4px; }
.chat-msg.user .chat-msg-body { align-items: flex-end; }

.chat-msg-content {
  padding: 8px 11px;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.55;
  word-break: break-word;
}
.chat-msg.user .chat-msg-content {
  background: #C9A84C;
  color: #000;
  border-bottom-right-radius: 4px;
  font-weight: 500;
}
.chat-msg.assistant .chat-msg-content {
  background: #161616;
  color: #ddd;
  border: 1px solid #1e1e1e;
  border-bottom-left-radius: 4px;
}

.chat-msg-meta { font-size: 10px; color: #444; padding: 0 4px; }
.chat-cursor { animation: blink 1s step-end infinite; color: #C9A84C; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }

/* ── Code blocks ────────────────────────────────────────────────── */
.chat-code {
  background: #0a0a0a;
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  padding: 8px;
  font-size: 11px;
  overflow-x: auto;
  white-space: pre;
  margin: 4px 0;
  color: #a8e6cf;
}
.chat-inline-code {
  background: #1a1a1a;
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 11px;
  color: #C9A84C;
  font-family: monospace;
}

/* ── Dispatch badge ─────────────────────────────────────────────── */
.chat-dispatch-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: #1a1a10;
  border: 1px solid #2e2510;
  border-radius: 8px;
  font-size: 11px;
  color: #C9A84C;
  margin-top: 4px;
}
.chat-task-pill {
  background: #C9A84C;
  color: #000;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  font-family: monospace;
}
.chat-task-pill:hover { background: #e0c06a; }

/* ── Notification toast ─────────────────────────────────────────── */
.chat-notif {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #1a1a10;
  border: 1px solid #2e2510;
  border-radius: 10px;
  font-size: 12px;
  color: #C9A84C;
  animation: notifSlide 0.3s ease;
  pointer-events: auto;
}
@keyframes notifSlide { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ── Input bar ──────────────────────────────────────────────────── */
.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #1a1a1a;
  background: #0d0d0d;
  flex-shrink: 0;
}
.chat-textarea {
  flex: 1;
  background: #1a1a1a;
  border: 1px solid #252525;
  border-radius: 10px;
  color: #ddd;
  font-size: 12px;
  padding: 8px 11px;
  resize: none;
  outline: none;
  font-family: inherit;
  line-height: 1.4;
  max-height: 120px;
  overflow-y: auto;
  transition: border-color 0.15s;
}
.chat-textarea:focus { border-color: #C9A84C; }
.chat-textarea::placeholder { color: #444; }
.chat-send-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: none;
  background: #C9A84C;
  color: #000;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}
.chat-send-btn:hover { background: #ddb85a; transform: scale(1.05); }
.chat-send-btn:active { transform: scale(0.95); }

/* ═══════════════════════════════════════════════════════════════
   FULL PAGE CHAT
   ═══════════════════════════════════════════════════════════════ */
.chat-page {
  display: flex;
  height: calc(100vh - 56px);
  overflow: hidden;
}

.chat-page-sidebar {
  width: 220px;
  border-right: 1px solid #1a1a1a;
  display: flex;
  flex-direction: column;
  padding: 12px 8px;
  gap: 8px;
  flex-shrink: 0;
  overflow-y: auto;
}
.chat-new-btn {
  width: 100%;
  padding: 9px 14px;
  background: #1a1a1a;
  border: 1px solid #252525;
  border-radius: 8px;
  color: #ccc;
  cursor: pointer;
  font-size: 13px;
  text-align: left;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.chat-new-btn:hover { background: #222; color: #C9A84C; }

.chat-page-sidebar .chat-sidebar-list { padding: 0; }
.chat-page-sidebar .chat-sidebar-item { padding: 10px 10px; }
.chat-page-sidebar .chat-sidebar-title { font-size: 12px; }

.chat-page-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-messages-page {
  padding: 24px 32px;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}
.chat-messages-page .chat-msg-content { font-size: 14px; }
.chat-messages-page .chat-welcome-title { font-size: 22px; }
.chat-messages-page .chat-welcome-sub { font-size: 14px; }
.chat-messages-page .chat-welcome-hints span { font-size: 13px; padding: 10px 14px; }

.chat-page .chat-input-bar {
  padding: 14px 32px;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
  background: transparent;
  border-top: 1px solid #1a1a1a;
}
.chat-page .chat-textarea { font-size: 14px; padding: 10px 14px; }
.chat-page .chat-send-btn { width: 38px; height: 38px; }

/* Nav pulse dot */
.chat-nav-pulse {
  width: 6px; height: 6px;
  background: #22c55e;
  border-radius: 50%;
  margin-left: auto;
  animation: chatPulse 2s ease-in-out infinite;
  flex-shrink: 0;
}

/* ── Dept chat markdown rendering ───────────────────────────────── */
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3,
.msg-bubble h4, .msg-bubble h5, .msg-bubble h6 {
  color: var(--text-1, #f0f0f0);
  font-weight: 700;
  margin: 14px 0 6px;
  line-height: 1.3;
}
.msg-bubble h1 { font-size: 18px; }
.msg-bubble h2 { font-size: 15px; border-bottom: 1px solid rgba(255,255,255,0.08); padding-bottom: 6px; }
.msg-bubble h3 { font-size: 13px; color: #c9a84c; }
.msg-bubble p { margin: 6px 0; line-height: 1.65; }
.msg-bubble ul, .msg-bubble ol { padding-left: 18px; margin: 6px 0; }
.msg-bubble li { margin: 3px 0; line-height: 1.55; }
.msg-bubble strong { color: var(--text-1, #f0f0f0); font-weight: 700; }
.msg-bubble em { color: #a0a0a0; }
.msg-bubble code {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: #a8e6cf;
}
.msg-bubble pre {
  background: #0a0a0a;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 12px;
  overflow-x: auto;
  margin: 8px 0;
}
.msg-bubble pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  color: #a8e6cf;
}
.msg-bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 12px;
}
.msg-bubble th {
  background: rgba(201,168,76,0.12);
  color: #c9a84c;
  font-weight: 700;
  padding: 7px 10px;
  text-align: left;
  border: 1px solid rgba(255,255,255,0.08);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.msg-bubble td {
  padding: 6px 10px;
  border: 1px solid rgba(255,255,255,0.06);
  color: #ccc;
  vertical-align: top;
}
.msg-bubble tr:nth-child(even) td { background: rgba(255,255,255,0.02); }
.msg-bubble blockquote {
  border-left: 3px solid #c9a84c;
  margin: 8px 0;
  padding: 6px 12px;
  background: rgba(201,168,76,0.06);
  border-radius: 0 6px 6px 0;
  color: #aaa;
}
.msg-bubble hr {
  border: none;
  border-top: 1px solid rgba(255,255,255,0.08);
  margin: 12px 0;
}
/* ── In-chat artifact (HTML doc rendered inline) ─────────────── */
.chat-artifact-wrap {
  margin-top: 10px;
  border: 1px solid rgba(201,168,76,0.25);
  border-radius: 12px;
  overflow: hidden;
  background: #0d0d0d;
}
.chat-artifact-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(201,168,76,0.08);
  border-bottom: 1px solid rgba(201,168,76,0.2);
}
.chat-artifact-title {
  font-size: 11px;
  font-weight: 700;
  color: #c9a84c;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 6px;
}
.chat-artifact-actions {
  display: flex;
  gap: 6px;
}
.chat-artifact-btn {
  background: rgba(201,168,76,0.12);
  border: 1px solid rgba(201,168,76,0.3);
  color: #c9a84c;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font, 'Inter', sans-serif);
  transition: all 0.15s;
  letter-spacing: 0.04em;
}
.chat-artifact-btn:hover { background: rgba(201,168,76,0.25); }
.chat-artifact-iframe {
  width: 100%;
  height: 420px;
  border: none;
  display: block;
}
/* ── PDF download button on rich messages ─────────────────────── */
.msg-pdf-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 6px 14px;
  background: rgba(201,168,76,0.1);
  border: 1px solid rgba(201,168,76,0.3);
  border-radius: 8px;
  color: #c9a84c;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font, 'Inter', sans-serif);
  transition: all 0.15s;
  letter-spacing: 0.03em;
}
.msg-pdf-btn:hover { background: rgba(201,168,76,0.2); }

/* ── Download bar (every agent response) ── */
.msg-download-bar {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-wrap: wrap;
}
.msg-dl-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3, #888);
  cursor: pointer;
  font-family: var(--font, 'Inter', sans-serif);
  transition: all 0.15s;
  line-height: 1.4;
}
.msg-dl-btn:hover {
  background: rgba(100,180,255,0.1);
  border-color: rgba(100,180,255,0.3);
  color: rgba(100,180,255,0.9);
}
