/*
 * Bot Hound — Report Page Styles
 *
 * C2 Warm Earth theme. Requires theme.css to be loaded first.
 * Used by the server-rendered report page at /report/{id}.
 *
 * Class prefix: report-
 */

/* ============================================================
   1. Report container
   ============================================================ */

.report-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 32px 24px;
  background: var(--color-bg-panel);
  color: var(--color-text-default);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  border-left: 1px solid var(--color-border-default);
  border-right: 1px solid var(--color-border-default);
  min-height: 100vh;
}

/* ============================================================
   2. Report header
   ============================================================ */

.report-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--color-border-default);
  margin-bottom: 24px;
  position: relative;
}

.report-branding {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--color-text-muted);
  font-size: 13px;
  font-weight: 600;
}

.report-branding:hover {
  color: var(--color-text-primary);
  text-decoration: none;
}

.report-branding-logo {
  width: 24px;
  height: 24px;
}

/* Header avatar: bc-avatar bc-avatar--lg in bot-card.css provides these for new reports.
   Kept here for backward compat with existing S3 reports that don't load bot-card.css. */
.report-header-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--color-border-muted);
  transition: border-color 0.15s;
}

.report-header-avatar:hover {
  border-color: var(--color-accent-teal);
}

.report-header-info {
  flex: 1;
  min-width: 0;
}

/* Header name/handle: bc-name/bc-handle in bot-card.css provides base for new reports.
   Kept here for backward compat with existing S3 reports. */
.report-header-display-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0 0 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.report-header-display-name a {
  color: inherit;
  text-decoration: none;
}

.report-header-display-name a:hover {
  text-decoration: underline;
}

.report-header-username {
  font-size: 14px;
  color: var(--color-text-muted);
  margin: 0 0 4px 0;
}

.report-header-username a {
  color: var(--color-accent-teal);
  text-decoration: none;
}

.report-header-username a:hover {
  text-decoration: underline;
}

.report-header-meta {
  font-size: 13px;
  color: var(--color-text-dim);
  margin: 0;
}

.report-header-meta span + span::before {
  content: " · ";
}

/* ============================================================
   3. Stat cards
   ============================================================ */

.report-stat-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.report-stat-card {
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border-default);
  border-radius: 8px;
  padding: 20px 12px;
  text-align: center;
}

.report-stat-card-value {
  display: block;
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 8px;
}

.report-stat-card-value--real {
  color: var(--color-score-real);
}

.report-stat-card-value--suspect {
  color: var(--color-score-suspect);
}

.report-stat-card-value--bot {
  color: var(--color-score-bot);
}

.report-stat-card-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

/* ============================================================
   4. Stacked bar
   ============================================================ */

.report-stacked-bar {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 24px;
}

.report-stacked-bar-segment--real {
  background: var(--color-score-real);
}

.report-stacked-bar-segment--suspect {
  background: var(--color-score-suspect);
}

.report-stacked-bar-segment--bot {
  background: var(--color-score-bot);
}

/* ============================================================
   5. Probability histogram
   ============================================================ */

.report-histogram {
  margin-bottom: 24px;
}

.report-histogram:has(+ .report-threshold-slider) {
  margin-bottom: 0;
}

.report-histogram + .report-histogram {
  margin-top: 32px;
}

.report-threshold-slider + .report-histogram {
  margin-top: 32px;
}

.report-histogram-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

.report-histogram-chart {
  display: flex;
  align-items: flex-end;
  gap: 0;
  height: 160px;
  padding-bottom: 0;
  position: relative;
}

/* Grid lines only on the probability distribution chart (not stacked) */
.report-histogram-chart:not(.report-histogram-chart--stacked) {
  background:
    repeating-linear-gradient(
      to top,
      transparent,
      transparent calc(25% - 1px),
      var(--color-border-default) calc(25% - 1px),
      var(--color-border-default) 25%
    );
}

.report-histogram-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%;
  cursor: default;
  padding: 0 2px;
  transition: opacity 0.15s;
}

.report-histogram-chart:hover .report-histogram-col {
  opacity: 0.4;
}

.report-histogram-chart:hover .report-histogram-col:hover {
  opacity: 1;
}

.report-histogram-bar {
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  transition: background-color 0.15s;
}

.report-histogram-bar--low {
  background: var(--color-score-real);
}

.report-histogram-bar--mid {
  background: var(--color-score-suspect);
}

.report-histogram-bar--high {
  background: var(--color-score-bot);
}

/* Stacked column bars (age histogram) */
.report-histogram-chart--stacked {
  align-items: flex-end;
}

