/* ═══════════════════════════════════════════════════════════════
   Claims Report Page Styles
   ═══════════════════════════════════════════════════════════════ */


/* ═══════════════════════════════════════════════════════════════
   1. PAGE HEADER & NAVIGATION
   ═══════════════════════════════════════════════════════════════ */
.claims-page-header {
  margin-bottom: 32px;
}

.claims-back-link {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--color-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 16px;
}

.claims-back-link:hover { color: var(--color-gold-text); }
.claims-back-link .material-symbols-outlined { font-size: 15px; }

.claims-page-title {
  font-family: var(--font-serif);
  font-size: 36px;
  line-height: 1.2;
  color: var(--color-ink);
  font-weight: 400;
  margin: 0;
}


/* ═══════════════════════════════════════════════════════════════
   2. LATEST REPORT CARD (Container, Header, Toggle)
   ═══════════════════════════════════════════════════════════════ */
.latest-report-card {
  background: var(--surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 32px;
  margin-bottom: 40px;
  position: relative; /* Anchor point for the floating toggle */
}
/* ── Flex alignment for header download button ── */
.latest-report-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.latest-report-card__header > div:first-child {
  flex: 1;
}
.latest-report-card__header {
  padding-right: 280px; /* Prevents overlapping the toggle on wider screens */
  margin-bottom: 28px;
}

.latest-report-card__title {
  font-family: var(--font-serif);
  font-size: 24px;
  color: var(--color-ink);
  margin: 0 0 4px;
  font-weight: 400;
}

.latest-report-card__date {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--color-muted);
  margin: 0;
}

/* ── Floating Toggle Wrap ── */
.latest-report-toggle-wrap {
  position: absolute;
  top: 32px;
  right: 32px;
}

/* Safeguard: force panels to hide properly */
.latest-tab-panel[hidden] {
  display: none !important;
}

/* ── Claims-Specific KPI Modifiers ── */
.kpi-item__value--rejected { color: var(--status-rejected); }
.kpi-item__value--outstanding { color: var(--status-outstanding); }


/* ═══════════════════════════════════════════════════════════════
   3. CHARTS & PANELS
   ═══════════════════════════════════════════════════════════════ */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 32px;
}

/* CRITICAL FIX: Prevents charts/skeletons from overflowing the grid horizontally */
.charts-row > * {
  min-width: 0;
  overflow: hidden;
}

.charts-row--trend {
  grid-template-rows: 400px;
}

.claims-bar-chart,
.claims-ageing-chart {
  min-height: 220px;
  width: 100%;
}

.chart-panel {
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  padding: 20px;
}

.chart-panel__label {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-subtle);
  margin: 0 0 16px;
}

/* ── Elevated Chart Panel (Trend Section) ── */
.chart-panel--elevated {
  background: var(--surface);
  border: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
}

.chart-panel__header { margin-bottom: 16px; }
.chart-panel__header .chart-panel__label { margin: 0 0 2px; }

.chart-panel__description {
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--color-muted);
  margin: 0;
}

.chart-panel__body {
  flex: 1;
  min-height: 0;
}

/* ═══════════════════════════════════════════════════════════════
   4. DATA TABLES
   ═══════════════════════════════════════════════════════════════ */
.detail-tables-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.detail-tables-row__label,
.claims-detail-section__label {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-subtle);
  margin: 0 0 12px;
}

.claims-detail-section { margin-top: 24px; }

.db-table tr.total-row {
  font-weight: 600;
  background: var(--surface-alt);
}


/* ═══════════════════════════════════════════════════════════════
   5. TREND SECTION & FILTER BAR
   ═══════════════════════════════════════════════════════════════ */
.trend-section-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 20px;
}

.trend-section-divider {
  flex: 1;
  height: 1px;
  background: var(--color-border);
  align-self: center;
}

.trend-section-note {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--color-muted);
  margin: 0;
}

/* ── Filter Bar Container ── */
.claims-trend-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 20px;
  padding: 20px;
  margin-bottom: 24px;
  background: var(--surface-alt);
  border-radius: var(--radius-md);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-group__label {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-muted);
}

/* ── Segmented Toggle (Report Type) ── */
.report-type-toggle {
  display: flex;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
}

.report-type-toggle label {
  position: relative;
  padding: 8px 14px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-subtle);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.report-type-toggle label:not(:last-child) {
  border-right: 1px solid var(--color-border);
}

.report-type-toggle input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.report-type-toggle input[type="radio"]:checked + label,
.report-type-toggle label:has(input[type="radio"]:checked) {
  background: var(--swatch-gold-bg);
  color: var(--swatch-gold-text);
}

/* ── Year Select ── */
.claims-trend-filters select {
  height: 38px;
  padding: 0 12px;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--color-ink);
  background: var(--surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
}

/* ── Checkbox Dropdown Filters ── */
.filter-dropdown { position: relative; }

