/* ============================================
   Tekglen ChatGPT-Style UI
   ============================================ */

:root {
  /* Core colors */
  --bg: #f9fafb;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;

  /* Primary accent */
  --primary: #0f766e;
  --primary-hover: #0d6860;

  /* Sidebar */
  --sidebar-width: 280px;
  --sidebar-bg: #1e293b;
  --sidebar-text: #e2e8f0;
  --sidebar-muted: #94a3b8;
  --sidebar-border: #334155;
  --sidebar-hover: #334155;

  /* Chat bubbles */
  --user-bg: #0f766e;
  --user-text: #ffffff;
  --bot-bg: #f1f5f9;
  --bot-text: #0f172a;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

/* ============================================
   Main Layout
   ============================================ */

.chatgpt-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* ============================================
   Sidebar
   ============================================ */

.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease, margin-left 0.3s ease;
  z-index: 100;
}

.sidebar.collapsed {
  margin-left: calc(-1 * var(--sidebar-width));
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  flex: 1;
  min-width: 0;
}

.sidebar-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.sidebar-logo-icon {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.topbar-logo-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.sidebar-nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--sidebar-muted);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}

.sidebar-nav-link:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text);
}

.hamburger-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.hamburger-btn:hover {
  background: var(--sidebar-hover);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.sidebar-section {
  margin-bottom: 16px;
}

.sidebar-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--sidebar-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sidebar-select,
.sidebar-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border-radius: 8px;
  border: 1px solid var(--sidebar-border);
  background: var(--sidebar-hover);
  color: var(--sidebar-text);
  outline: none;
  transition: border-color 0.15s;
}

.sidebar-select:focus,
.sidebar-input:focus {
  border-color: var(--primary);
}

.sidebar-select option {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
}

.sidebar-hint {
  font-size: 11px;
  color: var(--sidebar-muted);
  margin-top: 4px;
}

.sidebar-divider {
  height: 1px;
  background: var(--sidebar-border);
  margin: 20px 0;
}

/* ============================================
   Under the Hood Panel
   ============================================ */

.under-hood-panel {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 14px;
}

.under-hood-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--sidebar-text);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.under-hood-title::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
}

.hood-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 0;
  border-bottom: 1px solid var(--sidebar-border);
}

.hood-row:last-child {
  border-bottom: none;
}

.hood-label {
  font-size: 11px;
  color: var(--sidebar-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hood-value {
  font-size: 12px;
  color: var(--sidebar-text);
  word-break: break-word;
  white-space: pre-wrap;
  font-family: "SF Mono", Monaco, Consolas, monospace;
}

/* Developer Mode Toggle */
.dev-mode-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.dev-mode-label {
  font-size: 12px;
  color: var(--sidebar-muted);
  font-weight: 500;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--sidebar-border);
  border-radius: 20px;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  bottom: 2px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--primary);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(16px);
}

.under-hood-panel.hidden {
  display: none;
}

/* ============================================
   Sidebar Overlay (Mobile)
   ============================================ */

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
}

.sidebar-overlay.visible {
  display: block;
}

/* ============================================
   Main Chat Area
   ============================================ */

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}

/* Chat topbar (visible when sidebar is collapsed) */
.chat-topbar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.chat-topbar.visible {
  display: flex;
}

.chat-topbar .hamburger-btn {
  color: var(--text);
}

.chat-topbar .hamburger-btn:hover {
  background: var(--bot-bg);
}

.chat-topbar-title {
  font-size: 16px;
  font-weight: 600;
}

/* ============================================
   Messages Container
   ============================================ */

.messages-container {
  flex: 1;
  overflow-y: auto;
  display: flex;
  justify-content: center;
}

.messages {
  width: 100%;
  max-width: 768px;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
}

/* Empty state / Hero */
.empty {
  text-align: center;
  padding-top: 80px;
}

.hero-logo {
  margin-bottom: 16px;
}

.hero-logo img {
  width: 192px;
  height: 192px;
  object-fit: contain;
}

.empty-title-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 4px;
}

.empty-title-icon {
  width: 40px;
  height: 40px;
  object-fit: contain;
  flex-shrink: 0;
}

.empty-title {
  font-size: 36px;
  font-weight: 600;
  color: var(--text);
}

