/* chatbot.css — Strut Grounded Agent Chatbot Styling */

:root {
  --bg-dark: #09090b;
  --bg-sidebar: #0d0d11;
  --bg-card: #141418;
  --bg-card-hover: #1c1c22;
  --bg-input: #121216;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(96, 165, 250, 0.5);
  
  --text-main: #f4f4f5;
  --text-muted: #a1a1aa;
  --text-dim: #71717a;

  --accent-cyan: #06b6d4;
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-emerald: #10b981;

  --ease-out-strong: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body.chatbot-body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  height: 100vh;
  overflow: hidden;
}

.chat-app-wrapper {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Sidebar */
.chat-sidebar {
  width: 280px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  flex-shrink: 0;
}

.sidebar-brand {
  margin-bottom: 20px;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.sidebar-brand-logo {
  height: 30px;
  width: auto;
  display: block;
  object-fit: contain;
  transition: opacity 160ms ease;
}

.brand-link:hover .sidebar-brand-logo {
  opacity: 0.85;
}

.brand-badge {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.25), rgba(59, 130, 246, 0.25));
  color: #c084fc;
  border: 1px solid rgba(139, 92, 246, 0.4);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-left: 4px;
}

.sidebar-action-wrap {
  margin-bottom: 24px;
}

.new-chat-btn {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
  padding: 10px 14px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 160ms var(--ease-out-strong);
}

.new-chat-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

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

.sidebar-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  padding: 0 4px;
}

.model-select-wrapper {
  margin-bottom: 24px;
}

.chat-model-select {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: #e4e4e7;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 6px;
  outline: none;
  cursor: pointer;
  transition: border-color 160ms var(--ease-out-strong);
}

.chat-model-select:focus {
  border-color: var(--border-focus);
}

.engine-telemetry-box {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: auto;
}

.telemetry-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.telem-label {
  color: var(--text-muted);
}

.telem-val {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  color: #fff;
}

.telem-val.online {
  color: #34d399;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.telem-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: pulse-dot 2s infinite;
}

.telem-val.highlight {
  color: #60a5fa;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.sidebar-footer {
  border-top: 1px solid var(--border-subtle);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.footer-link {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 6px 8px;
  border-radius: 6px;
  transition: all 140ms var(--ease-out-strong);
}

.footer-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

/* Main Chat Workspace */
.chat-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
  background: var(--bg-dark);
}

.workspace-header {
  height: 56px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  background: rgba(9, 9, 11, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.workspace-title {
  font-family: 'Outfit', sans-serif;
  font-size: 17px;
  font-weight: 600;
  color: #fff;
}

.workspace-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 10px;
}

.workspace-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.workspace-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 140ms var(--ease-out-strong);
}

.workspace-btn:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

.workspace-btn:active {
  transform: scale(0.97);
}

.count-badge {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 9999px;
}

/* Messages Container */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 30px 40px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Welcome Card */
.welcome-card {
  max-width: 720px;
  margin: 40px auto;
  text-align: center;
  animation: fadeIn 300ms var(--ease-out-strong);
}

.welcome-brand-logo {
  height: 58px;
  width: auto;
  max-width: 220px;
  object-fit: contain;
  display: block;
  margin: 0 auto 20px auto;
  filter: drop-shadow(0 4px 20px rgba(255, 255, 255, 0.08));
}

.welcome-icon-glow {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(139, 92, 246, 0.2));
  border: 1px solid rgba(59, 130, 246, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px auto;
  box-shadow: 0 0 24px rgba(59, 130, 246, 0.25);
}

.welcome-icon {
  font-size: 28px;
  color: #60a5fa;
}

.welcome-title {
  font-family: 'Outfit', sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.welcome-desc {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 32px;
}

.prompt-pills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  text-align: left;
}

.prompt-pill {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: all 160ms var(--ease-out-strong);
}

.prompt-pill:hover {
  background: var(--bg-card-hover);
  border-color: rgba(96, 165, 250, 0.35);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.prompt-pill:active {
  transform: scale(0.98);
}

.pill-tag {
  font-size: 11px;
  font-weight: 600;
  color: #60a5fa;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pill-text {
  font-size: 13.5px;
  color: #e4e4e7;
  font-weight: 500;
}

/* Chat Messages */
.chat-row {
  display: flex;
  gap: 14px;
  max-width: 840px;
  width: 100%;
  margin: 0 auto;
  animation: slideUp 200ms var(--ease-out-strong);
}

.chat-row.user {
  justify-content: flex-end;
}

.chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.chat-row.ai .chat-avatar {
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #fff;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.3);
}

.chat-row.user .chat-avatar {
  background: #27272a;
  color: #e4e4e7;
}

.chat-bubble {
  padding: 14px 18px;
  border-radius: 12px;
  font-size: 14.5px;
  line-height: 1.65;
  position: relative;
}

.chat-row.user .chat-bubble {
  background: #2563eb;
  color: #ffffff;
  border-bottom-right-radius: 4px;
  max-width: 80%;
}

.chat-row.ai .chat-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: #f4f4f5;
  border-bottom-left-radius: 4px;
  flex: 1;
}

.chat-bubble p {
  margin-bottom: 12px;
}
.chat-bubble p:last-child {
  margin-bottom: 0;
}

.chat-bubble ul, .chat-bubble ol {
  margin: 8px 0 12px 20px;
}
.chat-bubble li {
  margin-bottom: 6px;
}

