/**
 * BDS AI Workspace - Scoped CSS
 * ========================================
 * Place this file at: assets/vendor/css/pages/bds-ai-workspace.css
 * Load AFTER app-chat.css in the HTML
 * 
 * All styles scoped under .bds-ai-workspace to avoid affecting Vuexy globally
 */

/* ============================================
   Main Workspace Container
   ============================================ */
.bds-ai-workspace {
  background: var(--bs-card-bg, #fff);
}

/* ============================================
   Left Panel - AI Chat
   ============================================ */
.bds-ai-workspace .bds-chat-panel {
  display: flex;
  flex-direction: column;
  background: var(--bs-card-bg, #fff);
  /* No fixed floor: the panel fills its column (chat mode ties it to the
     viewport height below). min-height:0 lets the inner flex body shrink and
     own the single vertical scroll. */
  min-height: 0;
}

.bds-ai-workspace .bds-chat-header,
.bds-ai-workspace .bds-workspace-header {
  display: flex;
  align-items: center;
  min-height: 4.5rem;
  flex-shrink: 0;
  background: var(--bs-body-bg, #f8f7fa);
}

.bds-ai-workspace .bds-chat-header > .d-flex,
.bds-ai-workspace .bds-workspace-header > .d-flex {
  width: 100%;
}

.bds-ai-workspace .bds-workspace-header {
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
}

.bds-ai-workspace .bds-workspace-heading,
.bds-ai-workspace .bds-workspace-identity,
.bds-ai-workspace .bds-workspace-heading-actions,
.bds-ai-workspace .bds-workspace-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.bds-ai-workspace .bds-workspace-heading {
  justify-content: space-between;
  flex-wrap: wrap;
}

.bds-ai-workspace .bds-workspace-heading-actions {
  margin-inline-start: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 100%;
}

.bds-ai-workspace .bds-workspace-identity,
.bds-ai-workspace .bds-workspace-title-group {
  min-width: 0;
}

.bds-ai-workspace .bds-workspace-identity > i,
.bds-ai-workspace .bds-workspace-heading-actions {
  flex-shrink: 0;
}

.bds-ai-workspace #workspaceHeaderSub {
  display: block;
  overflow-wrap: anywhere;
  font-size: 0.75rem;
}

.bds-ai-workspace .bds-workspace-toolbar {
  flex-wrap: wrap;
}

.bds-ai-workspace .bds-workspace-toolbar:not(:has(> :not(.d-none):not([style*="display:none"]):not([style*="display: none"]))) {
  display: none;
}

.bds-ai-workspace .bds-workspace-header .btn {
  min-height: 36px;
  white-space: nowrap;
}

.bds-ai-workspace .bds-workspace-header .btn-icon {
  width: 36px;
  height: 36px;
}

.bds-ai-workspace #workspaceFilterBtn:not(.btn-primary) {
  color: var(--bs-secondary-color, #6e6b7b);
  background: transparent;
  border-color: var(--bs-border-color, #dbdade);
}

.bds-ai-workspace #workspaceFilterBtn:not(.btn-primary):hover {
  background: var(--bs-secondary-bg, #f0f0f2);
}

.bds-ai-workspace #workspaceOligoSwitchWrap {
  order: 2;
  margin-inline-start: auto;
  min-height: 36px;
  padding: 0.375rem 0;
  gap: 0.5rem;
  border: 0;
  font-size: 0.75rem;
  white-space: nowrap;
}

.bds-ai-workspace #workspaceDescriptionControls .table_options {
  position: static !important;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.bds-ai-workspace #workspaceDescriptionControls .desc_row_len {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
}

.bds-ai-workspace #workspaceDescriptionControls select {
  height: 36px !important;
  margin: 0 !important;
  padding: 0.375rem 0.5rem;
  border: 1px solid var(--bs-border-color, #dbdade);
  border-radius: var(--bs-border-radius, 0.375rem);
  background-color: var(--bs-body-bg, #fff);
  color: var(--bs-body-color, #6e6b7b);
  font-size: 0.8125rem;
}

.bds-ai-workspace #workspaceFilterBadge {
  display: flex;
  align-items: center;
  align-self: flex-start;
  max-width: 100%;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
}

.bds-ai-workspace #workspaceFilterBadgeText {
  min-width: 0;
}

.bds-ai-workspace #workspaceFilterBadge .btn {
  flex-shrink: 0;
  min-height: 24px;
  width: 24px;
  height: 24px;
}

.bds-ai-workspace .bds-chat-body {
  flex: 1;
  padding: 1.5rem;
}