.report-histogram-stacked-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  border-radius: 3px 3px 0 0;
  overflow: hidden;
}

.report-histogram-seg {
  width: 100%;
  min-height: 0;
}

.report-histogram-seg--bot {
  background: var(--color-score-bot);
}

.report-histogram-seg--suspect {
  background: var(--color-score-suspect);
}

.report-histogram-seg--real {
  background: var(--color-score-real);
}

.report-histogram-x-axis {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.report-histogram-x-label {
  flex: 1;
  font-size: 10px;
  color: var(--color-text-muted);
  text-align: center;
}

.report-histogram-endpoints {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* --- 4c. Threshold slider --- */

.report-threshold-slider {
  position: relative;
  padding: 12px 0 0;
}

.report-threshold-track {
  position: relative;
  height: 32px;
}

.report-threshold-track-bg {
  position: absolute;
  left: 0;
  right: 0;
  top: 12px;
  height: 4px;
  background: var(--color-border-default, #3f3f46);
  border-radius: 2px;
}

.report-threshold-zone {
  position: absolute;
  top: 12px;
  height: 4px;
}

.report-threshold-zone--human {
  background: var(--color-score-real);
  border-radius: 2px 0 0 2px;
}

.report-threshold-zone--suspect {
  background: var(--color-score-suspect);
}

.report-threshold-zone--bot {
  background: var(--color-score-bot);
  border-radius: 0 2px 2px 0;
}

.report-threshold-handle {
  position: absolute;
  top: 4px;
  width: 20px;
  height: 20px;
  border: 2px solid #fff;
  border-radius: 50%;
  cursor: grab;
  z-index: 2;
  transform: translateX(-10px);
  touch-action: none;
}

.report-threshold-handle:active {
  cursor: grabbing;
}

.report-threshold-handle:focus {
  outline: 2px solid var(--color-accent-teal, #2dd4bf);
  outline-offset: 2px;
}

.report-threshold-handle--suspect {
  background: var(--color-score-suspect);
}

.report-threshold-handle--bot {
  background: var(--color-score-bot);
}

.report-threshold-label {
  position: absolute;
  top: 28px;
  font-size: 11px;
  font-weight: 600;
  transform: translateX(-50%);
  white-space: nowrap;
}

.report-threshold-label--suspect {
  color: var(--color-score-suspect);
}

.report-threshold-label--bot {
  color: var(--color-score-bot);
}

.report-threshold-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--color-text-dim, #a1a1aa);
}

.report-threshold-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.report-threshold-legend-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.report-threshold-reset {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--color-accent-teal, #2dd4bf);
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: text-decoration-color 0.15s;
}

.report-threshold-reset:hover {
  text-decoration-color: currentColor;
}

/* Y-axis labels positioned at top and bottom of chart, right side */
.report-histogram-y-axis {
  position: absolute;
  right: -4px;
  top: 0;
  bottom: 0;
  transform: translateX(100%);
  pointer-events: none;
}
.report-histogram-y-label {
  position: absolute;
  left: 0;
  font-size: 10px;
  color: var(--color-text-muted);
  line-height: 1;
}
.report-histogram-y-label:first-child {
  top: 0;
  transform: translateY(-50%);
}
.report-histogram-y-label:last-child {
  bottom: 0;
  transform: translateY(50%);
}

/* ============================================================
   6. Stats table
   ============================================================ */

.report-stats-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
  font-size: 14px;
}

.report-stats-table th,
.report-stats-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--color-border-default);
}

.report-stats-table th {
  font-weight: 600;
  color: var(--color-text-secondary);
  width: 50%;
}

.report-stats-table td {
  color: var(--color-text-default);
}

.report-stats-table tr:last-child th,
.report-stats-table tr:last-child td {
  border-bottom: none;
}

/* ============================================================
   7. Sampling callout
   ============================================================ */

.report-sampling-callout {
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border-default);
  border-radius: 6px;
  padding: 16px 20px;
  margin-bottom: 24px;
  font-size: 13px;
  color: var(--color-text-muted);
  line-height: 1.5;
}

.report-sampling-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-secondary);
  margin-bottom: 12px;
}

.report-sampling-text {
  margin-top: 10px;
  margin-bottom: 0;
}

/* Single-column layout: dot grid + stats */
.report-sampling-columns {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  align-items: start;
}

.report-sampling-left {
  min-width: 0;
}

/* Visual sampling guide — reuses vetting bar classes */
.report-sampling-viz {
  margin-bottom: 0;
}

