/* ── Chatbot panel ────────────────────────────────────────────────────────── */

/* Variables for light/dark mode — inherits from main.css :root / [data-theme="dark"] */

#chatbot-tab {
  position: fixed;
  bottom: 0;
  right: 24px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px 8px 0 0;
  padding: 8px 18px;
  font-family: 'Montserrat', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  z-index: 900;
  box-shadow: 0 -2px 12px var(--shadow-sm);
  transition: background 0.15s;
}
#chatbot-tab:hover {
  background: var(--accent-hover);
}

#chatbot-panel {
  position: fixed;
  bottom: 0;
  right: 24px;
  width: 380px;
  height: 520px;
  min-width: 280px;
  min-height: 300px;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border-heavy);
  border-radius: 10px;
  box-shadow: 0 -4px 24px var(--shadow-md);
  z-index: 901;
  font-family: 'Montserrat', sans-serif;
  overflow: visible;
}

/* Resize handles */
.chatbot-resize-l {
  position: absolute;
  top: 0;
  left: -3px;
  width: 6px;
  height: 100%;
  cursor: ew-resize;
  z-index: 5;
}
.chatbot-resize-r {
  position: absolute;
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  cursor: ew-resize;
  z-index: 5;
}
.chatbot-resize-t {
  position: absolute;
  top: -3px;
  left: 0;
  width: 100%;
  height: 6px;
  cursor: ns-resize;
  z-index: 5;
}
.chatbot-resize-b {
  position: absolute;
  bottom: -3px;
  left: 0;
  width: 100%;
  height: 6px;
  cursor: ns-resize;
  z-index: 5;
}
#chatbot-panel.hidden {
  display: none;
}

/* Header */
.chatbot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  cursor: grab;
  flex-shrink: 0;
  user-select: none;
  position: relative;
}
.chatbot-header:active {
  cursor: grabbing;
}

/* Triode icon hover popup */
.chatbot-triode-icon {
  position: relative;
  display: inline-block;
}
.chatbot-triode-popup {
  display: none;
  position: absolute;
  bottom: calc(100% + 12px);
  left: -10px;
  width: 140px;
  height: 140px;
  background: var(--bg-surface);
  border: 1px solid var(--border-heavy);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 4px 20px var(--shadow-md);
  z-index: 30;
  cursor: pointer;
  object-fit: contain;
}
.chatbot-triode-icon:hover .chatbot-triode-popup {
  display: block;
}
.chatbot-header-title {
  font-size: 13px;
  font-weight: 600;
}
.chatbot-header-section {
  font-size: 10px;
  background: rgba(255,255,255,0.2);
  border-radius: 4px;
  padding: 2px 8px;
  margin-left: 8px;
}
.chatbot-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.chatbot-header-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  line-height: 1;
}
.chatbot-header-btn:hover {
  background: rgba(255,255,255,0.2);
}


/* Messages area */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 200px;
  max-height: 340px;
}

.chatbot-msg {
  font-size: 12px;
  line-height: 1.6;
  padding: 8px 12px;
  border-radius: 8px;
  max-width: 90%;
  word-wrap: break-word;
}
.chatbot-msg.assistant {
  background: var(--bg-surface-alt);
  color: var(--text-primary);
  align-self: flex-start;
  border-bottom-left-radius: 2px;
}
.chatbot-msg.user {
  background: var(--accent);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 2px;
}
.chatbot-msg.system {
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  text-align: center;
  align-self: center;
  font-style: italic;
}
.chatbot-msg em {
  font-style: italic;
  opacity: 0.85;
}
.chatbot-msg strong {
  font-weight: 600;
}
.chatbot-msg code {
  font-family: monospace;
  font-size: 11px;
  background: var(--bg-page);
  padding: 1px 4px;
  border-radius: 3px;
}

/* Tour buttons */
.chatbot-tour-btns {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.chatbot-tour-btn {
  padding: 6px 14px;
  border-radius: 5px;
  font-size: 12px;
  font-family: 'Montserrat', sans-serif;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s;
}
.chatbot-tour-btn.primary {
  background: var(--accent);
  color: #fff;
}
.chatbot-tour-btn.primary:hover {
  background: var(--accent-hover);
}
.chatbot-tour-btn.secondary {
  background: var(--bg-surface-alt);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}
.chatbot-tour-btn.secondary:hover {
  background: var(--border-light);
}

/* Input area */
.chatbot-input-area {
  display: flex;
  align-items: flex-end;
  padding: 8px 12px;
  border-top: 1px solid var(--border-light);
  gap: 6px;
  flex-shrink: 0;
}
.chatbot-input {
  flex: 1;
  border: 1px solid var(--border-heavy);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 12px;
  font-family: 'Montserrat', sans-serif;
  background: var(--bg-input);
  color: var(--text-primary);
  resize: none;
  max-height: 80px;
  line-height: 1.4;
}
.chatbot-input:focus {
  outline: none;
  border-color: var(--accent);
}
.chatbot-input::placeholder {
  color: var(--text-muted);
}
.chatbot-send-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Montserrat', sans-serif;
  flex-shrink: 0;
  transition: background 0.15s;
}
.chatbot-send-btn:hover {
  background: var(--accent-hover);
}
.chatbot-send-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Footer disclaimer */
.chatbot-footer {
  padding: 6px 14px 8px;
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.4;
  text-align: center;
  flex-shrink: 0;
  border-top: 1px solid var(--border-light);
}

/* Nav restore icon (when panel hidden) */
#chatbot-nav-restore {
  cursor: pointer;
  font-size: 14px;
  margin-left: 4px;
  display: none;
}

/* Loading indicator */
.chatbot-typing {
  display: inline-flex;
  gap: 3px;
  padding: 4px 0;
}
.chatbot-typing span {
  width: 5px;
  height: 5px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: chatbot-bounce 1.2s infinite;
}
.chatbot-typing span:nth-child(2) { animation-delay: 0.15s; }
.chatbot-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chatbot-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

/* Wave animation for landing page */
#chatbot-tab.waving {
  animation: chatbot-wave 1.2s ease-in-out 3;
}
@keyframes chatbot-wave {
  0%, 100% { transform: translateY(0); }
  30% { transform: translateY(-8px); }
  50% { transform: translateY(-2px); }
  70% { transform: translateY(-6px); }
}

/* Mobile */
@media (max-width: 640px) {
  #chatbot-panel {
    right: 8px;
    left: 8px;
    width: auto;
    max-height: 70vh;
  }
  #chatbot-tab {
    right: 8px;
  }
}

/* ── Enlarged mode ─────────────────────────────────────────────────────── */
#chatbot-panel.chatbot-enlarged {
  width: 75vw !important;
  height: 75vh !important;
  max-width: 75vw !important;
  max-height: 75vh !important;
  top: 12.5vh !important;
  left: 12.5vw !important;
  right: auto !important;
  bottom: auto !important;
  border-radius: 12px;
}
#chatbot-panel.chatbot-enlarged .chatbot-messages {
  max-height: none;
}

/* ── Mermaid diagrams ──────────────────────────────────────────────────── */
.chatbot-mermaid {
  margin: 8px 0;
  overflow-x: auto;
  text-align: center;
  background: var(--bg-page);
  border-radius: 6px;
  padding: 8px 4px;
}
.chatbot-mermaid svg {
  max-width: 100%;
  height: auto;
}
