/* ===== List pages (invoice: /hoa-don/…, vnv: /vnv/…) =====
   Shared look of every list page; reference page: Lịch sử thanh toán (/hoa-don/lich-su-thanh-toan/).
   JS: static/js/list/*.js · markup: templates/includes/list/*.html · guide: documents/guides/development/list-pages.md
   Load after static/css/components/house-card.css and before the app's own CSS. */

/* ===== Page shell of the list pages (root: .house-mng.list-page) =====
   Full page width (no 720px / 1200px cap of .house-mng), only the page padding at the sides */
.house-mng.list-page {
    max-width: none;
}

/* Card view: as many cards per row as fit instead of two */
@media (min-width: 992px) {
    .list-page .house-mng__list {
        grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
    }
}

/* Filter chip on the left, Bảng / Thẻ toggle on the right */
.list-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.list-toolbar__views {
    margin-left: auto;
}

.list-toolbar__views .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

/* Right end holding more than the switch (e.g. "Cột" + Bảng / Thẻ): the group takes the auto margin */
.list-toolbar__end {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.list-toolbar__end .list-toolbar__views {
    margin-left: 0;
}

/* ===== "Cột" picker of a Bảng table (static/js/list/list-columns.js) ===== */
.list-columns__toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.list-columns__menu {
    min-width: 13rem;
    max-height: min(70vh, 26rem);
    overflow-y: auto;
    padding: 0.375rem 0;
}

.list-columns__item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    padding: 0.375rem 0.875rem;
    font-size: 0.875rem;
    cursor: pointer;
}

.list-columns__item:hover {
    background: #f3f4f6;
}

.list-columns__item .form-check-input {
    margin: 0;
}

