/* Reporting Overlay Styles */

.reporting-overlay {
  position: fixed;
  inset: 0;
  z-index: 1050;
  background: var(--bs-body-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Controls bar (date range, queue selector, close) */
.reporting-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1.5rem;
  border-bottom: 1px solid var(--bs-border-color);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.reporting-controls label {
  font-size: 0.8rem;
  margin-bottom: 0;
  white-space: nowrap;
}

.reporting-controls .form-control,
.reporting-controls .form-select {
  font-size: 0.85rem;
  padding: 0.25rem 0.5rem;
  height: auto;
}

.reporting-date-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.reporting-range-hint {
  font-size: 0.7rem;
  white-space: nowrap;
}

.reporting-queue-menu {
  min-width: 240px;
  max-height: 320px;
  overflow-y: auto;
}

.reporting-queue-menu .dropdown-item {
  cursor: pointer;
  font-size: 0.82rem;
  padding: 0.4rem 0.5rem;
}

.reporting-preset-btns .btn {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
}

/* Main content area (sidebar + report area) */
.reporting-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar navigation */
.reporting-sidebar {
  width: 220px;
  border-right: 1px solid var(--bs-border-color);
  overflow-y: auto;
  flex-shrink: 0;
  padding: 0.5rem 0;
}

.reporting-sidebar .nav-link {
  width: auto;
  height: auto;
  margin: 0.125rem 0.5rem;
  padding: 0.5rem 0.75rem;
  border: none !important;
  border-radius: 0.375rem;
  text-align: left;
  font-size: 0.85rem;
  color: var(--bs-body-color);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.reporting-sidebar .nav-link:hover {
  background: var(--bs-tertiary-bg);
}

.reporting-sidebar .nav-link.active {
  background: var(--bs-primary);
  color: #fff;
}

.reporting-sidebar .nav-link i {
  width: 1.25rem;
  text-align: center;
}

.reporting-sidebar .nav-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--bs-secondary-color);
  padding: 0.75rem 0.75rem 0.25rem;
  margin-top: 0.5rem;
}

/* Report content area */
.reporting-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

.reporting-content-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--bs-secondary-color);
}

.reporting-content-empty i {
  font-size: 3rem;
  margin-bottom: 1rem;
}

/* Loading state */
.reporting-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--bs-secondary-color);
}

/* Metric summary cards at the top of reports */
.reporting-content .card {
  padding: 0.75rem 1.25rem !important;
  max-width: none !important;
  min-width: 140px;
  border-radius: 0.5rem;
}

.reporting-content .card small {
  font-size: 0.75rem;
  margin-bottom: 0.25rem;
}

.reporting-content .card strong {
  font-size: 1.25rem;
  line-height: 1.2;
}

.reporting-metric-label {
  cursor: help;
  text-decoration-line: underline;
  text-decoration-style: dotted;
  text-decoration-color: var(--bs-secondary-color);
  text-underline-offset: 0.2rem;
}

