/* Styles pour les tableaux */
.table-responsive {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    margin: -0.5rem;
    padding: 0.5rem;
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0;
}

.table thead {
    background: #f9fafb;
}

.table thead tr {
    border-bottom: 2px solid #e5e7eb;
}

.table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    font-size: 0.75rem;
}

.table td {
    padding: 1rem;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.938rem;
    color: var(--muted);
    vertical-align: middle;
}

.table-hover tbody tr:hover {
    background-color: #f9fafb;
}

.table-light {
    background-color: #f9fafb;
}

.table-secondary {
    opacity: 0.6;
}

.table__title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
}

.table__title .material-symbols-outlined {
    font-size: 1.5rem;
    color: var(--primary);
}

.table__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: flex-end;
    white-space: nowrap;
}

.table__ajout {
    text-align: left !important;
}

.table thead th.sorted {
    color: var(--primary);
}

.table thead th .th-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.table thead th .th-content a {
    color: inherit;
    text-decoration: none;
    flex: 1;
}

.table thead th .material-symbols-outlined {
    font-size: 1.125rem;
    color: var(--primary);
}

/* En-têtes triables */
.table thead th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s ease;
}

.table thead th.sortable:hover {
    background: var(--line);
}

.table thead th.sortable .th-content {
    justify-content: space-between;
}

.table thead th.sortable .sort-icon {
    font-size: 1.125rem;
    color: var(--muted);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.table thead th.sortable.sorted .sort-icon {
    color: var(--primary);
    font-weight: bold;
}

.table thead th.sortable.sorted.asc .sort-icon {
    transform: rotate(0deg);
}

.table thead th.sortable.sorted.desc .sort-icon {
    transform: rotate(180deg);
}

.table tbody tr {
    border-bottom: 1px solid var(--line);
    transition: background-color 0.15s ease;
}

.table tbody tr:hover {
    background: var(--bg);
}

.table tbody tr.clickable {
    cursor: pointer;
}

.table tbody tr.clickable:hover {
    background: var(--primary-bg-light, #f0f4ff);
}

.table thead th .th-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
    width: 100%;
}

.table thead th .th-wrapper a {
    color: inherit;
    text-decoration: none;
    flex: 1;
}

.table thead th .th-wrapper .sort-icon {
    font-size: 1.125rem;
    color: var(--muted);
    flex-shrink: 0;
    margin-left: auto;
}

.table thead th:hover .th-wrapper {
    background: transparent;
}

.table thead th.sorted .th-wrapper .sort-icon {
    color: var(--primary);
    font-weight: bold;
}

/* Colonne nom avec badge */
.td-nom {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.td-nom .material-symbols-outlined.filled:not([class*="member-icon"]) {
    color: #fbbf24;
}

.td-nom-content {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.td-nom-label {
    font-weight: 500;
    color: var(--ink);
}

.table-link {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s ease;
}
.table-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* État vide */
.table tbody td.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--muted);
    border: 2px dashed #e5e7eb;
}

.table tbody td.empty-state .material-symbols-outlined {
    font-size: 3rem;
    display: block;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.table tbody td.empty-state p {
    margin: 0;
    font-size: 1rem;
    max-width: none;
}

/* Responsive pour petits écrans */
@media screen and (max-width: 768px) {
    .table-responsive {
        width: calc(100vw - 5rem);
        max-width: calc(100vw - 4.5rem);
        overflow-x: auto;
    }
    
    .table {
        width: max-content;
        max-width: none;
    }
    
    .table th,
    .table td {
        padding: 0.5rem;
        font-size: 0.813rem;
        white-space: nowrap;
    }
    
    .table__title {
        white-space: nowrap;
    }
}
/* Tableau en cartes sur téléphone : ajouter la classe `table--cartes` au
   <table> et un attribut data-label="<intitulé de colonne>" sur chaque <td>.
   Sous 600 px, chaque ligne devient une carte, chaque cellule affiche son
   intitulé devant sa valeur : plus de défilement horizontal, les boutons
   d'action restent visibles. */
@media screen and (max-width: 600px) {
    .table-responsive:has(> .table--cartes) {
        margin: 0;
        padding: 0;
        overflow-x: visible;
    }

    .table--cartes thead {
        display: none;
    }

    .table--cartes,
    .table--cartes tbody,
    .table--cartes tr,
    .table--cartes td {
        display: block;
        width: 100% !important;
    }

    .table--cartes tr {
        padding: 0.5rem 0;
        border-bottom: 1px solid #e5e7eb;
    }

    .table--cartes td {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
        padding: 0.4rem 0.75rem;
        border-bottom: none;
        text-align: right;
    }

    .table--cartes td[data-label]::before {
        content: attr(data-label);
        font-size: 0.75rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        text-align: left;
        color: var(--muted);
    }

    .table--cartes td[data-label=""]::before {
        content: none;
    }

    .table--cartes td[colspan] {
        text-align: left;
    }
}
