/* Tabs, report view, toast and print layout. Uses the color tokens from styles.css. */

/* ---------------------------------------------------------------------------
   Workspace tabs
   --------------------------------------------------------------------------- */
.workspace_tabs_row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 38px;
}

.workspace_tabs {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  min-width: 0;
  padding-bottom: 2px;
}

/* Tabs look like the chatbot's chat pills: rounded, bold uppercase, solid green when active */
.workspace_tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 240px;
  padding: 5px 6px 5px 12px;
  background-color: var(--bg_panel);
  border: 1px solid var(--border_subtle);
  border-radius: var(--radius_md);
  color: var(--text_muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: var(--shadow_subtle);
  transition: all 0.15s ease;
}

.workspace_tab:hover {
  color: var(--accent_primary_strong);
  border-color: var(--accent_primary);
}

.workspace_tab.active {
  color: #ffffff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent_primary_strong) 0%, var(--accent_primary) 100%);
  box-shadow: var(--shadow_primary);
}

body.dark_theme .workspace_tab.active {
  color: #04120a;
  background: var(--accent_primary);
}

.tab_name {
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab_status_dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background-color: transparent;
}

.workspace_tab.unread .tab_status_dot {
  background-color: var(--accent_primary);
}

.workspace_tab.active.unread .tab_status_dot {
  background-color: #ffffff;
}

.workspace_tab.running .tab_status_dot {
  background-color: var(--accent_gold);
  animation: tab_pulse 1.2s ease-in-out infinite;
}

@keyframes tab_pulse {
  50% { opacity: 0.3; }
}

.tab_close_btn {
  border: none;
  background: transparent;
  color: inherit;
  opacity: 0.6;
  font-size: 15px;
  line-height: 1;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  cursor: pointer;
}

.tab_close_btn:hover {
  opacity: 1;
  color: #ffffff;
  background-color: var(--accent_danger);
}

.tab_rename_input {
  width: 150px;
  font: inherit;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text_main);
  background-color: var(--bg_panel);
  border: 1px solid var(--accent_primary);
  border-radius: 6px;
  padding: 1px 6px;
}

.add_tab_btn {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: var(--radius_md);
  border: 1.5px dashed var(--border_highlight);
  /* Stays visible at the end of the tab strip even when the tabs scroll */
  position: sticky;
  right: 0;
  background-color: var(--bg_app);
  color: var(--accent_primary_strong);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s ease;
}

.add_tab_btn:hover {
  color: #ffffff;
  border-style: solid;
  border-color: var(--accent_primary);
  background-color: var(--accent_primary);
}

.open_report_btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--radius_md);
  border: 1px solid var(--border_highlight);
  background-color: var(--bg_panel);
  color: var(--accent_primary_strong);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: var(--shadow_subtle);
  transition: all 0.15s ease;
}

.open_report_btn:hover,
.open_report_btn.has_items {
  border-color: var(--accent_primary);
}

.open_report_btn:hover {
  background-color: rgba(var(--accent_primary_rgb), 0.08);
}

.report_count {
  min-width: 18px;
  padding: 1px 6px;
  border-radius: var(--radius_full);
  background-color: var(--bg_surface_elevated);
  font-size: 11px;
  text-align: center;
}

.open_report_btn.has_items .report_count {
  background-color: var(--accent_primary);
  color: #ffffff;
}

.pin_pill:disabled,
.pin_result_btn:disabled {
  opacity: 0.7;
  cursor: default;
}

.pin_result_btn.pinned,
.pin_result_btn.pinned:hover {
  color: var(--accent_primary_strong);
  background-color: rgba(var(--accent_primary_rgb), 0.1);
  border-color: var(--border_highlight);
}

.agent_actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Toast notification */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  max-width: min(520px, calc(100vw - 32px));
  padding: 10px 16px;
  border-radius: var(--radius_md);
  background-color: var(--bg_surface_elevated);
  border: 1px solid var(--border_highlight);
  color: var(--text_main);
  font-size: 13px;
  box-shadow: var(--shadow_prominent);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 2000;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------------------------------------------------------------------------
   Report view (always light, like paper)
   --------------------------------------------------------------------------- */
.report_view {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: flex;
  flex-direction: column;
  background-color: rgba(10, 29, 17, 0.6);
}

.report_view.hidden {
  display: none;
}

.report_toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 20px;
  background-color: var(--bg_panel);
  border-bottom: 1px solid var(--border_subtle);
}

.report_toolbar_title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--text_main);
}

.report_toolbar_actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.report_scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px 16px 48px;
}

.report_document {
  max-width: 900px;
  margin: 0 auto;
  background-color: #ffffff;
  color: #0a1d11;
  border-radius: var(--radius_md);
  padding: 40px 48px;
  box-shadow: var(--shadow_prominent);
  font-size: 13px;
  line-height: 1.55;
}

.report_header {
  border-bottom: 3px solid #35af61;
  padding-bottom: 14px;
  margin-bottom: 24px;
}