.filter-dropdown-btn {
  height: 38px;
  padding: 0 14px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-subtle);
  background: var(--surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.filter-dropdown-btn:hover,
.filter-dropdown:focus-within .filter-dropdown-btn {
  color: var(--color-gold-text);
  border-color: var(--color-gold-text);
}

.filter-dropdown-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.filter-dropdown-count {
  font-weight: 400;
  color: var(--color-muted);
  font-size: 12px;
}

.filter-dropdown-btn .material-symbols-outlined {
  font-size: 16px;
  transition: transform 0.2s ease;
}

.filter-dropdown:focus-within .filter-dropdown-btn .material-symbols-outlined {
  transform: rotate(180deg);
}

.filter-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 220px;
  max-height: 280px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-dropdown);
  z-index: 100;
  padding: 8px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.filter-dropdown:focus-within .filter-dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.filter-checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--color-ink);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.filter-checkbox-item:hover { background: var(--surface-muted); }
.filter-checkbox-item input[type="checkbox"] { accent-color: var(--color-gold-text); }
.filter-checkbox-item input[type="checkbox"]:disabled { opacity: 0.4; }
.filter-checkbox-item:has(input:disabled) { color: var(--color-muted); cursor: not-allowed; }

/* ── Apply Button ── */
.apply-filters-btn {
  height: 38px;
  padding: 0 20px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--swatch-gold-strong);
  background: var(--swatch-gold-bg);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease;
}

.apply-filters-btn:hover { background: var(--swatch-gold-hover); }


/* ═══════════════════════════════════════════════════════════════
   6. REPORT HISTORY (Tabs & Accordions)
   ═══════════════════════════════════════════════════════════════ */
.report-history-header { margin-bottom: 16px; }

.report-history-header__title {
  font-family: var(--font-serif);
  font-size: 22px;
  color: var(--color-ink);
  margin: 0 0 4px;
  font-weight: 400;
}

.report-history-header__subtitle {
  font-family: var(--font-serif-alt);
  font-size: 14px;
  color: var(--color-muted);
  margin: 0;
}

.history-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 20px;
}

.history-tab {
  padding: 10px 16px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.history-tab:hover { color: var(--color-gold-text); }

.history-tab.is-active {
  color: var(--color-gold-text);
  border-bottom-color: var(--color-gold-text);
}

.report-history-list {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.history-empty {
  padding: 24px;
  text-align: center;
}

/* ── Accordion Overrides ── */
.claims-accordion-trigger { padding: 16px 24px; }

.claims-accordion-trigger__name {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  color: var(--color-ink);
  margin: 0;
}

.claims-accordion-trigger__date {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--color-muted);
  margin: 2px 0 0;
}

.claims-accordion-trigger .accordion-icon { color: var(--color-muted); }
.claims-accordion-body { padding: 0 24px 24px; }


/* ═══════════════════════════════════════════════════════════════
   7. UTILITIES, SKELETONS & EMPTY STATES
   ═══════════════════════════════════════════════════════════════ */
.no-data-text {
  color: var(--color-muted);
  font-size: 14px;
}

.skeleton--fill { width: 100%; height: 100%; }
.skeleton-text--wide { width: 80%; }
.skeleton-text--medium { width: 60%; }
.skeleton-chart--spaced { margin-top: 12px; }

.trend-skeleton-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 40px;
}

.trend-skeleton-card {
  background: var(--surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 24px;
}

.no-trend-notice {
  text-align: center;
  padding: 48px 24px;
  color: var(--color-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: 40px;
  background: var(--surface);
}

.no-trend-notice__text {
  font-family: var(--font-serif-alt);
  font-size: 15px;
  margin: 0;
}

.empty-state {
  text-align: center;
  padding: 80px 24px;
  color: var(--color-muted);
}

.empty-state__icon {
  font-size: 48px;
  display: block;
  margin-bottom: 12px;
  color: var(--color-border-strong);
}

.empty-state__text {
  font-family: var(--font-serif-alt);
  font-size: 18px;
  margin: 0;
}


/* ═══════════════════════════════════════════════════════════════
   8. RESPONSIVE ADJUSTMENTS
   ═══════════════════════════════════════════════════════════════ */
/* ═══════════════════════════════════════════════════════════════
   8. RESPONSIVE ADJUSTMENTS
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* ── Page Header ── */
  .claims-page-title { font-size: 28px; }

  /* ── Latest Report Card ── */
  .latest-report-toggle-wrap {
    position: static;
    margin-bottom: 24px;
  }
  .latest-report-card__header { padding-right: 0; }

  /* ── Hide specific chart labels on mobile ── */
  .latest-report-card .chart-panel__label {
    display: none;
  }

  /* ── Mobile Segmented Control Fix ── */
  .claims-trend-filters {
    flex-direction: column;
    align-items: stretch; /* Let containers fill width */
  }
  
  /* Force the toggle buttons to share space equally and center text */
  .report-type-toggle {
    width: 100%;
  }
  .report-type-toggle label {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
  }

  /* ── Dropdowns align right on mobile to prevent clipping ── */
  .filter-dropdown-menu {
    left: auto;
    right: 0;
  }

  /* ── Force ALL Graphs & Tables to stack vertically (100% width) ── */
  .charts-row,
  .charts-row--trend,
  .detail-tables-row,
  .trend-skeleton-row {
    grid-template-columns: 1fr; /* 1fr means 100% of the container width */
  }
  
  /* Remove fixed height on trend charts so they grow naturally with content */
  .charts-row--trend { 
    grid-template-rows: auto; 
  }

  /* ── Trend Header Wrap ── */
  .trend-section-header { flex-wrap: wrap; }
  .trend-section-note { width: 100%; text-align: center; }
}