/**
 * DFO Dashboard - Addepar-Style Table Formatting
 * Institutional-quality reporting styles matching Addepar's design language
 * Integrates with shared-theme.css variables and supports dark mode
 */

/* ========================================
   BASE TABLE STRUCTURE
   ======================================== */

.addepar-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.5;
}

/* ========================================
   HEADERS
   ======================================== */

.addepar-table th {
  text-transform: uppercase;
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
  text-align: left;
}

.addepar-table th.num {
  text-align: right;
}

/* ========================================
   DATA CELLS
   ======================================== */

.addepar-table td {
  padding: 8px 14px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-light);
}

/* Numeric columns */
.addepar-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}

/* Ticker column */
.addepar-table .ticker-col {
  font-weight: 600;
  color: var(--accent);
}

/* ========================================
   SPECIAL ROWS
   ======================================== */

/* Total rows */
.addepar-table .total-row {
  border-top: 2px solid var(--text-secondary);
  font-weight: 700;
}

.addepar-table .total-row td {
  padding-top: 12px;
  padding-bottom: 12px;
}

/* Group parent rows */
.addepar-table .group-parent {
  font-weight: 700;
  background: var(--bg-secondary);
}

/* Indented child rows */
.addepar-table .group-child td:first-child {
  padding-left: 32px;
}

/* Benchmark comparison rows */
.addepar-table .benchmark-row {
  font-style: italic;
  color: var(--text-secondary);
}

.addepar-table .benchmark-row .outperform {
  color: var(--green);
  font-weight: 600;
}

.addepar-table .benchmark-row .underperform {
  color: var(--red);
  font-weight: 600;
}

/* ========================================
   VALUE FORMATTING
   ======================================== */

/* Parenthetical negatives */
.addepar-table .pct-negative {
  color: var(--red);
}

/* Em dash for empty/zero values */
.addepar-table .empty-val {
  color: var(--text-muted);
}

/* ========================================
   INTERACTION STATES
   ======================================== */

/* Hover state — subtle */
.addepar-table tbody tr:hover {
  background: rgba(255,255,255,0.02);
}

/* Sortable columns */
.addepar-table th.sortable {
  cursor: pointer;
  position: relative;
}

.addepar-table th.sortable:hover {
  color: var(--text-primary);
}

.addepar-table th.sort-asc::after {
  content: ' ▲';
  font-size: 8px;
  color: var(--accent);
  margin-left: 4px;
}

.addepar-table th.sort-desc::after {
  content: ' ▼';
  font-size: 8px;
  color: var(--accent);
  margin-left: 4px;
}

/* ========================================
   COLLAPSIBLE GROUPS
   ======================================== */

.addepar-table .group-toggle {
  cursor: pointer;
  user-select: none;
}

.addepar-table .group-toggle::before {
  content: '▼';
  margin-right: 8px;
  font-size: 8px;
  display: inline-block;
  transition: transform 0.2s ease;
}

.addepar-table .group-toggle.collapsed::before {
  transform: rotate(-90deg);
}

.addepar-table .group-collapsed {
  display: none;
}

/* ========================================
   ALTERNATING ROWS (OPTIONAL)
   ======================================== */

.addepar-table.striped tbody tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.02);
}

[data-theme="dark"] .addepar-table.striped tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

/* ========================================
   STOCK PAGE BREADCRUMB
   ======================================== */

.stock-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 0 4px;
  font-size: 12px;
  font-weight: 500;
}

.stock-breadcrumb .breadcrumb-entity {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 11px;
  font-weight: 500;
  transition: all 0.15s ease;
}

.stock-breadcrumb .breadcrumb-entity:hover {
  color: var(--text-primary);
  border-color: var(--accent);
  background: var(--bg-secondary);
}

.stock-breadcrumb .breadcrumb-sector {
  padding: 4px 10px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
}

/* ========================================
   REPORT MODE TOGGLE BUTTON
   ======================================== */

.report-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.report-mode-btn:hover {
  background: var(--accent-hover);
  color: #ffffff;
  border-color: var(--accent-hover);
}

.report-mode-btn svg {
  width: 14px;
  height: 14px;
}

/* ========================================
   RESPONSIVE ADJUSTMENTS
   ======================================== */

@media (max-width: 768px) {
  .addepar-table th,
  .addepar-table td {
    padding: 6px 8px;
  }

  .addepar-table {
    font-size: 12px;
  }

  .addepar-table th {
    font-size: 9px;
  }

  .addepar-table .num {
    font-size: 11px;
  }
}

/* ========================================
   DARK MODE ADJUSTMENTS
   ======================================== */

[data-theme="dark"] .addepar-table td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .addepar-table th {
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
}

[data-theme="dark"] .addepar-table .total-row {
  border-top: 1px solid rgba(255, 255, 255, 0.15);
}