.hero-tagline {
  font-size: 14px;
  font-weight: 500;
  color: var(--primary);
  margin-bottom: 12px;
  letter-spacing: 0.02em;
}

.empty-subtitle {
  font-size: 15px;
  color: var(--muted);
  max-width: 460px;
  margin: 0 auto;
  line-height: 1.5;
}

/* Sample Question Chips */
.sample-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
}

.sample-chip {
  padding: 8px 16px;
  font-size: 13px;
  border: 1px solid var(--primary);
  border-radius: 20px;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}

.sample-chip:hover {
  background: var(--primary);
  color: #fff;
}

/* New Chat Button */
.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  color: var(--sidebar-text);
  background: var(--primary);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.new-chat-btn:hover {
  background: var(--primary-hover);
}

.new-chat-btn:active {
  transform: scale(0.98);
}

/* Message Wrapper */
.message-wrapper {
  display: flex;
  flex-direction: column;
  margin-bottom: 12px;
  max-width: 85%;
}

.message-wrapper.user {
  align-self: flex-end;
}

.message-wrapper.bot {
  align-self: flex-start;
}

/* Message Actions (copy, etc.) */
.message-actions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}

.message-wrapper:hover .message-actions {
  opacity: 1;
}

.msg-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.msg-action-btn:hover {
  background: var(--bot-bg);
  color: var(--text);
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 16px 20px !important;
}

.typing-indicator span {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--muted);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Inline typing indicator (cold start) */
.typing-indicator.inline {
  display: inline-flex;
  padding: 0 !important;
  background: none !important;
  margin-left: 6px;
  vertical-align: middle;
}

.typing-indicator.inline span {
  width: 6px;
  height: 6px;
}

/* Cold start message */
.cold-start-msg {
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
}

/* Retry Button */
.retry-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 6px 14px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  color: var(--primary);
  background: transparent;
  border: 1px solid var(--primary);
  border-radius: 16px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.retry-btn:hover {
  background: var(--primary);
  color: #fff;
}

.error-msg {
  border-left: 3px solid #ef4444;
}

/* Message bubbles */
.message {
  padding: 12px 16px;
  border-radius: 16px;
  margin-bottom: 0;
  font-size: 15px;
  line-height: 1.5;
  max-width: 100%;
  word-wrap: break-word;
}

/* Markdown-rendered bot messages */
.message.bot strong,
.message.assistant strong {
  font-weight: 600;
}

.message.bot ul,
.message.assistant ul,
.message.bot ol,
.message.assistant ol {
  margin: 6px 0;
  padding-left: 20px;
}

.message.bot li,
.message.assistant li {
  margin-bottom: 4px;
}

.message.bot code,
.message.assistant code {
  background: rgba(0, 0, 0, 0.06);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 13px;
  font-family: "SF Mono", Monaco, Consolas, monospace;
}

.message.bot p,
.message.assistant p {
  margin: 0 0 8px 0;
}

.message.bot p:last-child,
.message.assistant p:last-child {
  margin-bottom: 0;
}

.message.bot a,
.message.assistant a {
  color: var(--primary);
  text-decoration: underline;
}

/* Headers in bot messages */
.message.bot h1,
.message.assistant h1 {
  font-size: 20px;
  font-weight: 700;
  margin: 16px 0 10px 0;
  color: var(--text);
}

.message.bot h1:first-child,
.message.assistant h1:first-child {
  margin-top: 0;
}

.message.bot h2,
.message.assistant h2 {
  font-size: 18px;
  font-weight: 700;
  margin: 14px 0 8px 0;
  color: var(--text);
}

.message.bot h2:first-child,
.message.assistant h2:first-child {
  margin-top: 0;
}

.message.bot h3,
.message.assistant h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 12px 0 6px 0;
  color: var(--text);
}

.message.bot h3:first-child,
.message.assistant h3:first-child {
  margin-top: 0;
}

.message.user {
  background: var(--user-bg);
  color: var(--user-text);
  border-bottom-right-radius: 4px;
  white-space: pre-wrap;
}

.message.bot,
.message.assistant {
  background: var(--bot-bg);
  color: var(--bot-text);
  border-bottom-left-radius: 4px;
}