.bds-ai-workspace .bds-chat-footer {
  flex-shrink: 0;
  background: var(--bs-card-bg, #fff);
  border-top: 1px solid var(--bs-border-color);
}

/* ============================================
   Welcome Screen - Welcome Mode Layout
   ============================================ */
.bds-ai-workspace .bds-welcome-screen {
  padding: 0rem 1rem;
}

/* Container for welcome content - same width for composer and suggestions */
.bds-ai-workspace .bds-welcome-container {
  max-width: 750px;
  width: 100%;
  margin: 0 auto;
}

/* Welcome Composer - Large input box above suggestions */
.bds-ai-workspace .bds-welcome-composer {
  background: var(--bs-card-bg, #fff);
  border: 1px solid var(--bs-border-color);
  border-radius: 0.75rem;
  padding: 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.bds-ai-workspace .bds-welcome-textarea {
  border: none;
  resize: none;
  font-size: 1rem;
  padding: 0.5rem;
  min-height: 80px;
}

.bds-ai-workspace .bds-welcome-textarea:focus {
  box-shadow: none;
  outline: none;
}

.bds-ai-workspace .bds-welcome-composer-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--bs-border-color);
  margin-top: 0.75rem;
}

/* Hide bottom chat footer when welcome screen is visible (class added by JS) */
.bds-ai-workspace.welcome-mode .bds-chat-footer {
  display: none !important;
}

/* Show bottom chat footer when in chat mode */
.bds-ai-workspace:not(.welcome-mode) .bds-chat-footer {
  display: block !important;
}

/* AI Disclaimer Text */
.bds-ai-workspace .bds-ai-disclaimer {
  font-size: 0.8125rem;
  color: #9aa0a6;
  letter-spacing: 0.01em;
}

/* ChatGPT-style Circular Send Button */
.bds-ai-workspace .bds-send-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.bds-ai-workspace .bds-send-btn i {
  font-size: 1.125rem;
  line-height: 1;
}

/* ============================================
   Chat Mode - Viewport-Fill Height with Internal Scroll
   ============================================
   The panel fills the available height below the top navigation via the
   viewport unit (100vh minus the navbar/container chrome), so zooming out or a
   taller desktop viewport naturally reveals MORE message history. The message
   body (flex:1 1 auto; min-height:0; overflow-y:auto) is the single vertical
   scroll container; the header and composer take only the space they need. */
.bds-ai-workspace.chat-mode-active .bds-chat-panel {
  height: calc(100vh - 180px);
  min-height: 400px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.bds-ai-workspace.chat-mode-active .bds-chat-header {
  flex: 0 0 auto;
}

.bds-ai-workspace.chat-mode-active .bds-chat-body {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
}

.bds-ai-workspace.chat-mode-active .bds-chat-footer {
  flex: 0 0 auto;
  padding: 1rem 1.5rem;
  background: var(--bs-card-bg, #fff);
}

/* The composer stays compact when empty (one line, min-height 38px from the
   #messageInput rule below) and grows only while typing, up to max-height. No
   large blank block is reserved beneath the textarea. */
.bds-ai-workspace.chat-mode-active .bds-chat-footer #messageInput {
  resize: none;
}

.bds-ai-workspace .bds-chat-footer #chatForm > .flex-grow-1 {
  min-width: 0;
}

/* Suggestion Items */
.bds-ai-workspace .suggestion-item {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 0.375rem;
  margin-bottom: 0.5rem;
  transition: all 0.2s ease;
}

.bds-ai-workspace .suggestion-item:hover {
  border-color: var(--bs-primary);
  background-color: rgba(var(--bs-primary-rgb), 0.04);
}

.bds-ai-workspace .suggestion-item span {
  flex: 1;
}

/* Chat Messages Container */
.bds-ai-workspace .bds-chat-messages {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-right: 0.5rem; /* Space for scrollbar */
}

/* Individual Messages */
.bds-ai-workspace .chat-message {
  display: flex;
  gap: 0.75rem;
  max-width: 85%;
  animation: bds-fadeIn 0.3s ease;
}

@keyframes bds-fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.bds-ai-workspace .chat-message.user {
  margin-left: auto;
  flex-direction: row-reverse;
}

.bds-ai-workspace .chat-message .message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 600;
}

.bds-ai-workspace .chat-message.ai .message-avatar {
  background: var(--bs-primary);
  color: #fff;
}

.bds-ai-workspace .chat-message.user .message-avatar {
  background: var(--bs-gray-200);
  color: var(--bs-body-color);
}

.bds-ai-workspace .chat-message .message-bubble {
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  line-height: 1.5;
  max-width: 100%;
}

.bds-ai-workspace .chat-message .message-content {
  min-width: 0;
}

