/* resp-accounts-a — responsive layout for its pages. Loaded after app.css.
   Pages: Accounts home, Transactions, Cash & bank, Categories, Budgets, Commission.
   Everything is scoped by the .aa-page wrapper or an aa- class. Phone styles first. */

.aa-page { min-width: 0; max-width: 100%; }
.aa-page .rz-form-field { min-width: 0; max-width: 100%; }
.aa-page .app-page__card { min-width: 0; }

/* ── Form cards ─────────────────────────────────────────────────── */
/* Expense | Income switch fills the width */
.aa-page .tx-type { display: flex; width: 100%; }
.aa-page .tx-type .rz-button {
    flex: 1 1 0;
    min-width: 0;
    min-height: 48px;
    padding: 0.4rem 0.5rem;
    white-space: normal;
    line-height: 1.2;
    letter-spacing: 0.02em;
    font-size: 0.8rem;
}

/* Transactions: amount, what for, note — rows fill themselves, no lopsided gaps */
.aa-tx-grid,
.aa-tx-details,
.aa-inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem 0.75rem;
}
.aa-tx-grid > .rz-form-field,
.aa-tx-details > .rz-form-field,
.aa-inline-form > .rz-form-field { flex: 1 1 100%; }
.aa-page .aa-form-card .rz-form-field .rz-numeric,
.aa-page .aa-form-card .rz-form-field .rz-dropdown,
.aa-page .aa-form-card .rz-form-field .rz-datepicker,
.aa-page .aa-filters .rz-form-field .rz-numeric,
.aa-page .aa-filters .rz-form-field .rz-datepicker { width: 100%; }

.aa-tx-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
}
.aa-tx-actions .tx-more { display: block; }
.aa-tx-actions .tx-more .rz-button {
    width: 100%;
    height: auto;
    min-height: 40px;
    padding: 0.4rem 0.25rem;
    white-space: normal;
    text-align: left;
    line-height: 1.25;
}
.aa-tx-actions .tx-more .rz-button-box { justify-content: flex-start; text-align: left; }
.aa-tx-actions .aa-tx-save { width: 100%; min-height: 48px; font-size: 0.95rem; }

/* Date / account / branch / category inline forms */
.aa-inline-form { align-items: center; }
.aa-inline-form > .rz-button { flex: 1 1 100%; min-height: 44px; }

/* Cash & bank add / edit row */
.aa-ca-form { display: flex; flex-wrap: wrap; gap: 0.85rem 0.75rem; align-items: center; }
.aa-ca-form > .rz-form-field { flex: 1 1 100%; }
.aa-form-title { flex: 1 1 100%; display: flex; align-items: center; gap: 0.5rem; font-weight: 700; font-size: 0.95rem; color: var(--text-primary); }
.aa-form-actions { flex: 1 1 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
.aa-form-actions .rz-button { flex: 1 1 8rem; min-height: 44px; }
.aa-form-actions .rz-chkbox-label,
.aa-form-actions label { white-space: nowrap; }

/* Account cards: auto-fit grid, capped so one or two accounts do not stretch across the page */
.aa-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 420px));
    gap: 1rem;
    align-items: stretch;
}
.aa-card-grid > .app-page__card { margin-bottom: 0; height: 100%; }

/* ── Filter rows (From / To / Refresh / Export, Year / Month / Refresh) ───── */
.aa-filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 1rem;
}
.aa-filters > .rz-button { width: 100%; min-height: 44px; padding-left: 0.5rem; padding-right: 0.5rem; letter-spacing: 0.02em; font-size: 0.82rem; white-space: nowrap; }
.aa-filters .rz-datepicker .rz-inputtext { font-size: 0.92rem; padding-right: 2.25rem; }
.aa-filters > :last-child:nth-child(odd) { grid-column: 1 / -1; }

/* ── Categories: expense and income panels ──────────────────────── */
.aa-cat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
    gap: 1rem;
    align-items: stretch;
}
.aa-cat-col { min-width: 0; }
.aa-cat-col > .app-page__card { height: 100%; margin-bottom: 0; }
.aa-cat-col .rz-stack > .rz-textbox { min-width: 0; }
.aa-cat-col .rz-stack > .rz-button { flex: 0 0 auto; }
.aa-cat-col .finance-subnav__item { min-height: 44px; }
.aa-cat-col .finance-subnav__item span { min-width: 0; overflow-wrap: anywhere; }

/* ── Grids: scroll inside the card, hide low-value columns ─────── */
.aa-page .app-datagrid { max-width: 100%; }
.aa-page .app-datagrid .rz-data-grid-data { overflow-x: auto; }
/* Radzen's fixed layout collapses unsized columns to 0 once the sized ones fill the card */
.aa-page .app-datagrid .rz-grid-table { table-layout: auto; width: 100%; }
.aa-page .app-datagrid .rz-grid-table td,
.aa-page .app-datagrid .rz-grid-table th { white-space: nowrap; }
.aa-page .app-datagrid .rz-grid-table td .finance-status-pill { white-space: nowrap; }

@media (max-width: 900px) {
    .aa-page th.aa-hide-md,
    .aa-page td.aa-hide-md { display: none; }
}

/* ── Phones only ─────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .aa-page .rz-button { min-height: 40px; }
    .aa-page .rz-button.rz-button-xs,
    .aa-page .rz-button.rz-button-sm { min-width: 40px; }
    .aa-page .app-datagrid .rz-grid-table td,
    .aa-page .app-datagrid .rz-grid-table th { padding: 0.55rem 0.5rem; }
    .aa-page .app-datagrid .rz-column-resizer { display: none; }
    .aa-page th.aa-hide-sm,
    .aa-page td.aa-hide-sm { display: none; }
}

/* ── Tablet and up ───────────────────────────────────────────────── */
@media (min-width: 641px) {
    .aa-tx-grid > .rz-form-field:nth-child(1) { flex: 1 1 9rem; }
    .aa-tx-grid > .rz-form-field:nth-child(2) { flex: 1.6 1 13rem; }
    .aa-tx-grid > .rz-form-field:nth-child(3) { flex: 2 1 15rem; }
    .aa-tx-details > .rz-form-field { flex: 1 1 11rem; }
    .aa-tx-details > .rz-form-field:nth-child(2) { flex: 1.4 1 13rem; }

    .aa-tx-actions { flex-direction: row; justify-content: space-between; align-items: center; }
    .aa-tx-actions .tx-more { flex: 1 1 auto; min-width: 0; }
    .aa-tx-actions .tx-more .rz-button { width: auto; max-width: 100%; }
    .aa-tx-actions .aa-tx-save { width: auto; min-width: 10rem; min-height: 44px; flex: 0 0 auto; }

    .aa-inline-form > .rz-form-field { flex: 1 1 12rem; }
    .aa-budget-form > .rz-form-field:first-child { flex: 0 1 9rem; }
    .aa-inline-form > .rz-button { flex: 0 0 auto; min-width: 9rem; margin-left: auto; }

    .aa-ca-form > .rz-form-field { flex: 1 1 11rem; }
    .aa-form-title + .rz-form-field { flex: 1.5 1 13rem; }
    .aa-form-actions { justify-content: flex-end; }
    .aa-form-actions .rz-button { flex: 0 0 auto; min-width: 8rem; }

    .aa-filters { display: flex; flex-wrap: wrap; }
    .aa-filters > .rz-form-field { flex: 0 1 11rem; }
    .aa-filters > .rz-button { width: auto; min-width: 7.5rem; }

}