/* ============================================
   Composer
   ============================================ */

.composer-container {
  display: flex;
  justify-content: center;
  padding: 16px 20px 24px;
  background: linear-gradient(transparent, var(--bg) 20%);
}

.composer {
  width: 100%;
  max-width: 768px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 8px 8px 8px 16px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.composer:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.1), var(--shadow);
}

.composer-textarea {
  flex: 1;
  border: none;
  outline: none;
  font-size: 15px;
  line-height: 1.5;
  resize: none;
  max-height: 200px;
  padding: 6px 0;
  background: transparent;
  font-family: inherit;
}

.composer-textarea::placeholder {
  color: var(--muted);
}

.composer-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.composer-icon-btn,
.composer-send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.composer-icon-btn {
  background: transparent;
  color: var(--muted);
}

.composer-icon-btn:hover {
  background: var(--bot-bg);
  color: var(--text);
}

.composer-icon-btn.listening {
  background: #fee2e2;
  color: #dc2626;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.composer-send-btn {
  background: var(--primary);
  color: #fff;
}

.composer-send-btn:hover {
  background: var(--primary-hover);
}

.composer-send-btn:active {
  transform: scale(0.95);
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    transform: translateX(0);
    margin-left: 0;
  }

  .sidebar.collapsed {
    transform: translateX(-100%);
    margin-left: 0;
  }

  .chat-topbar {
    display: flex;
  }

  .messages {
    padding: 16px;
  }

  .composer-container {
    padding: 12px 16px 20px;
  }

  .message-wrapper {
    max-width: 90%;
  }
}

@media (max-width: 480px) {
  .sidebar {
    width: 100%;
    min-width: 100%;
  }

  .empty {
    padding-top: 40px;
  }

  .empty-title-icon {
    width: 30px;
    height: 30px;
  }

  .empty-title {
    font-size: 26px;
  }

  .empty-subtitle {
    font-size: 14px;
  }
}

/* ============================================
   Demo Banner (#1)
   ============================================ */

.demo-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #0f766e;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  letter-spacing: 0.01em;
  position: relative;
  flex-shrink: 0;
}

.demo-banner-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6ee7b7;
  box-shadow: 0 0 0 2px rgba(110, 231, 183, 0.3);
  animation: bannerPulse 2s infinite;
  flex-shrink: 0;
}

@keyframes bannerPulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(110, 231, 183, 0.3); }
  50% { box-shadow: 0 0 0 5px rgba(110, 231, 183, 0.1); }
}

.demo-banner-close {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

.demo-banner-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
}

/* ============================================
   Sidebar Section Labels (#9)
   ============================================ */

.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--sidebar-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 4px;
  margin-bottom: 8px;
}

/* ============================================
   Sidebar Dashboard Button (#11)
   ============================================ */

.sidebar-dashboard-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  margin-bottom: 0;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: var(--sidebar-text);
  background: rgba(15, 118, 110, 0.2);
  border: 1px solid rgba(15, 118, 110, 0.4);
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}

.sidebar-dashboard-btn:hover {
  background: rgba(15, 118, 110, 0.35);
  border-color: rgba(15, 118, 110, 0.6);
  color: var(--sidebar-text);
}

/* ============================================
   Export Transcript Button (#15)
   ============================================ */

.export-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  margin-bottom: 8px;
  font-size: 13px;
  font-family: inherit;
  color: var(--sidebar-muted);
  background: transparent;
  border: 1px solid var(--sidebar-border);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.export-btn:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text);
}

/* ============================================
   Sidebar Peek Tab (#14)
   ============================================ */

.sidebar-peek-tab {
  display: none; /* shown/hidden by JS */
  align-items: center;
  justify-content: center;
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 48px;
  background: var(--sidebar-bg);
  color: var(--sidebar-muted);
  border: 1px solid var(--sidebar-border);
  border-left: none;
  border-radius: 0 8px 8px 0;
  cursor: pointer;
  z-index: 101;
  transition: background 0.15s, color 0.15s, width 0.15s;
}

.sidebar-peek-tab:hover {
  width: 24px;
  color: var(--sidebar-text);
  background: var(--sidebar-hover);
}

@media (max-width: 768px) {
  .sidebar-peek-tab {
    display: none !important;
  }
}