.list-columns__reset {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    padding: 0.5rem 0.875rem;
    border: 0;
    border-top: 1px solid #e5e7eb;
    background: none;
    color: var(--primary, #1877f2);
    font-size: 0.875rem;
    text-align: left;
}

.list-columns__reset:hover,
.list-columns__reset:focus-visible {
    text-decoration: underline;
}

/* ===== Bảng / Thẻ rule (static/js/list/list-view.js) ===== */
/* STT: first column of every Bảng table, numbered across the loaded pages */
.list-view__index {
    width: 3rem;
    color: #6b7280;
    font-variant-numeric: tabular-nums;
    text-align: center;
    white-space: nowrap;
}

/* ===== Filter row, totals line (Thẻ), Bảng pager ===== */
/* Filter row (.list-filter, list-filter.js), same look as "Khách xem phòng" (templates/properties/
   guest_visit_room_dashboard.html): the label sits on the input's top border, every filter one compact 40px row.
   Phones: search on its own line, the other filters two by two; from 992px: one line (wraps when there are many),
   the search twice as wide. Works for any number of filters. */
.list-filter {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 8px;
    margin: 6px 0 14px;
}

.list-filter__item {
    position: relative;
    min-width: 0;
}

/* Search, and wide pickers (e.g. Nhà of Chi phí đầu tư): a line of their own on phones, twice as wide from 992px */
.list-filter__item--search,
.list-filter__item--wide {
    grid-column: 1 / -1;
}

.list-filter__label {
    position: absolute;
    top: -8px;
    left: 10px;
    z-index: 1;
    max-width: calc(100% - 16px);
    margin: 0;
    padding: 0 6px;
    overflow: hidden;
    border-radius: 999px;
    background: #eaf3ff;
    color: var(--primary, #1877f2);
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 15px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.list-filter__input {
    width: 100%;
    height: 40px;
    padding: 9px 12px;
    border: 1.5px solid #dee2e6;
    border-radius: 10px;
    background-color: #fff;
    color: #111;
    font-size: 0.88rem;
}

.list-filter__input:focus {
    border-color: var(--primary, #1877f2);
    outline: none;
}

.list-filter__input--search { padding-left: 34px; }
.list-filter__input--date { padding-right: 34px; cursor: pointer; }
.list-filter__input--money { padding-right: 28px; }
.list-filter__input--select { padding-right: 8px; cursor: pointer; }

.list-filter__icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: #868e96;
    font-size: 0.85rem;
    pointer-events: none;
}

.list-filter__icon--left { left: 12px; color: #adb5bd; }
.list-filter__icon--right { right: 12px; }

/* A yes / no filter ("Chỉ nhà của tôi"): a box of the same height as the inputs */
.list-filter__check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    height: 40px;
    margin: 0;
    padding: 0 12px;
    border: 1.5px solid #dee2e6;
    border-radius: 10px;
    background-color: #fff;
    color: #111;
    font-size: 0.88rem;
    white-space: nowrap;
    cursor: pointer;
}

.list-filter__check .form-check-input {
    margin: 0;
}

.list-filter__error {
    grid-column: 1 / -1;
    margin: -6px 0 0;
    color: #dc3545;
    font-size: 0.85rem;
}

/* "×" of a date: replaces the calendar icon once a date is set */
.list-filter__clear {
    position: absolute;
    top: 50%;
    right: 6px;
    display: none;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #868e96;
    transform: translateY(-50%);
    cursor: pointer;
}

.list-filter__clear:hover {
    background: #f1f3f5;
    color: #111;
}

.list-filter__item.has-value .list-filter__clear {
    display: inline-flex;
}

.list-filter__item.has-value .list-filter__icon--right {
    display: none;
}

@media (max-width: 767.98px) {
    .list-filter__check {
        height: 34px;
        padding: 0 8px;
        font-size: 0.76rem;
    }

    .list-filter__input {
        height: 34px;
        padding: 6px 8px;
        font-size: 0.76rem;
    }

    .list-filter__input--search { padding-left: 26px; }
    .list-filter__input--date { padding-right: 26px; }
    .list-filter__input--money { padding-right: 22px; }
    .list-filter__icon { font-size: 0.75rem; }
    .list-filter__icon--left { left: 8px; }
    .list-filter__icon--right { right: 8px; }
}

@media (min-width: 992px) {
    .list-filter {
        display: flex;
        flex-wrap: wrap;
        gap: 14px 10px;
    }

    .list-filter__item {
        flex: 1 1 140px;
    }

    .list-filter__item--search,
    .list-filter__item--wide {
        flex: 2 1 260px;
    }

    .list-filter__error {
        flex-basis: 100%;
    }
}

/* Multi-select filter (list-filter.js multiSelect, list-filter-multi.html): a dropdown of tick boxes drawn as an input */
.list-multi__toggle {
    overflow: hidden;
    padding-right: 2rem;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.list-multi__menu {
    width: 100%;
    max-height: 320px;
    overflow-y: auto;
}

.list-multi__option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    white-space: normal;
}

.list-multi__option .form-check-input {
    flex-shrink: 0;
    margin: 0;
}

.list-multi__clear {
    font-size: 0.85rem;
    color: var(--primary);
}

/* Thẻ: count + totals in the toolbar above the cards (where Bảng shows its row count + page size) */
.list-summary {
    margin: 0;
    color: #374151;
    font-size: 0.9rem;
    font-weight: 600;
}

/* Bảng: totals of the whole filtered result in the table footer */
.list-table__total th,
.list-table__total td {
    background: #f9fafb;
    font-weight: 700;
    color: #111827;
}

.list-pager {
    display: flex;
    justify-content: center;
    margin-top: 0.75rem;
}

/* Row count + page size, in the toolbar above the table; one line even on phones */
.list-pager-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.list-pager__info {
    color: #374151;
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
}

/* Phones: count + page size still on one line */
@media (max-width: 575.98px) {
    .list-pager-meta {
        gap: 0.5rem;
    }

    .list-pager__info,
    .list-pager__size {
        font-size: 0.8rem;
    }
}

.list-pager__size {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    margin: 0;
    color: #6b7280;
    font-size: 0.85rem;
}

.list-pager__size {
    white-space: nowrap;
}

/* Compact select: the site-wide form styles (core/main.css, components/forms.css) make it as tall as a field */
.list-pager__size .form-select {
    width: auto;
    height: 30px;
    min-height: 0;
    padding: 0 1.75rem 0 0.5rem;
    background-position: right 0.5rem center;
    font-size: 0.85rem;
    line-height: 28px;
}

/* House filter chip (opened from a house card), "×" clears it */
.list-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 100%;
    padding: 0.25rem 0.25rem 0.25rem 0.75rem;
    border-radius: 999px;
    background: #f3f4f6;
    font-size: 0.875rem;
    font-weight: 600;
    color: #111827;
}

.list-chip.d-none {
    display: none;
}

.list-chip i {
    color: var(--primary);
}

.list-chip__clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #4b5563;
    cursor: pointer;
}

.list-chip__clear:hover {
    background: #e5e7eb;
}

.list-card__image {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0 0.75rem;
    padding: 0.75rem 0.25rem;
    border-top: 1px solid var(--border, #e5e7eb);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
}

.list-card__image img {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    object-fit: cover;
    background: #f3f4f6;
}

/* Table view (default): scrolls sideways inside its box on narrow screens */
.list-table-wrap {
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 12px;
    background: #fff;
}

.list-table {
    font-size: 0.875rem;
}

.list-table th {
    background: #f9fafb;
    font-weight: 600;
    color: #4b5563;
    white-space: nowrap;
}

.list-table__main {
    font-weight: 600;
    color: #111827;
}

.list-table__sub {
    display: block;
    font-size: 0.8rem;
    color: #6b7280;
}

.list-table__phone {
    text-decoration: none;
}

.list-table__phone:hover {
    text-decoration: underline;
}

.list-table__house {
    min-width: 200px;
}

.list-table__amount .list-table__main {
    color: var(--primary);
}

.list-table__content {
    min-width: 160px;
    max-width: 260px;
}

.list-table__content .list-table__main {
    font-weight: 400;
}

/* PDF attachment (imageLink): an icon the size of the thumbnail */
.list-file-thumb {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 6px;
    background: #fef2f2;
    color: #dc2626;
    font-size: 1.25rem;
}

.list-card__image .list-file-thumb {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    font-size: 1.5rem;
}

.list-table__thumb img {
    display: block;
    width: 40px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
    background: #f3f4f6;
}

.list-table__action {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

/* ===== Thao tác column (td.list-table__actions-cell, every list table) =====
   Plain icon / text buttons: no border, background or padding, in the colour of their kind (Bootstrap outline
   buttons keep their --bs-btn-color; the card-style buttons of /hoa-don/ turn primary). Beats the page rules
   (.vnv-table__actions …, .invoice-house-table__actions …) by specificity, no !important. */
.list-table td.list-table__actions-cell > div {
    gap: 0.75rem;
}

.list-table td.list-table__actions-cell .btn,
.list-table td.list-table__actions-cell .list-card__action {
    width: auto;
    height: auto;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
    line-height: 1.25;
}

.list-table td.list-table__actions-cell .btn,
.list-table td.list-table__actions-cell .btn:hover,
.list-table td.list-table__actions-cell .btn:active {
    color: var(--bs-btn-color);
    background: none;
}

.list-table td.list-table__actions-cell .list-card__action--primary,
.list-table td.list-table__actions-cell .list-card__action--outline {
    color: var(--primary);
}

.list-table td.list-table__actions-cell .btn:hover,
.list-table td.list-table__actions-cell .list-card__action:hover {
    filter: none;
    opacity: 0.7;
}

.list-table td.list-table__actions-cell .btn:focus-visible,
.list-table td.list-table__actions-cell .list-card__action:focus-visible {
    border-radius: 2px;
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* ===== Sortable headers (static/js/list/list-sort.js): th[data-sort-field] holds a button with the direction ===== */
.list-sort {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    white-space: nowrap;
}

.list-sort__icon {
    font-size: 0.75em;
    opacity: 0.4;
}

.list-sort:hover .list-sort__icon,
.list-sort.is-active .list-sort__icon {
    opacity: 1;
}

.list-sort.is-active {
    color: var(--primary);
}

/* ===== Tick boxes + bulk bar (static/js/list/list-select.js, list-bulk.html) ===== */
.list-table__check {
    width: 40px;
    text-align: center;
}

.list-table tr.is-selected td {
    background: #dbeafe;
}

/* Sticky bar while rows are ticked: count, one button per action, "Bỏ chọn" */
.list-bulk {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky, 1020);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 10px;
    background: var(--primary-light, #eff6ff);
    font-size: 0.875rem;
    font-weight: 600;
}

.list-bulk.d-none {
    display: none;
}

.list-bulk__count {
    margin-right: auto;
}

.list-bulk__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.list-bulk__actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

/* ===== Cards of the list pages (Thẻ): list-format.js cardTitle / agentLine / detailRow / statPill =====
   Builds on .house-mng-card from static/css/components/house-card.css */
/* Header: the rooms pill stays at the top right and the address may take two lines instead of one cut line */
.list-card .house-mng-card__head {
    align-items: flex-start;
}

.list-card .house-mng-card__address {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    white-space: normal;
}

/* Landlord name · phone on one line at every width: the phone always shows in full, a long name is cut with "…" */
.list-card__agent {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    min-width: 0;
    margin: 0.375rem 0 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
}

.list-card__agent > i {
    flex-shrink: 0;
}

.list-card__agent > span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.list-card__phone {
    flex-shrink: 0;
    color: #fff;
    font-weight: 400;
    text-decoration: none;
    white-space: nowrap;
}

.list-card__phone::before {
    content: "·";
    margin-right: 0.375rem;
}

.list-card__phone:hover {
    text-decoration: underline;
}

.list-card__details {
    margin: 0;
    padding: 0.5rem 1rem;
}

.list-card__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0;
    font-size: 0.9rem;
}

.list-card__row + .list-card__row {
    border-top: 1px dashed var(--border, #e5e7eb);
}

.list-card__label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-weight: 400;
    color: #4b5563;
}

.list-card__row-icon {
    width: 1.1em;
    text-align: center;
    color: var(--primary);
}

.list-card__value {
    margin: 0;
    font-weight: 600;
    text-align: right;
    color: #111827;
}

/* Actions: one line while they fit; otherwise the buttons that do not fit move to the next line, and a label longer
   than a whole line breaks inside its button instead of spilling out of it */
.list-card__footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0.75rem;
    padding: 0.75rem 0;
    border-top: 1px solid var(--border, #e5e7eb);
}

.list-card__action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    min-width: 0;
    min-height: 40px;
    padding: 0.5rem 0.875rem;
    white-space: normal;
    text-align: center;
    line-height: 1.25;
    border: 1px solid var(--primary);
    border-radius: 8px;
    background: #fff;
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: filter var(--transition-base, 0.15s);
}

.list-card__action:hover {
    filter: brightness(0.95);
}

/* Each starts at its label's width and grows to fill the line (flex-basis auto = the label's width) */
.list-card__action--primary {
    flex: 1 1 auto;
    background: var(--primary);
    color: #fff;
}

.list-card__action--outline {
    flex: 1 1 auto;
}

/* Settings gear: pushed to the right edge */
.list-card__action--icon {
    flex: 0 0 auto;
    width: 40px;
    margin-left: auto;
    padding: 0;
    border-color: var(--border, #e5e7eb);
    color: #4b5563;
}

/* Icon buttons after the first (history, then gear) sit next to it instead of splitting the free space */
.list-card__action--icon + .list-card__action--icon {
    margin-left: 0;
}

/* Phones: tighter footer so the four actions of /hoa-don/ still fit on one row at 360-430px */
@media (max-width: 575.98px) {
    .list-card__details {
        padding: 0.25rem 0.875rem;
    }

    .list-card__row {
        padding: 0.4375rem 0;
        font-size: 0.875rem;
    }

    .list-card__footer {
        gap: 0.375rem;
        margin: 0 0.875rem;
        padding: 0.625rem 0 0.75rem;
    }

    .list-card__action {
        padding: 0.5rem 0.5rem;
        font-size: 0.875rem;
    }

    .list-card__action--icon {
        width: 40px;
        padding: 0;
    }
}

/* 360-374px phones: a bit smaller still, so "Xuất hóa đơn" keeps one line */
@media (max-width: 374.98px) {
    .list-card__action {
        padding: 0.5rem 0.375rem;
        font-size: 0.8125rem;
    }

    .list-card__action--icon {
        width: 36px;
        padding: 0;
    }
}

/* Tick box at the left of the blue card header (cards that can be selected) */
.list-card__select {
    display: inline-flex;
    flex: 0 0 auto;
    padding-top: 0.125rem;
    cursor: pointer;
}

.list-card__select .form-check-input {
    width: 1.25rem;
    height: 1.25rem;
    margin: 0;
    border-color: #fff;
    cursor: pointer;
}

.list-card.is-selected {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ===== Status badge (list-format.js badge(text, tone)) ===== */
.list-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}

.list-badge--neutral { background: #f3f4f6; color: #4b5563; }
.list-badge--info { background: #dbeafe; color: #1d4ed8; }
.list-badge--success { background: #dcfce7; color: #15803d; }
.list-badge--warning { background: #fef3c7; color: #b45309; }
.list-badge--danger { background: #fee2e2; color: #b91c1c; }

/* Under the title of a card */
.list-card .house-mng-card__heading > .list-badge {
    align-self: flex-start;
    margin-top: 0.25rem;
}

/* ===== Pinch zoom of the list (static/js/list/list-zoom.js) =====
   Touch screens only: the badge shows the zoom while pinching; a tap resets to 100%. */
.list-zoom-badge {
    position: fixed;
    top: calc(var(--navbar-height, 56px) + 0.75rem);
    left: 50%;
    z-index: var(--z-popover);
    transform: translateX(-50%);
    padding: 0.25rem 0.75rem;
    border: 0;
    border-radius: 999px;
    background: rgba(17, 24, 39, 0.85);
    color: #fff;
    font-size: 0.875rem;
    font-weight: 600;
}

.list-zoom-badge[hidden] {
    display: none;
}
