/* Financial Report Builder — Tabulator theme overrides matching Corvenia styles */

.tabulator {
    font-family: 'Lato', sans-serif;
    font-size: 13px;
    border: 1px solid #dee2e6;
}

.tabulator .tabulator-header .tabulator-col {
    background: #e5e5e5;
    color: #495057;
    border-right: 1px solid #dee2e6;
    font-weight: 600;
    font-size: 12px;
    text-transform: none;
}

/*
 * Month column headers: Tabulator 6 simple theme does not use flex on .tabulator-col-content
 * (justify-content there had no effect). Alignment is done via headerHozAlign in TabulatorInterop.js.
 * Fallback: right-align the title element Tabulator puts header text in (.tabulator-col-title).
 */
.tabulator .tabulator-header .tabulator-col.frb-tabulator-month-col .tabulator-col-title,
.tabulator .tabulator-header .tabulator-col[tabulator-field^="values.month_"] .tabulator-col-title {
    text-align: right;
}

.tabulator-row {
    border-bottom: 1px solid #dee2e6;
}

.tabulator-row:hover {
    background: #f8f9fa !important;
}

.tabulator-row.tabulator-section-row {
    background: #F3F6F6 !important;
}
.tabulator-row.tabulator-section-row .tabulator-cell {
    font-weight: 700;
    color: #495057;
}

.tabulator-row.tabulator-subtotal-row {
    background: #eaefef !important;
    border-top: 2px solid #c9c9c9;
}
.tabulator-row.tabulator-subtotal-row .tabulator-cell {
    font-weight: 700;
    color: #495057;
}

.tabulator-row.tabulator-total-row {
    background: #DDE6E6 !important;
    border-top: 2px solid #aaa;
}
.tabulator-row.tabulator-total-row .tabulator-cell:first-child {
    border-left: 3px solid #009688;
}
.tabulator-row.tabulator-total-row .tabulator-cell {
    font-weight: 700;
    color: #495057;
}

/*
 * Formula rows with presentation = Standard: render like a body detail row (no fill, no bold).
 * No background/font-weight rules needed — the absence of subtotal/total classes already does that.
 * Declared as an empty rule for discoverability + forward-compat.
 */
.tabulator-row.tabulator-formula-plain-row {
    /* intentionally empty — styling is "plain" body row */
}

/*
 * Italic formula rows (FormulaItalic = true). Orthogonal to the presentation class so it
 * composes cleanly with Subtotal / GrandTotal / FormulaPlain rows.
 * Intentionally only sets font-style so it does not override fills or font-weight.
 */
.tabulator-row.tabulator-formula-italic .tabulator-cell {
    font-style: italic;
}

/* Spacer rows: visible vertical gap (layout-only; not a thin glitch line). */
.tabulator-row.tabulator-spacer-row {
    height: auto !important;
    min-height: 28px !important;
}
.tabulator-row.tabulator-spacer-row .tabulator-cell {
    padding: 10px 4px;
    border: none;
    vertical-align: middle;
}

/* Frozen bottom row (grand total via bottomCalc) */
.tabulator .tabulator-calcs-bottom {
    background: #DDE6E6 !important;
    border-top: 2px solid #aaa;
}
.tabulator .tabulator-calcs-bottom .tabulator-row .tabulator-cell {
    font-weight: 700;
    color: #495057;
}
.tabulator .tabulator-calcs-bottom .tabulator-row .tabulator-cell:first-child {
    border-left: 3px solid #c62828;
}
.tabulator .tabulator-calcs-bottom .tabulator-row {
    background: #DDE6E6 !important;
    border-top: 2px solid #c62828;
}

/* Ensure Tabulator fills its wrapper */
.tabulator-container {
    flex: 1 1 0;
    min-height: 0;
}

/* Number cells right-aligned */
.tabulator .tabulator-cell.tabulator-number-cell {
    text-align: right;
}

/* Frozen label column */
.tabulator .tabulator-frozen.tabulator-frozen-left {
    border-right: 2px solid #dee2e6;
}

/* Report Builder hub page header (parity with ExchangeRates.razor / Corvenia tools) */
.report-builder-page .report-builder-page-header {
    padding-bottom: 7px;
    margin-bottom: 0.75rem;
    position: relative;
}

.report-builder-page .report-builder-page-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    right: 0;
    height: 1px;
    background-color: #E4E4E7;
    width: 100vw;
    margin-left: -50vw;
}

.report-builder-page .report-builder-page-header h5 {
    margin: 0;
    color: #1f2937;
    font-weight: 600;
    font-size: 1.5rem;
    letter-spacing: -0.01em;
}

.report-builder-page .report-builder-page-header .text-muted {
    color: var(--mud-palette-text-secondary);
    font-size: 0.875rem;
}

/* Keep notification + AI chat (HeaderActions) visible next to page controls */
.report-builder-page .report-builder-header-toolbar {
    flex-shrink: 0;
}

.report-builder-page .report-builder-header-actions {
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.report-builder-page .report-builder-header-actions .header-actions {
    margin-left: 0;
}

/* Report builder page layout */
.report-builder-page .report-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 0;
}

.report-builder-page .report-card-grid-fixed {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-top: 0;
}

@media (max-width: 900px) {
    .report-builder-page .report-card-grid-fixed {
        grid-template-columns: 1fr;
    }
}