.bds-ai-workspace .chat-message .message-text {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.bds-ai-workspace .chat-message.ai .message-text {
  color: #1f2733;
  font-family: var(--bs-font-sans-serif, "Public Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
  font-size: 16px;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.6;
  max-width: 72ch;
  overflow-wrap: anywhere;
}

.bds-ai-workspace .chat-message.ai .message-text > :first-child {
  margin-top: 0;
}

.bds-ai-workspace .chat-message.ai .message-text > :last-child {
  margin-bottom: 0;
}

.bds-ai-workspace .chat-message.ai .message-text p {
  margin: 0 0 0.85em;
}

.bds-ai-workspace .chat-message.ai .message-text h2,
.bds-ai-workspace .chat-message.ai .message-text h3 {
  color: #12181f;
  letter-spacing: 0;
}

.bds-ai-workspace .chat-message.ai .message-text h2 {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  margin: 1.1em 0 0.55em;
}

.bds-ai-workspace .chat-message.ai .message-text h3 {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.35;
  margin: 1em 0 0.45em;
}

.bds-ai-workspace .chat-message.ai .message-text ul,
.bds-ai-workspace .chat-message.ai .message-text ol {
  margin: 0 0 0.9em;
  padding-left: 1.4rem;
}

.bds-ai-workspace .chat-message.ai .message-text li {
  margin: 0.35em 0;
  padding-left: 0.1rem;
}

.bds-ai-workspace .chat-message.ai .message-text li > ul,
.bds-ai-workspace .chat-message.ai .message-text li > ol {
  margin-top: 0.35em;
  margin-bottom: 0.35em;
}

.bds-ai-workspace .chat-message.ai .message-text table {
  border-collapse: collapse;
  display: block;
  font-size: 0.92em;
  font-variant-numeric: tabular-nums;
  line-height: 1.45;
  margin: 0.95em 0;
  max-width: 100%;
  overflow-x: auto;
  width: max-content;
}

.bds-ai-workspace .chat-message.ai .message-text thead {
  background: rgba(115, 103, 240, 0.09);
}

.bds-ai-workspace .chat-message.ai .message-text tbody {
  background: rgba(255, 255, 255, 0.62);
}

.bds-ai-workspace .chat-message.ai .message-text th,
.bds-ai-workspace .chat-message.ai .message-text td {
  border: 1px solid rgba(31, 39, 51, 0.14);
  padding: 0.45rem 0.55rem;
  text-align: left;
  vertical-align: top;
  white-space: normal;
  /* The ancestor .message-text sets overflow-wrap: anywhere for prose, which
     is inherited by table cells too. For table layout, "anywhere" lets the
     browser treat a column's min-content width as arbitrarily small (down to
     a single character), so once the table is squeezed by max-width: 100%
     on a narrow chat panel, every column can collapse to ~1 character wide
     and wrap character-by-character. "break-word" still wraps normal text at
     word boundaries and only breaks a single token as a last resort, without
     collapsing the column's minimum width — this is what keeps wide tables
     (e.g. Accession(s) / Primary Oligo / Causative Mutation(s) / Region)
     readable instead of column-collapsed. */
  overflow-wrap: break-word;
  word-break: normal;
  min-width: 6em;
}

.bds-ai-workspace .chat-message.ai .message-text th:first-child,
.bds-ai-workspace .chat-message.ai .message-text td:first-child {
  /* The first column in these generated tables is consistently the longer-
     content column (e.g. Accession(s)) across the AI's structured table
     responses — give it more baseline room than the shorter label/value
     columns that typically follow it. */
  min-width: 10em;
}

.bds-ai-workspace .chat-message.ai .message-text th {
  color: #12181f;
  font-weight: 700;
}

.bds-ai-workspace .chat-message.ai .message-text blockquote {
  border-left: 3px solid rgba(91, 100, 114, 0.35);
  color: #5b6472;
  margin: 0.95em 0;
  padding: 0.1rem 0 0.1rem 0.85rem;
}

.bds-ai-workspace .chat-message.ai .message-text code,
.bds-ai-workspace .chat-message.ai .message-text pre,
.bds-ai-workspace .chat-message.ai .message-text .bds-rid-link {
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-variant-numeric: tabular-nums;
}

.bds-ai-workspace .chat-message.ai .message-text code {
  background: rgba(31, 39, 51, 0.07);
  border: 1px solid rgba(31, 39, 51, 0.08);
  border-radius: 0.25rem;
  color: #202633;
  font-size: 0.9em;
  padding: 0.08rem 0.25rem;
  white-space: break-spaces;
}

.bds-ai-workspace .chat-message.ai .message-text pre {
  background: rgba(18, 24, 31, 0.055);
  border: 1px solid rgba(31, 39, 51, 0.12);
  border-radius: 0.4rem;
  color: #202633;
  font-size: 0.9em;
  line-height: 1.5;
  margin: 0.95em 0;
  max-width: 100%;
  overflow-x: auto;
  padding: 0.75rem;
}

.bds-ai-workspace .chat-message.ai .message-text pre code {
  background: transparent;
  border: 0;
  border-radius: 0;
  display: block;
  padding: 0;
  white-space: pre;
}

.bds-ai-workspace .chat-message.ai .message-text a {
  color: #4f46c8;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.14em;
}

.bds-ai-workspace .chat-message.ai .message-text a:hover,
.bds-ai-workspace .chat-message.ai .message-text a:focus {
  color: #3f37a8;
  text-decoration-thickness: 2px;
}

.bds-ai-workspace .chat-message.ai .message-text .bds-rid-link {
  border-bottom: 1px dotted currentColor;
  font-size: 0.95em;
  font-weight: 600;
  text-decoration: none;
}

.bds-ai-workspace .chat-message.ai .message-bubble {
  background: linear-gradient(45deg, #F3ECFF, #FAFAFA);
  color: var(--bs-body-color);
  overflow-x: hidden;
}

.bds-ai-workspace .chat-message.user .message-bubble {
  background: var(--bs-primary);
  color: #fff;
}

.bds-ai-workspace .chat-message.user .message-text .user-plain-text {
  white-space: pre-wrap;
  margin-bottom: 0;
}

/* Follow-up question chips */
.bds-ai-workspace .ai-followup-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 0.25rem;
}

.bds-ai-workspace .ai-followup-chip {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  background: #fff;
  border: 1px solid var(--bs-primary);
  border-radius: 1rem;
  color: var(--bs-primary);
  font-size: 0.8rem;
  line-height: 1.4;
  cursor: pointer;
  text-align: left;
  white-space: normal;
  transition: background 0.15s, color 0.15s;
}

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

.bds-ai-workspace .bds-chat-report-bundle {
  display: grid;
  gap: 0.625rem;
}

.bds-ai-workspace .bds-chat-report-card {
  display: grid;
  gap: 0.5rem;
  padding: 0.75rem;
  border: 1px solid rgba(115, 103, 240, 0.18);
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.72);
}

.bds-ai-workspace .bds-chat-report-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  font-size: 0.875rem;
}

