/* resp-salary-people — responsive layout for its pages. Loaded after app.css.
   Pages: salary home, Employees, Employee details, Advances, Bonus & fines, Leave, My payslip,
   and their dialogs. Radzen's own stylesheet loads after this file, so selectors that fight a
   Radzen rule carry an extra class to win on specificity; !important is used only where Radzen
   itself writes the value inline or marks its utility class !important (each one is commented). */

/* ───────────── header action buttons (Employees) ───────────── */
.sp-actions { max-width: 100%; }

@media (max-width: 640px) {
    .sp-actions { width: 100%; }
    .sp-actions > .rz-button { flex: 1 1 auto; justify-content: center; }
}

/* ───────────── form cards: one full-width card, tidy field grids ───────────── */
.sp-form-card.app-page__card--medium { max-width: none; }

/* Fields in a Radzen row/column pair: wrap and share the row, no empty cells and no fixed thirds */
.sp-fields.rz-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.9rem 1rem;
}
.sp-fields.rz-row > [class*="rz-col"] {
    flex: 1 1 12rem;
    width: auto;
    max-width: none;
    min-width: 0;
    padding: 0;
}

/* A horizontal "stack" of fields turned into a grid: 1 column on phones, as many as fit above that */
/* (Radzen's .rz-display-flex utility is !important, so display needs it as well) */
.sp-form-row.rz-stack {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
    gap: 0.9rem 1rem;
    align-items: end;
}
.sp-form-row > .rz-form-field,
.sp-fields .rz-form-field { width: 100%; }
.sp-form-row .rz-form-field :is(.rz-dropdown, .rz-numeric, .rz-datepicker, .rz-textbox, .rz-textarea) { width: 100%; }
.sp-form-row > :not(.rz-form-field) { align-self: center; }
.sp-form-row > .rz-button { justify-self: start; min-width: 7rem; }

/* Two small cards next to each other on wide screens, stacked otherwise */
.sp-pair {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    column-gap: 1rem;
    align-items: stretch;
}
.sp-pair > .app-page__card { max-width: none; min-width: 0; }
.sp-pair > .rz-alert { grid-column: 1 / -1; }

/* Form + side summary (Employee details, Advances) */
.sp-split.rz-row {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr);
    column-gap: 1rem;
    row-gap: 0;
    align-items: start;
}
.sp-split.rz-row > [class*="rz-col"] {
    flex: none;
    width: auto;
    max-width: none;
    min-width: 0;
    padding: 0;
}

@media (min-width: 1100px) {
    .sp-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .sp-split.rz-row { grid-template-columns: minmax(0, 1fr) 20rem; }
}

/* Employees: branch filter is a single dropdown, keep the card compact */
.sp-filter-card { max-width: 26rem; }
.sp-filter-card .rz-form-field { width: 100%; }

/* ───────────── data grids stay inside their card ───────────── */
.sp-grid-card { min-width: 0; max-width: 100%; }

/* Employees grid: below ~1400px the page has no room for Branch (col 3) and Status (col 6), so they go,
   and inactive people get a small tag next to their name instead. The <col> goes too, or the table
   keeps the width of the hidden column. Below ~1200px the row buttons turn icon-only. */
.sp-inactive-tag { display: none; margin-left: 0.25rem; }

@media (max-width: 1400px) {
    .sp-staff-card .sp-hide-lg { display: none; }
    .sp-staff-card colgroup col:nth-child(3),
    .sp-staff-card colgroup col:nth-child(6) { display: none; }
    .sp-inactive-tag { display: inline-flex; }
}

@media (max-width: 1200px) {
    .sp-act.rz-button { min-width: 2.5rem; padding-inline: 0.55rem; }
    .sp-act .rz-button-text { display: none; }
    .sp-act .rz-button-icon-left { margin: 0; }
    .sp-staff-card colgroup col:last-child,
    .sp-staff-card th:last-child,
    .sp-staff-card td:last-child { width: 8.5rem !important; }   /* Radzen writes this width inline */
}

/* ───────────── Employee details ───────────── */
@media (max-width: 480px) {
    .staff-doc-row { flex-wrap: wrap; }
    .staff-doc-row__body { flex-basis: calc(100% - 3.5rem); }
    .staff-doc-row__actions { width: 100%; justify-content: flex-end; }
}

/* ───────────── My payslip ───────────── */
@media (max-width: 640px) {
    .sp-punch-row > .rz-button { flex: 1 1 40%; }
}

/* ───────────── comfortable touch targets on phones ───────────── */
@media (max-width: 640px) {
    :is(.sp-grid-card, .sp-form-card, .sp-filter-card, .sp-actions, .sp-split, .sp-pair, .staff-attention,
        .payroll-empty-hero, .payroll-edit-dialog, .payroll-import-dialog) .rz-button:is(.rz-button-xs, .rz-button-sm, .rz-button-md) {
        min-height: 2.5rem;
    }
    .sp-form-row > .rz-button { justify-self: stretch; }
    .staff-attention { align-items: flex-start; }
    .staff-attention .rz-button { margin-left: 0; width: 100%; }
}

/* ───────────── dialogs ───────────── */
.payroll-edit-dialog,
.payroll-import-dialog { min-width: 0; max-width: 100%; }

@media (max-width: 640px) {
    .payroll-edit-dialog .rz-stack:last-child > .rz-button { flex: 1 1 0; }
    .acbulk-row { gap: 0.5rem; }
    .acbulk-row .rz-textbox { width: min(9rem, 45vw) !important; }   /* Radzen writes this width inline */
}

/* Checkbox + label inside a field grid: no stray margins, tap target is the whole line */
.sp-check { margin: 0; min-height: 2.5rem; }
.sp-form-row > .sp-check { align-self: center; }

/* Grid pager buttons: finger-sized on phones */
@media (max-width: 640px) {
    .sp-grid-card .rz-paginator .rz-paginator-element,
    .sp-grid-card .rz-paginator .rz-paginator-page { min-width: 2.5rem; min-height: 2.5rem; }
}