.report-builder-page .report-card {
    border-radius: 8px;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.report-builder-page .report-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.report-builder-page .report-card .mud-card-header {
    padding: 12px 16px 4px;
}

.report-builder-page .report-card .mud-card-content {
    padding: 10px;
}

.report-builder-page .report-card .mud-card-actions {
    padding: 0px 4px 8px 8px;
    justify-content: end;
}

.report-viewer-container {
    height: 100%;
    max-height: calc(100vh - 2rem);
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.report-viewer-container .tabulator-wrapper {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    /* padding: 0 16px 16px 16px; */
}

/* Adjusted column highlight */
.tabulator .tabulator-cell.adjusted-col {
    background: #fefce8;
}

.report-viewer-footer {
    padding: 12px 24px;
    font-size: 11px;
    color: #9e9e9e;
    border-top: 1px solid #e0e0e0;
    background: #fff;
}

/* AccountPalette (row editor): don’t stretch MudTabs — avoids empty gap above tab bar */
.account-palette-root .mud-tabs {
    flex: 0 1 auto;
    min-height: 0;
}

.account-palette-root .mud-tabs-panels {
    flex: 0 1 auto !important;
    min-height: 0 !important;
}

.account-palette-tab-panel {
    overflow-y: visible;
}

/*
 * Report Builder viewers: relax outer flex/vh clipping for print only.
 * Do NOT override .tabulator internals with !important — that breaks Tabulator's printAsHtml swap (blank pages).
 */
@media print {
    .report-viewer-container {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
        height: auto !important;
        max-height: none !important;
        min-height: 0 !important;
        overflow: visible !important;
        display: block !important;
    }

    .report-viewer-container .tabulator-wrapper {
        flex: none !important;
        min-height: 0 !important;
        overflow: visible !important;
        height: auto !important;
        max-height: none !important;
        display: block !important;
    }

    .report-viewer-container .tabulator-container {
        flex: none !important;
        min-height: 0 !important;
        overflow: visible !important;
        height: auto !important;
    }

    /* Toolbar: Expand / Export / Print (class already on markup; was only wired in reports-print.css for Mud report pages). */
    .report-viewer-container .report-print-hide {
        display: none !important;
    }

    /* ReportsFilter title row: Generate / Clear (when shown). */
    .report-viewer-container .action-buttons-wrapper {
        display: none !important;
    }

    /* Plain HTML table Tabulator injects when printAsHtml runs (do not fight Tabulator’s own print CSS). */
    .report-viewer-container table.tabulator-print-table {
        width: 100% !important;
        border-collapse: collapse;
    }
}

/* --- Template Editor: 3-column resizable layout (splitters: MasterCoAEditorLayout.js) --- */

.template-editor-root {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 64px);
    overflow: hidden;
}

.template-editor-root .coa-body {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.template-editor-root .coa-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.template-editor-root .coa-panel-left {
    flex-shrink: 0;
    min-width: 200px;
    border-right: none;
    background: #fafafa;
}

.template-editor-root .coa-panel-center {
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background: #fff;
}

.template-editor-root .coa-panel-right {
    flex-shrink: 0;
    min-width: 200px;
    min-height: 0;
    border-left: none;
    background: #fafafa;
    overflow: hidden;
}

.template-editor-root .coa-resizer {
    flex-shrink: 0;
    width: 6px;
    cursor: col-resize;
    touch-action: none;
    user-select: none;
    background: #e2e8f0;
    align-self: stretch;
}

.template-editor-root .coa-resizer:hover {
    background: #cbd5e1;
}

.template-editor-root .coa-body-dragging {
    cursor: col-resize;
    user-select: none;
}

.template-editor-root .coa-body-dragging .coa-resizer {
    background: #94a3b8;
}

.template-editor-root .coa-panel-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px;
}

@media (max-width: 960px) {
    .template-editor-root .coa-body {
        flex-direction: column;
    }

    .template-editor-root .coa-resizer {
        display: none;
    }

    .template-editor-root .coa-panel-left,
    .template-editor-root .coa-panel-center,
    .template-editor-root .coa-panel-right {
        width: 100% !important;
        min-width: 0 !important;
        border-right: none;
        border-left: none;
    }

    .template-editor-root .coa-panel-left {
        max-height: 40vh;
        border-bottom: 1px solid #e2e8f0;
    }

    .template-editor-root .coa-panel-right {
        max-height: 35vh;
        border-top: 1px solid #e2e8f0;
    }

    .template-editor-root {
        height: auto;
        min-height: calc(100vh - 64px);
    }
}

/* My Templates DataGrid - Match UserAdmin table header styling */
.report-builder-page .mud-table-head {
    background-color: #f8f9fa;
}

.report-builder-page .mud-table-head .mud-table-cell {
    font-weight: 600;
    font-size: 0.875rem;
    color: #495057;
    padding: 12px 16px;
    border-bottom: 2px solid #dee2e6;
}

.report-builder-page .mud-table-row {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.report-builder-page .mud-table-row:hover {
    background-color: #f8f9fa;
}

/*
 * Editor-only hint that an AccountRange row is nested under another range. The left border provides a subtle
 * tree-branch cue alongside the left-margin indent set inline by the canvas. Applied only in the editor's
 * row canvas, never in the rendered report grid.
 */
.row-canvas-row-wrap.row-canvas-nested-range .row-canvas-item {
    border-left: 3px solid #bbdefb;
}

.row-canvas-row-wrap.row-canvas-nested-range .row-canvas-item.expanded {
    border-left-color: #64b5f6;
}
