/* Page UX – layout, toolbar, compact tables, detail modals */

/* Page toolbar: primary action (Add X) + secondary (Manage types, Export, etc.) */
.page-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.page-toolbar .toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

/* Card header with toolbar */
.card-header-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

/* Compact data table: essential columns only; extra data in detail modal */
.table-compact thead th {
    white-space: nowrap;
}

.table-compact .col-amount {
    text-align: right;
    white-space: nowrap;
}

.table-compact .col-actions {
    white-space: nowrap;
    width: 1%;
}

/* Table total row: make footer/totals clearly distinct from data rows */
.table tr.table-total-row,
.table tfoot tr {
    border-top: 2px solid var(--bs-gray-500, #adb5bd) !important;
    background-color: var(--bs-gray-200, #e9ecef) !important;
    font-weight: 700;
}
.table tfoot td {
    padding: 0.5rem 0.75rem;
    vertical-align: middle;
}

/* Detail modal: key-value pairs, readable */
.detail-modal .detail-grid {
    display: grid;
    gap: 0.75rem 1.5rem;
    grid-template-columns: minmax(140px, auto) 1fr;
    align-items: start;
}

.detail-modal .detail-label {
    font-weight: 600;
    color: var(--gray, #6c757d);
    font-size: 0.875rem;
}

.detail-modal .detail-value {
    word-break: break-word;
}

.detail-modal .detail-section {
    margin-bottom: 1.25rem;
}

.detail-modal .detail-section-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--light-gray, #e9ecef);
}

/* Action buttons in tables */
.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

/* Filters: collapsible when used */
.filters-collapse .collapse-toggle {
    cursor: pointer;
    user-select: none;
}

/* Low-level “add” sections: in modals, not always on screen */
.add-form-modal .modal-body .form-floating,
.add-form-modal .modal-body .form-check {
    margin-bottom: 0.75rem;
}

/* --------------------------------------------------------------------
   Reports: P&L and multi-currency standards
   - KPI cards with currency breakdown pills
   - Original amount vs Base (base currency) columns
   - Section cards, filter bar, distinct totals
--------------------------------------------------------------------*/
.report-container { max-width: 1600px; margin: 0 auto; }

/* Filter bar above report content */
.report-filter-bar {
    background-color: hsl(var(--muted) / 0.5);
    border-radius: var(--radius);
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid hsl(var(--border));
}

/* KPI cards: left border indicates in/out/neutral */
.kpi-card {
    background-color: hsl(var(--card));
    border-radius: var(--radius);
    border: 1px solid hsl(var(--border));
    padding: 1.25rem;
    height: 100%;
    border-left: 4px solid transparent;
}
.kpi-card.positive { border-left-color: hsl(var(--success)); }
.kpi-card.negative { border-left-color: hsl(var(--destructive)); }
.kpi-card.neutral { border-left-color: hsl(var(--primary)); }
.kpi-card .kpi-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: hsl(var(--muted-foreground));
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.kpi-card .kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
    color: hsl(var(--card-foreground));
}
.kpi-currency-breakdown {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
    font-size: 0.75rem;
}
.currency-pill {
    background-color: hsl(var(--muted) / 0.6);
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    border: 1px solid hsl(var(--border));
    color: hsl(var(--foreground));
    white-space: nowrap;
}
.currency-pill strong { font-weight: 600; margin-right: 0.2rem; }

/* Section card: collapsible block with header badges */
.section-card {
    background-color: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
}
.section-header {
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    border-bottom: 1px solid transparent;
}
.section-header[aria-expanded="true"] {
    border-bottom-color: hsl(var(--border));
    background-color: hsl(var(--muted) / 0.2);
}
.section-header:hover { background-color: hsl(var(--muted) / 0.3); }
.section-header h6 { margin: 0; font-weight: 600; display: flex; align-items: center; gap: 0.75rem; }
.section-collapse { padding: 1.5rem; }

/* Report tables: original + base columns, badge for currency */
.report-table thead th {
    padding: 0.75rem 1rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    background-color: hsl(var(--muted) / 0.3);
    border-bottom: 1px solid hsl(var(--border));
}
.report-table tbody td { padding: 0.75rem 1rem; vertical-align: middle; }
.report-table tbody tr { border-bottom: 1px solid hsl(var(--border)); }
.report-table tbody tr:hover { background-color: hsl(var(--muted) / 0.3); }
.report-table .btn-expand {
    width: 28px; height: 28px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid hsl(var(--border));
    background-color: hsl(var(--card));
    border-radius: var(--radius-sm);
}
.report-table .btn-expand:hover { background-color: hsl(var(--accent)); }

/* Amount in original currency: badge + value */
.amount-original { white-space: nowrap; }
.amount-original .badge { font-weight: 400; }

/* Responsive */
@media (max-width: 768px) {
    .page-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .detail-modal .detail-grid {
        grid-template-columns: 1fr;
    }

    .kpi-card .kpi-value { font-size: 1.4rem; }
    .section-header { flex-wrap: wrap; gap: 0.5rem; }
}
