/* Shared report output styling (dashboard widgets + Reports pages).
   Ported from the Angular report-widget scss. */

.report-table-container {
    margin-bottom: 8px;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}

.report-table th {
    background: var(--mud-palette-primary, #5A9ED6);
    color: #fff;
    padding: 6px 8px;
    text-align: left; /* Angular parity: column headers are left-aligned */
    font-weight: 600;
    white-space: nowrap;
}

/* Banded tables mirror ngx-datatable "force" mode: all columns equal width. */
.report-table.report-table-fixed {
    table-layout: fixed;
}

.report-table.report-table-fixed td,
.report-table.report-table-fixed th {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.report-table td {
    padding: 4px 8px;
    border-bottom: 1px solid #eef0f3;
    vertical-align: middle;
}

.report-table th.report-group-header-cell {
    border-left: 2px solid #fff;
    border-right: 2px solid #fff;
    text-align: center; /* group band labels stay centered (Angular justify-content-center) */
}

.report-table th.report-group-header-blank {
    background: transparent;
}

.report-footer-band {
    background: var(--mud-palette-primary, #5A9ED6);
    color: #fff;
    font-weight: 600;
    font-size: 0.78rem;
    padding: 6px 8px;
    margin-top: 6px;
}

.report-cell-number, .report-cell-currency {
    text-align: right;
    padding-right: 6px;
}

.report-cell-date {
    text-align: center;
}

/* Angular parity: $ pinned to the left edge, amount right-aligned. */
.report-currency-wrap {
    position: relative;
    width: 100%;
}

.report-currency-symbol {
    position: absolute;
    left: 0;
    top: 0;
    width: 10px;
    padding-left: 3px;
}

.report-cell-value {
    text-align: right;
    padding-left: 10px;
    padding-right: 3px;
}

/* Long numbers step down in size so they fit narrow widget columns. */
.report-cell-value.report-cell-value-sm {
    font-size: 13px;
}

.report-cell-value.report-cell-value-xs {
    font-size: 11px;
}

/* Dollar sign shrinks along with the value it prefixes. */
.report-currency-symbol.report-cell-value-sm {
    font-size: 13px;
}

.report-currency-symbol.report-cell-value-xs {
    font-size: 11px;
}

.report-cell-label {
    background: var(--mud-palette-primary, #5A9ED6);
    color: #fff;
    text-align: center;
    font-weight: 600;
    padding: 10px 8px;
}

.report-cell-callout {
    font-size: 16px;
    height: 44px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0 4px;
}

.report-cell-callout.trend-up {
    background: #34c38f;
    color: #fff;
}

.report-cell-callout.trend-down {
    background: #f46a6a;
    color: #fff;
}

.report-cell-baseline {
    background: #f5f6f8;
    font-size: 16px;
    height: 44px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0 4px;
}

.report-trend-arrow {
    margin-left: 4px;
    font-size: 0.7rem;
}

/* --- ng-select-style entity multi-select (shared EntityMultiSelect component) --- */
.portfolio-popover {
    max-height: 320px;
    overflow-y: auto;
}

/* Transparent full-screen click-away layer for the dropdown. */
.pf-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1;
}

.portfolio-select {
    position: relative;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    min-height: 40px;
    padding: 6px 8px;
    border: 1px solid rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
}

.portfolio-select.pf-disabled {
    background: #f5f5f5;
    cursor: default;
    pointer-events: none;
    opacity: 0.75;
}

.portfolio-select-label {
    position: absolute;
    top: -9px;
    left: 9px;
    padding: 0 4px;
    font-size: 0.7rem;
    color: rgba(0, 0, 0, 0.6);
    background: #fff;
    line-height: 1.2;
}

.pf-chip {
    display: inline-flex;
    align-items: stretch;
    background: var(--mud-palette-primary, #5A9ED6);
    color: #fff;
    border-radius: 3px;
    font-size: 0.72rem;
    line-height: 1;
    overflow: hidden;
}

.pf-chip-x {
    display: flex;
    align-items: center;
    padding: 4px 6px;
    border-right: 1px solid rgba(255, 255, 255, 0.45);
    cursor: pointer;
    font-weight: 700;
}

.pf-chip-x:hover {
    background: rgba(0, 0, 0, 0.15);
}

.pf-chip-label {
    display: flex;
    align-items: center;
    padding: 4px 6px;
    white-space: nowrap;
}

.portfolio-input {
    flex: 1;
    min-width: 90px;
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.85rem;
}

.pf-arrow {
    margin-left: auto;
    color: rgba(0, 0, 0, 0.54);
}

/* Required-field asterisks in red (MudBlazor renders them via label::after). */
.mud-input-control.mud-input-required > .mud-input-control-input-container > .mud-input-label::after {
    color: var(--mud-palette-error, #f44336);
    font-size: 1.25em;
    font-weight: 700;
    margin-left: 4px;
}

/* Sortable column headers: stacked up/down arrows (ngx-datatable style). */
.report-table th.report-th-sortable {
    cursor: pointer;
    user-select: none;
}

.report-sort-arrows {
    display: inline-flex;
    flex-direction: column;
    vertical-align: middle;
    margin-left: 5px;
    line-height: 0.62;
    font-size: 0.55em;
    color: rgba(255, 255, 255, 0.55);
}

.report-sort-arrows .active {
    color: #fff;
}

/* Report run page: plain column-name headers — only the group band row keeps the blue fill. */
.report-run-output .report-table th {
    background: transparent;
    color: #333;
    border-bottom: 2px solid #d5dae0;
}

.report-run-output .report-table th.report-group-header-cell {
    background: var(--mud-palette-primary, #5A9ED6);
    color: #fff;
    border-bottom: none;
}

.report-run-output .report-table th.report-group-header-blank {
    background: transparent;
    border-bottom: none;
}

.report-run-output .report-sort-arrows {
    color: rgba(0, 0, 0, 0.35);
}

.report-run-output .report-sort-arrows .active {
    color: #333;
}

/* Zebra striping (Angular parity): first row shaded, then every other row. */
.report-run-output .report-table tbody tr:nth-child(odd) {
    background: #f2f4f6;
}

/* Footer band label rendered inline inside the main table (report page).
   Angular parity: a plain gray section row (e.g. "Avg Per Mid"), not a blue band. */
.report-table td.report-footer-band-cell {
    background: #e8ebef;
    color: #333;
    font-weight: 600;
    padding: 5px 8px;
    white-space: nowrap;
}

/* Band header cells match Angular: 36px tall, 12px text, no wrapping blowing up the row. */
.report-run-output .report-table th.report-group-header-cell {
    height: 36px;
    padding: 4px 8px;
    font-size: 12px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Item highlighted by dropdown type-to-jump. */
.mud-list-item.typeahead-hit {
    background: rgba(90, 158, 214, 0.15);
}

/* List tables (entity lists, scheduled reports): logo-blue header row with white text. */
.list-table thead th.mud-table-cell,
.list-table .mud-table-head .mud-table-cell {
    background: var(--mud-palette-primary, #5A9ED6) !important;
    color: #ffffff !important;
    font-weight: 600;
    border: 2px solid #ffffff !important;
}

.list-table thead .mud-table-cell *,
.list-table .mud-table-head .mud-table-cell .mud-table-sort-label,
.list-table .mud-table-head .mud-table-cell .mud-table-sort-label:hover,
.list-table .mud-table-head .mud-table-cell .mud-icon-root {
    color: #ffffff !important;
}

/* --- Mobile: wide report tables scroll horizontally instead of crushing --- */
@media (max-width: 960px) {
    .report-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .report-run-output .report-table td {
        white-space: nowrap; /* keep natural column widths; the container scrolls */
    }

    /* Fixed-layout (banded) tables on the full report pages are width:100% and
       would just crush their equal columns; give them a floor so the container
       scrolls instead. Dashboard widgets are excluded: they must shrink to fit. */
    .report-run-output .report-table.report-table-fixed {
        min-width: 640px;
    }
}

/* --- Mobile + tablet (2-per-row widgets): smaller widget fonts so values fit --- */
@media (max-width: 1280px) {
    .report-cell-callout,
    .report-cell-baseline {
        font-size: 10px;
        height: 30px;
        padding: 0 2px;
    }

    /* The long-number step-downs shrink proportionally too. */
    .report-cell-value.report-cell-value-sm,
    .report-currency-symbol.report-cell-value-sm {
        font-size: 10px;
    }

    .report-cell-value.report-cell-value-xs,
    .report-currency-symbol.report-cell-value-xs {
        font-size: 9px;
    }

    .report-cell-label {
        font-size: 10px;
        padding: 7px 3px;
    }
}

/* --- Mobile only: general table shrink --- */
@media (max-width: 960px) {
    .report-table {
        font-size: 0.66rem;
    }

    .report-table th {
        padding: 5px 5px;
    }

    .report-table td {
        padding: 3px 2px;
    }
}