.chat-bubble strong {
  color: #fff;
  font-weight: 600;
}

/* Citation Chips in Chat */
.citation-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.4);
  border-radius: 4px;
  padding: 0 5px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  margin: 0 2px;
  vertical-align: baseline;
  transition: all 140ms var(--ease-out-strong);
}

.citation-tag:hover {
  background: rgba(59, 130, 246, 0.35);
  color: #ffffff;
  border-color: #60a5fa;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.4);
}

/* Telemetry Footer under AI Message */
.ai-msg-telemetry {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
  font-size: 11.5px;
  color: var(--text-dim);
}

.telem-pill {
  font-family: 'JetBrains Mono', monospace;
}

.copy-msg-btn {
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  transition: color 140ms var(--ease-out-strong);
}
.copy-msg-btn:hover {
  color: #fff;
}

/* Input Dock */
.chat-input-dock {
  padding: 16px 40px 24px 40px;
  background: linear-gradient(180deg, rgba(9, 9, 11, 0) 0%, rgba(9, 9, 11, 0.95) 30%);
}

.input-container {
  max-width: 840px;
  margin: 0 auto;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  transition: border-color 160ms var(--ease-out-strong), box-shadow 160ms var(--ease-out-strong);
}

.input-container:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Real-Time Agent Stage Reasoning Bar */
.agent-stage-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: 6px;
  padding: 6px 12px;
  margin-bottom: 10px;
  animation: fadeIn 200ms var(--ease-out-strong);
}

.stage-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(96, 165, 250, 0.3);
  border-top-color: #60a5fa;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.stage-text {
  font-size: 12.5px;
  font-weight: 500;
  color: #93c5fd;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.chat-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-textarea {
  background: transparent;
  border: none;
  color: #fff;
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.5;
  resize: none;
  outline: none;
  min-height: 24px;
  max-height: 180px;
}

.chat-textarea::placeholder {
  color: var(--text-dim);
}

.input-actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 4px;
}

.input-meta-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stream-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 500;
  color: #34d399;
}

.stream-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
}

.grounding-badge {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 500;
}

.send-btn {
  background: #2563eb;
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 140ms var(--ease-out-strong);
}

.send-btn:hover {
  background: #3b82f6;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.4);
}

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

.input-disclaimer {
  text-align: center;
  font-size: 11.5px;
  color: var(--text-dim);
  margin-top: 8px;
}

/* Right-Hand Sources Drawer */
.sources-drawer {
  width: 340px;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  transition: transform 250ms var(--ease-out-strong);
  flex-shrink: 0;
}

.sources-drawer.collapsed {
  display: none;
}

.sources-drawer-header {
  height: 56px;
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sources-drawer-title {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.close-drawer-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
}

.sources-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.source-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px;
  transition: border-color 140ms var(--ease-out-strong);
}

.source-card:hover {
  border-color: rgba(96, 165, 250, 0.3);
}

.source-card-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.src-idx-badge {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}

.src-domain {
  font-size: 11.5px;
  color: var(--text-dim);
}

.src-title {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  display: block;
  margin-bottom: 6px;
  line-height: 1.4;
}
.src-title:hover {
  color: #60a5fa;
}

.src-quote {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  background: rgba(0, 0, 0, 0.2);
  padding: 6px 8px;
  border-radius: 4px;
  border-left: 2px solid #3b82f6;
}

/* Citation Hover Tooltip */
.citation-tooltip {
  position: absolute;
  z-index: 1000;
  width: 320px;
  background: #18181b;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  pointer-events: auto;
  animation: fadeIn 150ms var(--ease-out-strong);
}

.tooltip-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.tooltip-idx {
  color: #60a5fa;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
}

.tooltip-title {
  font-size: 12.5px;
  font-weight: 600;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tooltip-quote {
  font-size: 12px;
  color: #d4d4d8;
  line-height: 1.5;
  margin-bottom: 8px;
  max-height: 90px;
  overflow-y: auto;
}

.tooltip-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border-subtle);
  padding-top: 6px;
  font-size: 11px;
}

.tooltip-score {
  color: #34d399;
}

.tooltip-link {
  color: #60a5fa;
  text-decoration: none;
  font-weight: 500;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 900px) {
  .chat-sidebar {
    display: none;
  }
  .sources-drawer {
    display: none;
  }
  .messages-container {
    padding: 20px;
  }
  .chat-input-dock {
    padding: 10px 20px;
  }
}

/* ========================================================================= */
/* RESPONSIVE — NARROW VIEWPORTS */
/* ========================================================================= */
/* The workspace header is a fixed 56px justify-between row with the title and
   an inline strapline on one side. On a phone the strapline wrapped to two
   lines inside that fixed height, so the text collided with the action
   buttons. */
@media (max-width: 720px) {
  .workspace-header {
    height: auto;
    min-height: 56px;
    padding: 10px 14px;
    gap: 10px;
  }

  .workspace-title-wrap {
    min-width: 0;
  }

  .workspace-title {
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Decorative strapline — it is what forced the header to three lines. */
  .workspace-subtitle {
    display: none;
  }

  .workspace-actions {
    flex-shrink: 0;
  }
}

@media (max-width: 900px) {
  /* The drawer this button toggles is already display:none at this width (see
     the rule above), which left the control visible but inert. */
  #toggle-sources-btn {
    display: none;
  }
}
