/* Vue large des tableaux : voir public/js/table-view.js */

/* Filtres fermés : résumé sur une ligne */
.tv-filters-summary {
    margin-left: 12px;
    color: #4b5563;
    font-size: 13px;
    font-weight: 400;
}

/* Plus de largeur utile autour du tableau */
.tw-py-2:has(> .tv-table),
.tw-py-2:has(> .table-responsive > .tv-table) {
    padding: 0 !important;
}

/* Titre de la carte plus bas */
.tw-p-2:has(.tv-table) > .box-header {
    padding-top: 2px;
    padding-bottom: 2px;
}

/* Une seule ligne d'outils */
.tv-table .list-page-toolbar {
    margin-bottom: 6px !important;
}

.tv-table .list-page-toolbar-right {
    flex-wrap: nowrap;
}

.tv-table .list-page-toolbar-right .tw-dw-btn {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

.tv-table .list-page-toolbar-left .dataTables_length select,
.tv-table .list-page-toolbar-left .dataTables_filter input {
    height: 32px;
}

/* Tableau dense */
.tv-table table.dataTable {
    margin: 0 !important;
}

.tv-table table.dataTable > thead > tr > th,
.tv-table .dataTables_scrollHead table > thead > tr > th {
    padding: 6px 22px 6px 8px;
    font-size: 13px;
    line-height: 1.25;
    white-space: nowrap;
    vertical-align: middle;
}

.tv-table table.dataTable > tbody > tr > td,
.tv-table table.dataTable > tfoot > tr > td {
    padding: 5px 8px;
    font-size: 13px;
    line-height: 1.3;
    white-space: nowrap;
    vertical-align: middle;
}

.tv-table .dataTables_scrollFoot td {
    padding: 4px 8px !important;
    font-size: 12px;
    line-height: 1.25;
    white-space: nowrap;
}

.tv-table tbody .btn-group {
    display: inline-flex;
    height: 22px;
    margin: 0;
    vertical-align: middle;
}

.tv-table tbody img {
    max-width: 44px !important;
    max-height: 26px !important;
    width: auto;
    height: auto;
    object-fit: contain;
}

.tv-table tbody .btn-xs,
.tv-table tbody .tw-dw-btn-xs {
    height: 22px !important;
    min-height: 22px !important;
    padding: 0 8px;
    font-size: 12px;
    line-height: 20px;
}

.tv-table table.dataTable > tbody > tr > td.tv-wrap {
    min-width: 240px;
    white-space: normal;
}

/* Zone qui défile, en-têtes et totaux fixes */
.tv-viewport {
    overflow: auto;
    width: 100%;
}

.tv-viewport > table > thead > tr > th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #cbd5e1;
}

.tv-viewport > table > tfoot > tr > td {
    position: sticky;
    bottom: 0;
    z-index: 3;
    background: #e5e7eb;
}

/* Colonnes fixes à gauche */
.tv-table td.tv-sticky,
.tv-table th.tv-sticky {
    position: sticky;
    z-index: 2;
    background-color: #fff;
}

.tv-table tr:nth-of-type(odd) > td.tv-sticky {
    background-color: #f9fafb;
}

.tv-table th.tv-sticky {
    z-index: 4;
    background-color: #cbd5e1;
}

.tv-table th.tv-frozen-head {
    position: relative;
    z-index: 4;
    background-color: #cbd5e1;
}

.tv-table .tv-sticky-last {
    box-shadow: 2px 0 0 #d1d5db;
}

.tv-table td:has(> .open),
.tv-table td:has(> .btn-group.open) {
    z-index: 20;
}

.tv-table .dropdown-menu.tv-floating-menu {
    position: fixed !important;
    right: auto;
    bottom: auto;
    margin: 0;
}

/* Pagination sur une ligne : place laissée au bouton rond */
.tv-table .dataTables_info,
.tv-table .dataTables_paginate {
    float: left;
    width: auto;
    padding-top: 6px !important;
}

.tv-table .dataTables_paginate {
    float: right;
}