.bds-ai-workspace .bds-chat-report-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.bds-ai-workspace .bds-chat-report-actions-row .btn {
  min-height: 2rem;
}

.bds-ai-workspace .ai-blast-confirm-card {
  display: grid;
  gap: 0.625rem;
  padding: 0.75rem;
  border: 1px solid rgba(40, 199, 111, 0.22);
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.78);
}

.bds-ai-workspace .ai-blast-confirm-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.bds-ai-workspace .ai-blast-confirm-summary {
  display: grid;
  gap: 0.35rem;
}

.bds-ai-workspace .ai-blast-confirm-summary div {
  display: grid;
  grid-template-columns: minmax(7rem, 9rem) minmax(0, 1fr);
  gap: 0.5rem;
  align-items: start;
}

.bds-ai-workspace .ai-blast-confirm-summary dt,
.bds-ai-workspace .ai-blast-confirm-summary dd {
  margin: 0;
  font-size: 0.8125rem;
}

.bds-ai-workspace .ai-blast-confirm-summary dt {
  color: var(--bs-secondary-color);
}

.bds-ai-workspace .ai-blast-confirm-summary dd {
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

/* Loading State */
.bds-ai-workspace .message-loading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: linear-gradient(90deg, var(--bs-gray-100), var(--bs-gray-200), var(--bs-gray-100));
  background-size: 200% 100%;
  animation: bds-shimmer 1.5s infinite;
  border-radius: 0.5rem;
}

@keyframes bds-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.bds-ai-workspace .loading-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--bs-primary);
  border-top-color: transparent;
  border-radius: 50%;
  animation: bds-spin 1s linear infinite;
}

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

/* ============================================
   Right Panel - Workspace (Fixed Height with Internal Scroll)
   ============================================ */