/* Ensure the vetting bar classes work inside the report context */
.report-sampling-callout .sampling-bar-outer {
  position: relative;
  height: 28px;
  background: var(--color-border-default, #e7e5e4);
  border-radius: 4px;
  overflow: hidden;
  pointer-events: none;
}

.report-sampling-callout canvas {
  pointer-events: none;
}

.report-sampling-callout .sampling-bar-depth {
  position: relative;
  height: 100%;
  background: rgba(13, 148, 136, 0.18);
  border-radius: 4px 0 0 4px;
}

.report-sampling-callout .sampling-bar-labels {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  font-size: 11px;
  color: var(--color-text-muted);
  margin-bottom: 3px;
}

.report-sampling-callout .sampling-bar-labels .label-left {
  position: absolute;
  left: 0;
}

.report-sampling-callout .sampling-bar-labels .label-right {
  position: absolute;
  right: 0;
}

.report-sampling-callout .dot-legend {
  color: #0d7d74;
  font-weight: 500;
  font-size: 11px;
  text-align: center;
}

.report-sampling-callout .sampling-bar-bottom {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--color-text-dim);
  margin-top: 4px;
}

/* ============================================================
   8. Bot cards
   ============================================================ */

.report-bot-list {
  margin-bottom: 24px;
}

.report-bot-list-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin: 0 0 12px 0;
}

.report-bot-card {
  display: grid;
  grid-template-columns: 24px 32px minmax(100px, 180px) 40px 1fr;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border-default);
  max-width: 100%;
  overflow: hidden;
}

.report-bot-name-group {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex-shrink: 1;
}

.report-bot-number {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-dim);
  min-width: 24px;
  text-align: right;
  flex-shrink: 0;
}

.report-bot-card:last-child {
  border-bottom: none;
}

/* Bot avatar: bc-avatar bc-avatar--sm in bot-card.css provides these for new reports.
   Kept here for backward compat with existing S3 reports. */
.report-bot-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

/* Bot display name: bc-name bc-name--inline in bot-card.css provides these for new reports.
   Kept here for backward compat with existing S3 reports. */
.report-bot-display-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
  display: block;
}

/* Bot username: bc-handle bc-handle--inline in bot-card.css provides these for new reports.
   Kept here for backward compat with existing S3 reports. */
.report-bot-username {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-accent-teal);
  text-decoration: none;
  display: block;
}

.report-bot-username:hover {
  text-decoration: underline;
}

/* Bot probability: bc-prob/bc-prob--* in bot-card.css provides these for new reports.
   Kept here for backward compat with existing S3 reports. */
.report-bot-prob {
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.report-bot-prob--low {
  color: var(--color-score-real);
}

.report-bot-prob--mid {
  color: var(--color-score-suspect);
}

.report-bot-prob--high {
  color: var(--color-score-bot);
}

/* Bot reasons: bc-reasons in bot-card.css provides flex-wrap for new reports.
   Kept here for backward compat with existing S3 reports. */
.report-bot-reasons {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

/* ============================================================
   9. Reason tags
   ============================================================ */

/* Reason tags: bc-reason in bot-card.css provides these for new reports.
   Kept here for backward compat with existing S3 reports. */
.report-reason-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 3px;
  background: #f5f0ee;
  color: #78716c;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
  vertical-align: middle;
}

/* ============================================================
   10. Share / export bar
   ============================================================ */

.report-share-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding: 16px 0;
  border-top: 1px solid var(--color-border-default);
  border-bottom: 1px solid var(--color-border-default);
}

.report-share-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid var(--color-border-muted);
  background: var(--color-bg-panel);
  color: var(--color-text-secondary);
  transition: background 0.15s;
}

.report-share-btn:hover {
  background: var(--color-bg-subtle);
}

.report-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  border: none;
  background: var(--color-accent-teal);
  color: #ffffff;
  transition: background 0.15s;
}

.report-download-btn:hover {
  background: var(--color-btn-green-hover);
}

/* ============================================================
   11. CTA section
   ============================================================ */

.report-cta {
  text-align: center;
  padding: 32px 24px;
  background: var(--color-bg-subtle);
  border-radius: 8px;
  margin-bottom: 24px;
}

.report-cta-heading {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text-primary);
  margin: 0 0 8px 0;
}

.report-cta-body {
  font-size: 15px;
  color: var(--color-text-secondary);
  margin: 0 0 20px 0;
}

.report-cta-btn {
  display: inline-flex;
  align-items: center;
  padding: 12px 28px;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  background: var(--color-accent-teal);
  color: #ffffff;
  transition: background 0.15s;
}