.tv-table .dataTables_paginate .pagination {
    margin: 0;
}

body.tv-has-table .quick-actions-fab-wrap {
    right: 10px !important;
    bottom: 10px !important;
    transform: scale(0.8);
    transform-origin: bottom right;
}

@media (min-width: 992px) {
    .tv-table .dataTables_paginate {
        margin-right: 56px !important;
    }
}

/* Plein écran : au-dessus de la page, sous les fenêtres (factures, paiements) */
.tv-table.tv-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 1035;
    padding: 8px 12px;
    background: #fff;
}

body.tv-body-fullscreen {
    overflow: hidden;
}

body.tv-body-fullscreen .quick-actions-fab-wrap {
    display: none;
}

.tv-table.tv-fullscreen .dataTables_paginate {
    margin-right: 0 !important;
}

/* Sur téléphone, la page défile normalement */
@media (max-width: 991px) {
    .tv-table .list-page-toolbar-right {
        flex-wrap: wrap;
    }

    .tv-viewport {
        overflow-x: auto;
        overflow-y: visible;
    }

    .tv-viewport > table > thead > tr > th {
        position: static;
    }

    .tv-viewport > table > tfoot > tr > td {
        position: static;
    }

    .tv-filters-summary {
        display: block;
        margin: 4px 0 0;
    }
}

@media print {
    .tv-viewport,
    .dataTables_scrollBody {
        max-height: none !important;
        overflow: visible !important;
    }
}

/* Filtres compacts : une ou deux lignes sur ordinateur */
.filters-card .box-header {
    padding: 2px 8px;
}

.filters-card .box-header .box-title {
    font-size: 15px;
}

.filters-card .box-header .box-title.tw-pt-2,
.filters-card .box-header .box-title {
    padding-top: 4px !important;
    padding-bottom: 4px !important;
}

@media (min-width: 600px) {
    .filters-card .panel-collapse {
        padding: 6px 0 4px !important;
    }

    .filters-card .box-body {
        display: grid !important;
        grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
        gap: 6px 10px;
        align-items: end;
        margin: 0 !important;
        padding: 0 12px !important;
    }

    .filters-card .box-body::before,
    .filters-card .box-body::after,
    .filters-card .box-body > .clearfix {
        display: none !important;
        content: none !important;
    }

    .filters-card .box-body > .row {
        display: contents;
    }

    .filters-card .box-body > [class*="col-"],
    .filters-card .box-body > .row > [class*="col-"] {
        float: none !important;
        flex: none !important;
        width: auto !important;
        max-width: none !important;
        min-width: 0;
        padding: 0 !important;
    }

    .filters-card .box-body > .col-md-12,
    .filters-card .box-body > .row > .col-md-12 {
        grid-column: 1 / -1;
    }

    .filters-card .form-group {
        margin-bottom: 0 !important;
    }

    .filters-card .form-group > label {
        display: block;
        margin-bottom: 2px;
        overflow: hidden;
        color: #6b7280;
        font-size: 11px;
        font-weight: 600;
        text-overflow: ellipsis;
        text-transform: uppercase;
        white-space: nowrap;
    }

    .filters-card .form-control {
        height: 32px;
        padding: 4px 8px;
        font-size: 13px;
    }

    .filters-card .select2-container {
        width: 100% !important;
    }

    .filters-card .select2-container .select2-selection--single {
        height: 32px;
    }

    .filters-card .select2-container .select2-selection--single .select2-selection__rendered {
        padding-left: 8px;
        font-size: 13px;
        line-height: 30px;
    }

    .filters-card .select2-container .select2-selection--single .select2-selection__arrow {
        height: 30px;
    }

    .filters-card .checkbox,
    .filters-card .form-group > .checkbox {
        margin: 0;
        padding-bottom: 6px;
    }
}

/* Date d'échéance sous le délai de paiement */
.due-date-field {
    clear: both;
    padding-top: 6px;
}

.due-date-field label {
    margin-bottom: 2px;
}