.bds-ai-workspace .bds-workspace-panel {
  display: flex;
  flex-direction: column;
  background: var(--bs-card-bg, #fff);
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
}

.bds-ai-workspace .bds-workspace-tabs {
  flex-shrink: 0;
  overflow-x: auto;
  white-space: nowrap;
  background: var(--bs-card-bg, #fff);
}

.bds-ai-workspace .bds-workspace-tabs .nav-tabs {
  flex-wrap: nowrap;
  border-bottom: none;
}

.bds-ai-workspace .bds-workspace-tabs .nav-link {
  padding: 0.5rem 0.875rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--bs-secondary-color);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  white-space: nowrap;
}

.bds-ai-workspace .bds-workspace-tabs .nav-link:hover {
  color: var(--bs-body-color);
  border-bottom-color: var(--bs-gray-400);
}

.bds-ai-workspace .bds-workspace-tabs .nav-link.active {
  color: var(--bs-primary);
  border-bottom-color: var(--bs-primary);
  background: transparent;
}

.bds-ai-workspace .bds-run-status {
  flex-shrink: 0;
  background: var(--bs-gray-50, #fafafa);
}

.bds-ai-workspace .bds-workspace-body {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
}

.bds-ai-workspace .bds-workspace-footer {
  flex-shrink: 0;
  background: var(--bs-body-bg, #f8f7fa);
  letter-spacing: 0.5px;
  font-weight: 500;
}

/* Chat Mode Panel */
.bds-ai-workspace .bds-chat-mode-panel {
  min-height: 400px;
}

/* Run Mode Panel */
.bds-ai-workspace .bds-run-mode-panel {
  height: 100%;
}

.bds-ai-workspace .bds-search-details {
  margin: 1rem;
  border: 1px solid var(--bs-border-color, #dbdade);
  border-radius: 0.5rem;
  background: var(--bs-card-bg, #fff);
}

.bds-ai-workspace .bds-search-details:not([open]) {
  display: none;
}

.bds-ai-workspace .search_details_container {
  padding: 1rem;
}

.bds-ai-workspace .bds-search-details-metadata {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 1rem;
  margin: 0 0 1rem;
}

.bds-ai-workspace .bds-search-details-metadata dt,
.bds-ai-workspace .bds-search-details-sequences h6 {
  margin-bottom: 0.25rem;
  color: var(--bs-secondary-color, #6e6b7b);
  font-size: 0.75rem;
  font-weight: 500;
}

.bds-ai-workspace .bds-search-details-metadata dd {
  margin: 0;
  font-size: 0.8125rem;
  overflow-wrap: anywhere;
}

.bds-ai-workspace .bds-search-details-sequences {
  min-width: 0;
  padding-top: 1rem;
  border-top: 1px solid var(--bs-border-color, #dbdade);
}

.bds-ai-workspace .bds-search-details-sequences p:not(.small) {
  max-height: 8rem;
  overflow-y: auto;
  overflow-wrap: anywhere;
  font-family: monospace;
  font-size: 0.8125rem;
}

.bds-ai-workspace .bds-run-mode-panel .tab-content {
  height: 100%;
}

.bds-ai-workspace .bds-run-mode-panel .tab-pane {
  height: 100%;
}

/* ============================================
   Results Table Styling
   ============================================ */
.bds-ai-workspace .bds-results-table {
  font-size: 0.8125rem;
  margin-bottom: 0;
}

.bds-ai-workspace .bds-results-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.bds-ai-workspace .bds-results-table th {
  font-weight: 600;
  white-space: nowrap;
  padding: 0.625rem 0.75rem;
  border-bottom-width: 2px;
  background: var(--bs-table-bg, #f8f9fa);
}

.bds-ai-workspace .bds-results-table td {
  padding: 0.5rem 0.75rem;
  vertical-align: middle;
}

.bds-ai-workspace .bds-results-table tbody tr:hover {
  background-color: rgba(var(--bs-primary-rgb), 0.04);
}

.bds-ai-workspace .table-responsive {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
}

/* ============================================
   Workspace Collapsed Mode (BUG #1 FIX)
   - Hides right panel, left panel takes full width
   ============================================ */
.bds-ai-workspace.workspace-collapsed #bdsRightPanel {
  display: none !important;
}

.bds-ai-workspace.workspace-collapsed #bdsLeftPanel {
  flex: 0 0 100%;
  max-width: 100%;
  border-right: none;
}

/* Collapse button icon rotation when collapsed */
.bds-ai-workspace.workspace-collapsed #workspaceCollapseBtn i {
  transform: rotate(180deg);
}

/* ============================================
   Fullscreen Mode (BUG #2 FIX)
   - Scoped INSIDE content area only
   - Does NOT use position:fixed
   - Does NOT overlay navbar or sidebar menu
   ============================================ */
.bds-ai-workspace.workspace-fullscreen {
  /* Stay within the content wrapper - no fixed positioning */
  position: relative;
  z-index: 10; /* Below navbar/menu z-index */
  min-height: calc(100vh - 140px); /* Respect navbar height */
  border-radius: 0;
}

.bds-ai-workspace.workspace-fullscreen #bdsLeftPanel {
  display: none !important;
}

.bds-ai-workspace.workspace-fullscreen #bdsRightPanel {
  flex: 0 0 100%;
  max-width: 100%;
  border-left: none;
}

/* Fullscreen button icon change */
.bds-ai-workspace.workspace-fullscreen #workspaceFullscreenBtn i {
  /* Icon changes via JS */
}

/* Hide collapse button in fullscreen mode */
.bds-ai-workspace.workspace-fullscreen #workspaceCollapseBtn {
  display: none;
}

/* ============================================
   Responsive Adjustments
   ============================================ */
@media (max-width: 991.98px) {
  .bds-ai-workspace .bds-workspace-panel {
    display: none;
  }

  .bds-ai-workspace .bds-workspace-panel.show-mobile {
    display: flex;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1045;
    background: var(--bs-card-bg, #fff);
  }

  .bds-ai-workspace .bds-chat-panel {
    flex: 0 0 100%;
    max-width: 100%;
  }

  .bds-ai-workspace .chat-message {
    max-width: 100%;
  }

  .bds-ai-workspace .chat-message.ai .message-text {
    font-size: 16px;
    max-width: 100%;
  }

  .bds-ai-workspace .chat-message.ai .message-text h2 {
    font-size: 18px;
  }

  .bds-ai-workspace .chat-message.ai .message-text h3 {
    font-size: 16px;
  }

  .bds-ai-workspace .chat-message.ai .message-text table,
  .bds-ai-workspace .chat-message.ai .message-text pre {
    max-width: 100%;
  }
}

@media (min-width: 992px) {
  .bds-ai-workspace .bds-chat-panel {
    border-right: 1px solid var(--bs-border-color);
  }

  .bds-ai-workspace .bds-workspace-panel {
    border-left: none;
  }
}

/* ============================================
   Category Pills
   ============================================ */
.bds-ai-workspace #categoryPills .btn {
  transition: all 0.2s ease;
  --bs-btn-padding-y: 0.29rem;
    --bs-btn-padding-x: 0.4rem;
}

.bds-ai-workspace #categoryPills .btn.active {
  box-shadow: 0 2px 6px rgba(var(--bs-primary-rgb), 0.3);
}

