/* ============================================================================
   LogiFlotte — tableaux (.table + variantes --compact et --hover).
   ============================================================================ */

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    font-size: var(--font-size-sm);
}

.table th {
    padding: var(--space-3) var(--space-4);
    background: var(--color-surface-alt);
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

.table td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }

.table td.text-right,
.table th.text-right { text-align: right; }

/* -- Variante compacte -- */
.table--compact th,
.table--compact td {
    padding: var(--space-2) var(--space-3);
}

/* -- Variante ligne au survol -- */
.table--hover tbody tr {
    transition: background var(--transition);
}
.table--hover tbody tr:hover {
    background: var(--color-surface-alt);
}

/* -- Wrapper scrollable horizontal (mobile/tableaux larges) -- */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
}
.table-wrap .table {
    border: none;
}

/* -- Formulaire inline dans un tableau (actions rapides) -- */
.inline-form {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    margin: 0;
}
.inline-form select,
.inline-form input[type="text"],
.inline-form input[type="number"] {
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
}

/* -- Ligne marquée comme supprimée -- */
.table tr.is-deleted td {
    opacity: 0.5;
    text-decoration: line-through;
}

/* -- Mobile : tout tableau placé dans .card gagne un scroll horizontal -- */
@media (max-width: 768px) {
    /* `display: block` sur un <table> etait le pis-aller employe ici : il
       rend le tableau defilant, mais lui fait perdre `width: 100%` et
       impose `nowrap` a toutes les cellules. Tous les tableaux etant
       desormais dans un `.table-wrap`, c est le conteneur qui defile et
       le tableau redevient un tableau. */
    .table th, .table td {
        padding: var(--space-2) var(--space-3);
    }
}

/* ==================== Ligne en retard ====================================
   Une échéance dépassée doit se repérer sans lire la colonne de date :
   liseré rouge à gauche + fond très léger sur toute la ligne. */
.table tr.is-overdue > td {
    background: var(--color-danger-light);
}
.table tr.is-overdue > td:first-child {
    box-shadow: inset 3px 0 0 var(--color-danger);
}

/* ============================================================================
   Tableau « data-table » — variante dense utilisée par Clients, Locations et
   Sinistres.

   Vivait auparavant dans pages/clients.css, alors que trois pages s'en
   servent. Remonté ici, où on le cherche.
   ============================================================================ */

.data-table-wrap {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);

    /* `overflow: hidden` COUPAIT le tableau dès que l'écran devenait étroit :
       les dernières colonnes disparaissaient sans aucun moyen d'y accéder.
       Un défilement horizontal les rend au contraire toutes atteignables. */
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;

    /* Le rayon reste net malgré le défilement. */
    overflow-y: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.data-table thead th {
    background: color-mix(in srgb, var(--color-secondary) 4%, var(--color-surface));
    text-align: left;
    padding: var(--space-2) var(--space-3);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}
.data-table tbody td {
    padding: var(--space-3);
    vertical-align: middle;
    border-bottom: 1px solid color-mix(in srgb, var(--color-border) 60%, transparent);
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover {
    background: color-mix(in srgb, var(--color-primary) 3%, transparent);
}
.data-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.data-table .actions-col {
    text-align: right;
    white-space: nowrap;
    width: 1%;
}
.data-table .actions-col .btn,
.data-table .actions-col .inline-form {
    margin-left: 4px;
    display: inline-block;
    vertical-align: middle;
}
.data-table .inline-form { margin-bottom: 0; }

/* ----------------------------------------------------------------- Mobile */

@media (max-width: 640px) {
    /* Une table dense reste une table : on ne la transforme pas en liste de
       cartes, ce qui ferait perdre la comparaison colonne par colonne qui est
       tout l'intérêt du tableau. On resserre, et on laisse défiler. */
    .data-table { font-size: 0.84rem; }
    .data-table thead th { padding: var(--space-2); }
    .data-table tbody td { padding: var(--space-2); }

    /* Les boutons d'action passent au-dessus du seuil tactile. */
    .data-table .actions-col .btn {
        min-height: 34px;
        display: inline-flex;
        align-items: center;
    }
}

/* Indice de défilement : une ombre portée au bord droit tant qu'il reste du
   contenu à découvrir. Sans elle, rien ne dit qu'il faut faire glisser. */
.table-wrap,
.data-table-wrap {
    background-image:
        linear-gradient(to right, var(--color-surface) 30%, rgb(255 255 255 / 0)),
        linear-gradient(to right, rgb(255 255 255 / 0), var(--color-surface) 70%),
        linear-gradient(to right, rgb(23 21 41 / .10), rgb(23 21 41 / 0)),
        linear-gradient(to left,  rgb(23 21 41 / .10), rgb(23 21 41 / 0));
    background-position: 0 0, 100% 0, 0 0, 100% 0;
    background-repeat: no-repeat;
    background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
    background-attachment: local, local, scroll, scroll;
}