.report-cta-btn:hover {
  background: var(--color-btn-green-hover);
}

/* ============================================================
   11b. Pagination controls
   ============================================================ */

.report-pagination {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 0;
  font-size: 14px;
}

/* Row 1: page buttons centered */
.report-pg-nav-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
}

/* Row 2: info + controls */
.report-pg-meta-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.report-pg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid var(--color-border-muted);
  background: var(--color-bg-panel);
  color: var(--color-text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.report-pg-btn:hover:not(.report-pg-btn--active):not(.report-pg-btn--disabled) {
  background: var(--color-bg-subtle);
}

.report-pg-btn--active {
  background: var(--color-accent-teal);
  color: #ffffff;
  border-color: var(--color-accent-teal);
  cursor: default;
  font-weight: 600;
}

.report-pg-btn--disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

.report-pg-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 34px;
  color: var(--color-text-muted);
  font-size: 14px;
  user-select: none;
}

.report-pg-controls {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.report-pg-jump {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.report-pg-jump input {
  width: 52px;
  height: 30px;
  padding: 0 6px;
  border: 1px solid var(--color-border-muted);
  border-radius: 6px;
  background: var(--color-bg-panel);
  color: var(--color-text-default);
  font-size: 13px;
  text-align: center;
}

.report-pg-jump label {
  color: var(--color-text-muted);
  font-size: 13px;
}

.report-per-page {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.report-per-page select {
  height: 30px;
  padding: 0 6px;
  border: 1px solid var(--color-border-muted);
  border-radius: 6px;
  background: var(--color-bg-panel);
  color: var(--color-text-default);
  font-size: 13px;
  cursor: pointer;
}

.report-per-page label {
  color: var(--color-text-muted);
  font-size: 13px;
}

.report-pg-info {
  color: var(--color-text-muted);
  font-size: 13px;
  white-space: nowrap;
}

.report-pagination--loading .report-pg-btn {
  pointer-events: none;
  opacity: 0.5;
}

/* ============================================================
   12. Print styles
   ============================================================ */

@media print {
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  .report-share-bar,
  .report-cta,
  .report-pagination,
  nav,
  header > *:not(.report-print-header) {
    display: none !important;
  }

  body {
    background: #ffffff !important;
  }

  .report-container {
    max-width: 100%;
    padding: 0;
    background: #ffffff;
  }

  .report-stat-card,
  .report-sampling-callout {
    box-shadow: none !important;
    border: 1px solid #ccc !important;
  }

  .report-sampling-callout {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .report-histogram {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .report-bot-list {
    page-break-before: always;
  }

  .report-print-branding {
    display: block;
    font-size: 12px;
    color: #666;
    margin-bottom: 8px;
    font-weight: 600;
    letter-spacing: 0.05em;
  }

  .report-bot-card:nth-child(n+21) {
    display: none;
  }

  .report-reason-tag {
    max-width: none;
    white-space: normal;
  }

  .report-tooltip {
    display: none !important;
  }
}

/* Hide print-only branding on screen */
.report-print-branding {
  display: none;
}

/* ============================================================
   13. Custom histogram tooltip
   ============================================================ */

.report-tooltip {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  background: var(--color-bg-elevated, #23272f);
  color: var(--color-text, #e4e4e7);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.72rem;
  line-height: 1.3;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.08s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  border: 1px solid var(--color-border-muted, #3a3f47);
}

.report-tooltip.visible {
  opacity: 1;
}
.report-tooltip table {
  white-space: nowrap;
}

/* ============================================================
   14. Responsive — mobile
   ============================================================ */

@media (max-width: 768px) {
  .report-container {
    padding: 20px 16px;
  }

  .report-stat-cards {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .report-stat-card {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    text-align: left;
    gap: 12px;
  }

  .report-stat-card-value {
    font-size: 28px;
    margin-bottom: 0;
  }

  .report-bot-card {
    grid-template-columns: 24px 32px 1fr;
    grid-template-rows: auto auto;
  }
  .report-bot-card .report-bot-prob {
    grid-column: 3;
  }
  .report-bot-card .report-bot-reasons {
    grid-column: 1 / -1;
  }

  .report-bot-reasons {
    width: 100%;
    margin-top: 4px;
  }

  .report-share-bar {
    flex-wrap: wrap;
  }

  .report-pg-btn:not(.report-pg-nav) {
    display: none;
  }
  .report-pg-ellipsis {
    display: none;
  }
  .report-pg-meta-row {
    justify-content: center;
  }
}