/* ============================================
   Viewing As Chip (#2)
   ============================================ */

.viewing-as-bar {
  display: flex;
  justify-content: center;
  margin-bottom: 6px;
  min-height: 22px;
}

.viewing-as-chip {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
  background: var(--bot-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 3px 10px;
  letter-spacing: 0.01em;
}

.viewing-as-chip:empty {
  display: none;
}

/* ============================================
   Cold Start Progress Bar (#3)
   ============================================ */

.cold-start-bar {
  width: 100%;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 10px;
}

.cold-start-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  animation: coldStartProgress 30s linear forwards;
}

@keyframes coldStartProgress {
  0% { width: 0%; }
  80% { width: 85%; }
  100% { width: 95%; }
}

/* ============================================
   Follow-up Chips (#4)
   ============================================ */

.followup-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.followup-chip {
  padding: 5px 12px;
  font-size: 12px;
  font-family: inherit;
  color: var(--primary);
  background: transparent;
  border: 1px solid var(--primary);
  border-radius: 16px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.followup-chip:hover {
  background: var(--primary);
  color: #fff;
}

/* ============================================
   Feedback Buttons (#6)
   ============================================ */

.feedback-btn {
  /* inherits .msg-action-btn */
}

.feedback-active-good {
  color: #16a34a !important;
  background: #dcfce7 !important;
}

.feedback-active-bad {
  color: #dc2626 !important;
  background: #fee2e2 !important;
}

/* ============================================
   Message Timestamp (#10)
   ============================================ */

.message-timestamp {
  font-size: 10px;
  color: var(--muted);
  opacity: 0;
  margin-top: 2px;
  transition: opacity 0.15s;
  align-self: flex-end;
}

.message-wrapper.user .message-timestamp {
  align-self: flex-end;
}

.message-wrapper.bot .message-timestamp {
  align-self: flex-start;
}

.message-wrapper:hover .message-timestamp {
  opacity: 1;
}

/* ============================================
   ERP Diagram (#12)
   ============================================ */

.erp-diagram {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 20px auto 0;
  padding: 16px 20px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  max-width: 420px;
  box-shadow: var(--shadow-sm);
}

.erp-diagram-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 90px;
}

.erp-diagram-node--center .erp-diagram-icon {
  background: rgba(15, 118, 110, 0.08);
  border: 1px solid rgba(15, 118, 110, 0.2);
  border-radius: 10px;
}

.erp-diagram-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  border-radius: 10px;
  background: var(--bot-bg);
}

.erp-diagram-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
}

.erp-diagram-sub {
  font-size: 10px;
  color: var(--muted);
  text-align: center;
}

.erp-diagram-arrow {
  font-size: 18px;
  color: var(--primary);
  font-weight: 700;
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .erp-diagram {
    display: none;
  }

  .sidebar-peek-tab {
    display: none !important;
  }
}

/* ============================================
   KB-specific: Pillar buttons
   ============================================ */

.pillar-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: 1px solid var(--sidebar-border);
  border-radius: 8px;
  color: var(--sidebar-text);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  margin-bottom: 6px;
  transition: background 0.15s, border-color 0.15s;
}

.pillar-btn:hover {
  background: var(--sidebar-hover);
}

.pillar-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.pillar-btn svg {
  flex-shrink: 0;
  opacity: 0.8;
}

.pillar-btn.active svg {
  opacity: 1;
}

/* Sidebar footer link */
.sidebar-footer-link {
  display: block;
  padding: 8px 14px;
  color: var(--sidebar-muted);
  font-size: 0.8rem;
  text-decoration: none;
  margin-top: auto;
}

.sidebar-footer-link:hover {
  color: var(--sidebar-text);
}

/* ============================================
   KB-specific: Confidence badge
   ============================================ */

.message-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.confidence-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.01em;
}

.badge-high {
  background: #dcfce7;
  color: #15803d;
}

.badge-medium {
  background: #fef9c3;
  color: #a16207;
}

.badge-low {
  background: #fee2e2;
  color: #b91c1c;
}

/* ============================================
   KB-specific: Feedback buttons
   ============================================ */

.feedback-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.fb-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--muted);
  transition: background 0.15s, border-color 0.15s;
  line-height: 1.4;
}