/* Brand strip at the top of the report (also printed) */
.report_brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.report_brand_tf {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #1b6535;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.report_brand_tf img {
  width: 44px;
  height: 44px;
  object-fit: contain;
}

/* The logo file has wide white margins; negative margins trim them visually */
.report_brand_alliance {
  height: 116px;
  width: auto;
  margin: -36px -30px -36px 0;
}

.report_title_input {
  width: 100%;
  font: inherit;
  font-size: 24px;
  font-weight: 700;
  color: #0a1d11;
  border: 1px dashed transparent;
  border-radius: var(--radius_sm);
  padding: 2px 4px;
  margin-left: -5px;
  background: transparent;
}

.report_title_input:hover,
.report_title_input:focus {
  border-color: #b9d6c2;
  outline: none;
}

.report_print_title {
  font-size: 24px;
  margin: 0;
}

.report_meta {
  margin-top: 6px;
  color: #3f5a48;
  font-size: 12px;
}

.report_empty {
  color: #3f5a48;
  text-align: center;
  padding: 40px 0;
}

.report_item {
  position: relative;
  padding: 20px 0 24px;
  border-bottom: 1px solid #dcebe0;
}

.report_item:last-child {
  border-bottom: none;
}

.report_item_controls {
  position: absolute;
  top: 18px;
  right: 0;
  display: flex;
  gap: 4px;
}

.btn_small {
  padding: 3px 9px;
  font-size: 11px;
}

.report_item_title {
  font-size: 17px;
  margin: 0 170px 4px 0;
}

.report_item_meta {
  color: #6b8574;
  font-size: 11px;
  margin-bottom: 10px;
}

.report_question {
  margin-bottom: 8px;
  color: #2b4535;
}

.report_question span {
  font-weight: 600;
}

.report_summary {
  white-space: pre-line;
  margin-bottom: 12px;
}

.report_metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.report_metric {
  border: 1px solid #dcebe0;
  border-radius: var(--radius_sm);
  padding: 8px 10px;
}

.report_metric_label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b8574;
}

.report_metric_value {
  font-size: 18px;
  font-weight: 700;
}

.report_metric_sub {
  font-size: 11px;
  color: #6b8574;
}

.report_chart {
  display: block;
  width: 100%;
  height: auto;
  margin: 6px 0 12px;
}

.report_table_wrap {
  overflow-x: auto;
  margin-bottom: 10px;
}

.report_table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.report_table th,
.report_table td {
  border-bottom: 1px solid #dcebe0;
  padding: 4px 8px;
  text-align: left;
}

.report_table th {
  background-color: #eaf4ed;
  color: #132c1c;
  font-weight: 700;
}

.report_item_title {
  color: #132c1c;
}

.report_table_note {
  font-size: 11px;
  color: #6b8574;
  margin-top: 4px;
}

.report_note {
  min-height: 36px;
  padding: 8px 10px;
  border: 1px dashed #b9d6c2;
  border-radius: var(--radius_sm);
  white-space: pre-wrap;
  color: #0a1d11;
  margin-bottom: 10px;
}

.report_note:empty::before {
  content: attr(data-placeholder);
  color: #8fa898;
}

.report_note:focus {
  outline: none;
  border-color: #35af61;
}

.report_sql summary {
  cursor: pointer;
  color: #3f5a48;
  font-size: 12px;
}

.report_sql pre {
  white-space: pre-wrap;
  font-family: var(--font_mono);
  font-size: 10.5px;
  background-color: #f6faf7;
  border: 1px solid #dcebe0;
  border-radius: var(--radius_sm);
  padding: 10px;
}

.print_only {
  display: none;
}

body.report_open {
  overflow: hidden;
}

@media (max-width: 480px) {
  .workspace_tab {
    max-width: 150px;
  }
}

@media (max-width: 640px) {
  .report_document {
    padding: 24px 16px;
  }

  .report_item_controls {
    position: static;
    margin-bottom: 8px;
  }

  .report_item_title {
    margin-right: 0;
  }
}

/* Printing the report: hide the app, print the document as plain pages */
@media print {
  body.print_report > *:not(#report_view) {
    display: none !important;
  }

  body.print_report {
    background: #ffffff !important;
    overflow: visible !important;
    height: auto !important;
  }

  body.print_report .report_view {
    position: static;
    background: none;
    display: block;
  }

  body.print_report .report_toolbar,
  body.print_report .no_print {
    display: none !important;
  }

  body.print_report .print_only {
    display: block;
  }

  body.print_report .report_scroll {
    overflow: visible;
    padding: 0;
  }

  body.print_report .report_document {
    max-width: none;
    box-shadow: none;
    border-radius: 0;
    padding: 0;
  }

  body.print_report .report_item {
    break-inside: avoid-page;
  }

  body.print_report .report_item_title {
    margin-right: 0;
  }

  body.print_report .report_note {
    border: none;
    padding: 0;
    font-style: italic;
  }

  body.print_report .report_note:empty {
    display: none;
  }

  body.print_report .report_table_wrap {
    overflow: visible;
  }
}