.reporting-metric-label:focus-visible {
  outline: 2px solid var(--bs-primary);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Chart containers */
.reporting-chart-container {
  position: relative;
  width: 100%;
  max-height: 400px;
  margin-bottom: 1.5rem;
}

/* Data tables within reports */
.reporting-table {
  font-size: 0.85rem;
  color: var(--bs-body-color);
}

.reporting-table th {
  white-space: nowrap;
  font-weight: 600;
  color: var(--bs-body-color);
  background-color: var(--bs-tertiary-bg);
  border-bottom: 2px solid var(--bs-border-color);
}

.reporting-table tfoot td {
  font-weight: 600;
  color: var(--bs-body-color);
  background-color: var(--bs-tertiary-bg);
  border-top: 2px solid var(--bs-border-color);
}

/* Tree table styling for hierarchical reports */
.tree-table {
  table-layout: fixed;
  width: 100%;
}

.tree-table .tree-toggle-btn {
  background: transparent;
  border: none;
  padding: 0;
  margin-right: 6px;
  cursor: pointer;
  color: var(--bs-primary);
  font-size: 0.75rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 3px;
  transition: transform 0.15s ease, background-color 0.15s ease;
}

.tree-table .tree-toggle-btn:hover {
  background-color: var(--bs-tertiary-bg);
}

.tree-table .tree-row-parent {
  font-weight: 600;
}

.tree-table .tree-row-child {
  background-color: transparent;
}

.tree-table .tree-branch-icon {
  color: var(--bs-secondary-color);
  font-size: 0.75rem;
  margin-right: 6px;
  display: inline-block;
  width: 14px;
  text-align: center;
}

.tree-table .tree-code-cell {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Tab text overflow fix */
.reporting-content .nav-tabs .nav-link {
  width: auto;
  height: auto;
  margin: 0;
  padding: 0.5rem 0.75rem;
  border: none !important;
  border-bottom: 2px solid transparent !important;
  border-radius: 0;
  white-space: nowrap;
  font-size: 0.85rem;
  text-align: left;
}

/* Timeline Markers Menu & Modal Styles */
.reporting-markers-menu {
  min-width: 320px;
  max-width: 380px;
  font-size: 0.85rem;
}

.reporting-marker-category-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.reporting-category-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.2rem 0.45rem;
  border-radius: 1rem;
  background-color: var(--bs-tertiary-bg);
  border: 1px solid var(--bs-border-color);
  color: var(--bs-body-color);
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease-in-out;
}

.reporting-category-filter-chip:hover {
  border-color: var(--cat-color);
}

.reporting-category-filter-chip.active {
  background-color: var(--bs-body-bg);
  border-color: var(--cat-color);
  box-shadow: 0 0 0 1px var(--cat-color);
}

.reporting-category-filter-chip .cat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.reporting-category-filter-chip .cat-count {
  font-size: 0.68rem;
  color: var(--bs-secondary-color);
}

.reporting-marker-list {
  max-height: 200px;
  overflow-y: auto;
}

.reporting-marker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border-radius: 0.25rem;
  transition: background-color 0.15s ease-in-out;
}

.reporting-marker-item:hover {
  background-color: var(--bs-tertiary-bg);
}

.reporting-marker-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 0.25rem;
  color: #ffffff;
}

.reporting-color-picker-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.1s ease-in-out;
}

.reporting-color-picker-btn:hover,
.reporting-color-picker-btn.active {
  transform: scale(1.15);
  border-color: var(--bs-body-color);
}

/* Responsive: tablet */
@media (max-width: 991px) {
  .reporting-sidebar {
    width: 180px;
  }
}

@media (max-width: 767px) {
  .reporting-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--bs-border-color);
    max-height: 200px;
  }

  .reporting-body {
    flex-direction: column;
  }

  .reporting-controls {
    padding: 0.5rem 0.75rem;
  }
}

/* Print / PDF Export Styling */
@media print {
  /* Hide application shell, navbars, sidebars, modals and overlay controls */
  body > *:not(#reportingOverlay) {
    display: none !important;
  }

  .reporting-controls,
  .reporting-sidebar,
  .reporting-retry-btn,
  .nav-tabs,
  .btn {
    display: none !important;
  }

  .reporting-overlay {
    position: static !important;
    inset: auto !important;
    width: 100% !important;
    min-height: 100% !important;
    overflow: visible !important;
    background: #ffffff !important;
    color: #000000 !important;
    display: block !important;
  }

  .reporting-body {
    display: block !important;
    overflow: visible !important;
  }

  .reporting-content {
    padding: 0 !important;
    overflow: visible !important;
  }

  /* Show all tab panes in multi-tab reports during print */
  .reporting-print-all-tabs .tab-content > .tab-pane {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    margin-bottom: 2rem;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .reporting-print-header,
  .reporting-print-tab-header {
    display: block !important;
  }

  .reporting-content .card {
    border: 1px solid #dee2e6 !important;
    box-shadow: none !important;
    page-break-inside: avoid;
    break-inside: avoid;
    background: #f8f9fa !important;
    color: #000000 !important;
  }

  .reporting-chart-container,
  canvas {
    max-width: 100% !important;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  table {
    page-break-inside: auto;
    width: 100% !important;
  }

  tr {
    page-break-inside: avoid;
    break-inside: avoid;
  }
}