/* ============================================
   History Items in Offcanvas
   ============================================ */
.bds-ai-workspace ~ #chatHistoryOffcanvas .history-item {
  transition: background-color 0.2s ease;
}

.bds-ai-workspace ~ #chatHistoryOffcanvas .history-item:hover {
  background-color: rgba(var(--bs-primary-rgb), 0.04);
}

/* Offcanvas in main content */
#chatHistoryOffcanvas .history-item {
  transition: background-color 0.2s ease;
}

#chatHistoryOffcanvas .history-item:hover {
  background-color: rgba(var(--bs-primary-rgb), 0.04);
}

/* ============================================
   Scrollbar Styling
   ============================================ */
.bds-ai-workspace .bds-chat-body::-webkit-scrollbar,
.bds-ai-workspace .bds-workspace-body::-webkit-scrollbar,
.bds-ai-workspace .table-responsive::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.bds-ai-workspace .bds-chat-body::-webkit-scrollbar-track,
.bds-ai-workspace .bds-workspace-body::-webkit-scrollbar-track,
.bds-ai-workspace .table-responsive::-webkit-scrollbar-track {
  background: transparent;
}

.bds-ai-workspace .bds-chat-body::-webkit-scrollbar-thumb,
.bds-ai-workspace .bds-workspace-body::-webkit-scrollbar-thumb,
.bds-ai-workspace .table-responsive::-webkit-scrollbar-thumb {
  background: var(--bs-gray-400);
  border-radius: 3px;
}

.bds-ai-workspace .bds-chat-body::-webkit-scrollbar-thumb:hover,
.bds-ai-workspace .bds-workspace-body::-webkit-scrollbar-thumb:hover,
.bds-ai-workspace .table-responsive::-webkit-scrollbar-thumb:hover {
  background: var(--bs-primary);
}

/* ============================================
   Run Link in Chat
   ============================================ */
.bds-ai-workspace .run-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  margin-top: 0.5rem;
  padding: 0.375rem 0.75rem;
  background: rgba(var(--bs-primary-rgb), 0.1);
  border-radius: 0.375rem;
  color: var(--bs-primary);
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 500;
  transition: all 0.2s ease;
  cursor: pointer;
}

.bds-ai-workspace .run-link:hover {
  background: var(--bs-primary);
  color: #fff;
}

/* ============================================
   Input Textarea Auto-resize
   ============================================ */
.bds-ai-workspace #messageInput {
  min-height: 38px;
  max-height: 120px;
  overflow-y: auto;
}

/* ============================================
   Tooltip styling
   ============================================ */
.tooltip .tooltip-inner {
    background-color: #ddeeff;
    color: #222;
    text-align: justify;
}

.query-seq-tooltip .tooltip-inner {
    max-width: 420px;
}