.fb-btn:hover:not(:disabled) {
  background: var(--bot-bg);
  border-color: var(--primary);
  color: var(--primary);
}

.fb-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.fb-thanks {
  font-size: 0.75rem;
  color: var(--muted);
  font-style: italic;
}

/* ============================================
   KB-specific: Answer body
   ============================================ */

/* Bot avatar: logo image instead of text */
.bot-avatar {
  width: 32px !important;
  height: 32px !important;
  background: transparent !important;
  padding: 0 !important;
  flex-shrink: 0;
}
.bot-avatar img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

/* Answer sections */
.answer-summary p,
.answer-detail p  { margin: 0 0 0.4em; }
.answer-summary p:last-child,
.answer-detail p:last-child { margin-bottom: 0; }

.answer-summary ul,
.answer-detail ul  { margin: 0.3em 0; padding-left: 1.3em; }

.answer-summary li,
.answer-detail li  { margin-bottom: 0.15em; line-height: 1.45; }

.answer-summary h2, .answer-summary h3,
.answer-detail  h2, .answer-detail  h3 { margin: 0.6em 0 0.2em; font-size: 0.95rem; }

.answer-summary code,
.answer-detail  code {
  background: #e2e8f0;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.84em;
  font-family: ui-monospace, monospace;
}

/* Expand / collapse button */
.expand-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding: 3px 10px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.78rem;
  color: var(--primary);
  cursor: pointer;
  transition: background 0.15s;
}
.expand-btn:hover { background: #f0fdf4; }

/* Follow-up chips */
.follow-up-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.follow-up-chip {
  padding: 5px 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.78rem;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
  line-height: 1.35;
}
.follow-up-chip:hover {
  background: #f0fdf4;
  border-color: var(--primary);
  color: var(--primary);
}

.kb-error { color: #b91c1c; }

.error-avatar {
  background: #fee2e2 !important;
  color: #b91c1c !important;
  font-weight: 700;
}

/* Composer hint line */
.composer-hint {
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
  padding: 4px 16px 8px;
}

/* ============================================
   Priority 1 — Message turn rows with sender labels
   ============================================ */

.msg-row {
  display: flex;
  flex-direction: column;
  margin-bottom: 20px;
}

.msg-row--user {
  align-self: flex-end;
  align-items: flex-end;
  max-width: 78%;
}

.msg-row--bot {
  align-self: flex-start;
  align-items: flex-start;
  max-width: 92%;
}

/* "You" / "Tekglen Ask" labels */
.sender-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
  letter-spacing: 0.01em;
  user-select: none;
}

.sender-label--bot {
  font-size: 12px;
  color: var(--primary);
}

/* Avatar + "Tekglen Ask" on same baseline */
.bot-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

/* Bubble colours (aligned with class names the JS actually uses) */
.message.user-message {
  background: var(--user-bg);
  color: var(--user-text);
  border-radius: 16px;
  border-bottom-right-radius: 4px;
  white-space: pre-wrap;
}

.message.bot-message {
  background: var(--bot-bg);
  color: var(--bot-text);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}

/* ============================================
   Priority 2 — Lateral follow-up chip (explore)
   ============================================ */

.follow-up-chip--lateral {
  color: var(--muted);
  border-color: var(--border);
  font-style: italic;
}

.follow-up-chip--lateral::before {
  content: "→ ";
  font-style: normal;
  opacity: 0.7;
}

.follow-up-chip--lateral:hover {
  background: #f8fafc;
  border-color: var(--primary);
  color: var(--primary);
  font-style: italic;
}

/* ============================================
   Priority 3 — Thumbs-down reason picker
   ============================================ */

.fb-reason-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  width: 100%;
}

.fb-reason-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  width: 100%;
  margin-bottom: 2px;
}

.fb-reason-btn {
  padding: 3px 10px;
  font-size: 11px;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.fb-reason-btn:hover {
  border-color: #ef4444;
  color: #dc2626;
  background: #fff1f2;
}

.fb-reason-skip {
  color: var(--muted);
  font-style: italic;
}

.fb-reason-skip:hover {
  border-color: var(--border);
  color: var(--muted);
  background: var(--bot-bg);
}
