/**
 * Data Tables Modern - Design cohérent orienté data SaaS
 * Lignes aérées, sticky header, zebra, empty state, skeleton, responsive
 */

/* ========== WRAPPER GLOBAL ========== */
.data-modern-wrap {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

.data-modern-wrap:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

/* ========== TOOLBAR (recherche, filtres, actions) ========== */
.data-modern-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.data-modern-toolbar .dataTables_filter,
.data-modern-toolbar .dataTables_length {
    margin: 0;
}

.data-modern-toolbar .dataTables_filter input {
    min-width: 260px;
    padding: 10px 16px 10px 40px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    transition:
        border-color 0.2s,
        box-shadow 0.2s;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 12px 50%;
}

.data-modern-toolbar .dataTables_filter input:focus {
    outline: none;
    border-color: #a81734;
    box-shadow: 0 0 0 3px rgba(168, 23, 52, 0.12);
}

.data-modern-toolbar .dataTables_length select {
    padding: 8px 32px 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    background-color: #fff;
}

/* ========== TABLE CONTAINER (scroll horizontal) ========== */
.data-modern-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-modern-table-wrap::-webkit-scrollbar {
    height: 6px;
}

.data-modern-table-wrap::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.data-modern-table-wrap::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

/* ========== TABLE BASE ========== */
.data-modern-table {
    width: 100% !important;
    border-collapse: separate;
    border-spacing: 0;
}

.data-modern-table thead th {
    padding: 14px 16px;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 2;
    box-shadow: 0 1px 0 0 #e2e8f0;
}

.data-modern-table thead th.sorting,
.data-modern-table thead th.sorting_asc,
.data-modern-table thead th.sorting_desc {
    cursor: pointer;
    padding-right: 26px;
}

.data-modern-table thead th.sorting:after,
.data-modern-table thead th.sorting_asc:after,
.data-modern-table thead th.sorting_desc:after {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.5;
    font-size: 10px;
}

.data-modern-table thead th.sorting_asc:after {
    opacity: 1;
    color: #a81734;
}

.data-modern-table thead th.sorting_desc:after {
    opacity: 1;
    color: #a81734;
}

/* Corps du tableau - lignes aérées */
.data-modern-table tbody td {
    padding: 16px;
    font-size: 14px;
    color: #334155;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    transition: background-color 0.15s ease;
}

/* Zebra léger */
.data-modern-table.table-striped tbody tr:nth-of-type(odd) td {
    background-color: #fafbfc;
}

.data-modern-table.table-striped tbody tr:nth-of-type(even) td {
    background-color: #fff;
}

.data-modern-table tbody tr:hover td {
    background-color: #f8fafc !important;
}

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

/* ========== ACTIONS INLINE ========== */
.data-modern-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.data-modern-actions .btn {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

/* ========== EMPTY STATE ========== */
.data-modern-empty {
    padding: 48px 24px;
    text-align: center;
    color: #64748b;
}

.data-modern-empty-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: #f1f5f9;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: #94a3b8;
}

.data-modern-empty-title {
    font-size: 16px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 8px;
}

.data-modern-empty-text {
    font-size: 14px;
    max-width: 320px;
    margin: 0 auto;
}

/* ========== SKELETON LOADING ========== */
.data-modern-skeleton {
    pointer-events: none;
}

.data-modern-skeleton tbody tr td {
    padding: 16px;
}

.data-modern-skeleton .skeleton-line {
    height: 14px;
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: 4px;
}

.data-modern-skeleton .skeleton-line.short {
    width: 60%;
}

.data-modern-skeleton .skeleton-line.medium {
    width: 85%;
}

@keyframes skeleton-shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ========== PAGINATION MODERNE ========== */
.data-modern-pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    font-size: 13px;
    color: #64748b;
}

.data-modern-pagination .dataTables_info {
    margin: 0;
}

.data-modern-pagination .dataTables_paginate {
    margin: 0;
    padding: 0;
}

.data-modern-pagination .dataTables_paginate .paginate_button {
    margin: 0 2px;
    /* padding: 8px 14px; */
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #fff;
    color: #64748b;
    transition: all 0.2s ease;
}

.data-modern-pagination .dataTables_paginate .paginate_button:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #334155;
}

.data-modern-pagination .dataTables_paginate .paginate_button.current {
    background: #a81734;
    border-color: #a81734;
    color: #fff;
}

.data-modern-pagination .dataTables_paginate .paginate_button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========== RESPONSIVE - Cards sur mobile ========== */
@media (max-width: 767px) {
    .data-modern-table-wrap {
        overflow: visible;
    }

    .data-modern-table thead {
        display: none;
    }

    .data-modern-table tbody tr {
        display: block;
        margin-bottom: 16px;
        padding: 16px;
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 10px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    }

    .data-modern-table tbody tr:hover {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }

    .data-modern-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        padding: 10px 0;
        border-bottom: 1px solid #f1f5f9;
    }

    .data-modern-table tbody td:last-child {
        border-bottom: none;
        padding-top: 12px;
    }

    .data-modern-table tbody td:before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: #64748b;
        flex-shrink: 0;
        margin-right: 12px;
    }

    .data-modern-table tbody td[data-label]:first-child:before {
        display: none;
    }

    .data-modern-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .data-modern-toolbar .dataTables_filter input {
        min-width: 100%;
    }

    .data-modern-pagination {
        flex-direction: column;
    }
}

/* ========== INTÉGRATION EXISTANTE ========== */
.twm-D_table.data-modern-wrap .table,
.data-modern-wrap .data-modern-table {
    margin-bottom: 0 !important;
}

.data-modern-wrap .dataTables_wrapper {
    display: flex;
    flex-direction: column;
}

.data-modern-wrap .dataTables_wrapper .dataTables_length,
.data-modern-wrap .dataTables_wrapper .dataTables_filter {
    margin: 0;
}

/* ========== CHARGEMENT (processing) — pagination & filtres ========== */
.data-modern-wrap {
    position: relative;
}

.data-modern-wrap .dataTables_processing {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    transform: none !important;
    z-index: 24;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 2rem 1.5rem;
    min-height: 200px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.94) 0%, rgba(248, 250, 252, 0.96) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #334155;
    letter-spacing: 0.01em;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
    pointer-events: none;
}

/* DataTables affiche l’overlay avec style inline display:block — on passe en flex sans casser display:none */
.data-modern-wrap .dataTables_processing[style*="display: block"],
.data-modern-wrap .dataTables_processing[style*="display:block"] {
    display: flex !important;
}

.data-modern-wrap .dataTables_processing::before {
    content: "";
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 3px solid #e2e8f0;
    border-top-color: #a81734;
    border-right-color: #c41e3a;
    animation: mpp-dt-spin 0.7s linear infinite;
    flex-shrink: 0;
    box-shadow: 0 2px 12px rgba(168, 23, 52, 0.12);
}

@keyframes mpp-dt-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .data-modern-wrap .dataTables_processing::before {
        animation: none;
        border-color: #cbd5e1;
        border-top-color: #a81734;
    }
}

/* Scroll horizontal (missions) : l’overlay couvre la zone scroll */
.data-modern-wrap .dataTables_scroll {
    position: relative;
    min-height: 120px;
}

.data-modern-wrap .dataTables_scroll .dataTables_processing {
    border-radius: 0;
}