.bs-tooltip-top .tooltip-arrow::before,
.bs-tooltip-auto[data-popper-placement^="top"] .tooltip-arrow::before {
    border-top-color: #ddeeff;
}
.bs-tooltip-bottom .tooltip-arrow::before,
.bs-tooltip-auto[data-popper-placement^="bottom"] .tooltip-arrow::before {
    border-bottom-color: #ddeeff;
}
.bs-tooltip-start .tooltip-arrow::before,
.bs-tooltip-auto[data-popper-placement^="left"] .tooltip-arrow::before {
    border-left-color: #ddeeff;
}
.bs-tooltip-end .tooltip-arrow::before,
.bs-tooltip-auto[data-popper-placement^="right"] .tooltip-arrow::before {
    border-right-color: #ddeeff;
}

/* ============================================
   Data Visualization (Phase 1 — ApexCharts)
   ============================================ */
.bds-ai-workspace .ai-viz-block {
  margin-top: 0.5rem;
}

.bds-ai-workspace .ai-viz-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  background: #fff;
  border: 1px solid var(--bs-primary);
  border-radius: 1rem;
  color: var(--bs-primary);
  font-size: 0.8rem;
  line-height: 1.4;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.bds-ai-workspace .ai-viz-chip:hover:not(:disabled) {
  background: var(--bs-primary);
  color: #fff;
}

.bds-ai-workspace .ai-viz-chip:disabled {
  opacity: 0.65;
  cursor: default;
}

.bds-ai-workspace .ai-viz-surface {
  margin-top: 0.5rem;
}

.bds-ai-workspace .ai-viz-card {
  border: 1px solid var(--bs-border-color, #e7e7e7);
  border-radius: 0.5rem;
  padding: 0.75rem;
  background: var(--bs-card-bg, #fff);
  max-width: 100%;
  overflow: hidden;
}

.bds-ai-workspace .ai-viz-head {
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
  color: var(--bs-heading-color, inherit);
}

.bds-ai-workspace .ai-viz-canvas {
  min-height: 260px;
  width: 100%;
}

.bds-ai-workspace .ai-viz-loading {
  display: flex;
  align-items: center;
  padding: 1rem 0;
}

.bds-ai-workspace .ai-viz-fallback {
  margin-top: 0.25rem;
  color: var(--bs-secondary-color, #6c757d);
}

/* ============================================
   Phase 2A.1 — Failed/empty AI response state
   ============================================
   A visible failure state instead of a blank assistant bubble, with a
   "Try Again" retry control styled consistently with the branded purple
   controls used elsewhere in this file (var(--bs-primary), matching the
   .ai-followup-chip / user-bubble treatment above).
   ============================================ */
.bds-ai-workspace .chat-message.ai-response-failed .message-bubble {
  background: #FFF7F5;
  border: 1px solid rgba(220, 53, 69, 0.25);
  border-left: 3px solid #dc3545;
}

.bds-ai-workspace .chat-message.ai-response-failed .message-text {
  color: var(--bs-body-color);
}

/* Row holding both failed-response actions. flex-wrap + min-width: 0 on the
   buttons (below) is what prevents horizontal overflow on narrow/mobile
   widths — the two buttons wrap onto their own lines instead of forcing
   the message bubble wider than the viewport. */
.bds-ai-workspace .ai-retry-actions {
  min-width: 0;
}

.bds-ai-workspace .ai-retry-btn,
.bds-ai-workspace .ai-retry-different-model-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  min-width: 0;
  max-width: 100%;
}

/* "Try again" stays the primary purple action (btn-primary, inherited).
   "Try with a different model" is the secondary/outlined action — same
   purple brand color, outlined instead of filled, so the two are never
   visually confused. btn-outline-primary already resolves to
   var(--bs-primary) via Bootstrap/theme variables, consistent with the
   .ai-followup-chip pattern above. */
.bds-ai-workspace .ai-retry-different-model-btn {
  background: #fff;
}

.bds-ai-workspace .ai-retry-btn:disabled,
.bds-ai-workspace .ai-retry-btn[aria-busy="true"],
.bds-ai-workspace .ai-retry-different-model-btn:disabled,
.bds-ai-workspace .ai-retry-different-model-btn[aria-busy="true"] {
  opacity: 0.65;
  cursor: not-allowed;
}

/* Explicit, visible keyboard-focus state — this file has no established
   :focus-visible convention elsewhere, so define it directly here. */
.bds-ai-workspace .ai-retry-btn:focus-visible,
.bds-ai-workspace .ai-retry-different-model-btn:focus-visible {
  outline: 2px solid var(--bs-primary);
  outline-offset: 2px;
}

/* Helper hint injected into the model selector while a different-model
   retry is pending (see openModelSelectorForRetry). */
.bds-ai-workspace .ai-retry-model-hint {
  white-space: normal;
}

@media (max-width: 575.98px) {
  .bds-ai-workspace .ai-retry-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .bds-ai-workspace .ai-retry-btn,
  .bds-ai-workspace .ai-retry-different-model-btn {
    width: 100%;
    justify-content: center;
  }
}

/* ============================================
   Detection Group alignment color-coding
   ============================================
   Canonical BLASTseq AI oligo colors (must match VIZ_CATEGORY_COLORS/
   viz_specs.py exactly — do not introduce a different palette):
     Forward Primer: #108010   Probe: #E010D0   Reverse Primer: #D03010

   The alignment text is rendered with <code> runs (not <span>/inline
   style — the assistant-HTML sanitizer forbids both; see
   bds-ai-workspace.js's AI_MARKDOWN_ALLOWED_TAGS/FORBID_ATTR and the
   comment above renderClassifiedAlignmentRun). Column alignment between
   the Query line and each accession line depends on every <code> run
   staying strictly inline with zero extra padding/border/font-size change
   — the resets below are load-bearing, not decorative.
   ============================================ */
.bds-ai-workspace .ai-compact-oligo-alignment {
  overflow-x: auto;
}

.bds-ai-workspace .ai-alignment-preview-text {
  white-space: pre;
  overflow-x: visible; /* the scroll container is .ai-compact-oligo-alignment (or the panel) above */
}

.bds-ai-workspace .ai-compact-oligo-alignment code {
  display: inline;
  font: inherit;
  font-size: 1em;
  line-height: inherit;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  white-space: pre;
}

/* Group headings ("Forward" / "Probe" / "Reverse") and the Query line —
   exact canonical colors. */
.bds-ai-workspace .ai-align-heading-forward,
.bds-ai-workspace .ai-align-oligo-forward.ai-align-query {
  color: #108010;
}

.bds-ai-workspace .ai-align-heading-probe,
.bds-ai-workspace .ai-align-oligo-probe.ai-align-query {
  color: #E010D0;
}

.bds-ai-workspace .ai-align-heading-reverse,
.bds-ai-workspace .ai-align-oligo-reverse.ai-align-query {
  color: #D03010;
}

.bds-ai-workspace .ai-align-query {
  font-weight: 600;
}

/* Fully matching accession positions — a darker shade of the same oligo
   color family, distinct from the Query line's exact canonical color so
   "this is the query" and "this position matches the query" read as
   related-but-different at a glance. */
.bds-ai-workspace .ai-align-match.ai-align-oligo-forward {
  color: #0b5c0b;
}

.bds-ai-workspace .ai-align-match.ai-align-oligo-probe {
  color: #a90c9e;
}

.bds-ai-workspace .ai-align-match.ai-align-oligo-reverse {
  color: #9c260f;
}

/* Mismatch/substitution — never relies on color alone: amber/orange
   background + bold weight + a solid underline (border-bottom). */
.bds-ai-workspace .ai-align-mismatch {
  background: #FFDCA0;
  color: #5c3a00;
  font-weight: 700;
  border-bottom: 2px solid #B45309;
}

/* Gap/deletion — muted gray with a DASHED underline (distinct shape from
   mismatch's solid underline, per "do not rely on color alone"). */
.bds-ai-workspace .ai-align-gap {
  color: #8a8f98;
  border-bottom: 1px dashed #8a8f98;
}

/* Insertion marker — distinct cyan/blue, bold (the marker line is a
   separate row beneath the accession's pattern line; see
   buildInsertionMarkerPattern). */
.bds-ai-workspace .ai-align-insertion {
  color: #0891B2;
  font-weight: 700;
}

/* Unknown/ambiguous IUPAC base (N, R, Y, ...) — neutral gray, distinguished
   from a confirmed mismatch by a dotted (not solid/dashed) underline and no
   background fill. */
.bds-ai-workspace .ai-align-ambiguous {
  color: #6b7280;
  border-bottom: 1px dotted #6b7280;
}

/* Compact legend — Match / Mismatch / Gap. Intentionally small: inline
   flex row, small text, no border/background beyond the existing panel. */
.bds-ai-workspace .ai-align-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid rgba(31, 39, 51, 0.08);
}

.bds-ai-workspace .ai-align-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
}

.bds-ai-workspace .ai-align-legend-item code {
  display: inline-block;
  min-width: 1.1em;
  text-align: center;
  padding: 0 0.15rem;
  border-radius: 0.15rem;
}

@media (max-width: 575.98px) {
  .bds-ai-workspace .ai-align-legend {
    gap: 0.5rem;
    font-size: 0.75rem;
  }
}
