/* Style de base pour le tableau public des fichiers */
.fm-files-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    margin: 1.5rem 0;
    background: #ffffff;
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.fm-files-table thead {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #ffffff;
}

.fm-files-table thead th {
    padding: 0.85rem 1rem;
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 0.02em;
    vertical-align: middle;
}

.fm-sort-button {
    display: inline-flex;
    align-items: center;
    justify-content: inherit;
    gap: 0.35rem;
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font: inherit;
    font-weight: inherit;
    letter-spacing: inherit;
    text-align: inherit;
}

.fm-sort-button::after {
    content: "↕";
    display: inline-block;
    font-size: 0.72rem;
    line-height: 1;
    opacity: 0.72;
}

.fm-sort-button[data-sort-direction="asc"]::after {
    content: "↑";
    opacity: 1;
}

.fm-sort-button[data-sort-direction="desc"]::after {
    content: "↓";
    opacity: 1;
}

.fm-sort-button:hover,
.fm-sort-button:focus {
    outline: none;
    text-decoration: underline;
    text-underline-offset: 0.18rem;
}

.fm-files-table tbody tr:nth-child(even) {
    background: #f9fafb;
}

.fm-files-table tbody tr:nth-child(odd) {
    background: #ffffff;
}

.fm-files-table tbody tr:hover {
    background: #eff6ff;
}

.fm-files-table td {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    color: #111827;
    border-top: 1px solid #e5e7eb;
    vertical-align: middle;
}

.fm-files-table__category,
.fm-files-table__document,
.fm-files-table__date {
    text-align: left;
}

.fm-files-table__version,
.fm-files-table__download {
    text-align: center;
}

.fm-files-table th.fm-files-table__version,
.fm-files-table td.fm-files-table__version {
    width: 7rem;
}

.fm-files-table th.fm-files-table__download,
.fm-files-table td.fm-files-table__download {
    width: 8rem;
}

.fm-files-table th.fm-files-table__date,
.fm-files-table td.fm-files-table__date {
    width: 10rem;
}

.fm-file-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.fm-files-table a.fm-file-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    text-decoration: none;
    font-weight: 500;
    border-radius: 50%;
    border: 1px solid #2563eb;
    color: #2563eb;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.fm-files-table a.fm-file-action:hover,
.fm-files-table a.fm-file-action:focus-visible {
    background: #2563eb;
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.35);
}

.fm-file-action svg {
    width: 1.2rem;
    height: 1.2rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.fm-load-more-wrap {
    margin: -0.65rem 0 1.5rem;
    text-align: center;
}

.fm-load-more {
    padding: 0.55rem 1.15rem;
    border: 1px solid #2563eb;
    border-radius: 999px;
    background: #ffffff;
    color: #2563eb;
    cursor: pointer;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 650;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.fm-load-more:hover,
.fm-load-more:focus-visible {
    background: #2563eb;
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
}

body.fm-file-viewer-open {
    overflow: hidden;
}

.fm-file-viewer[hidden] {
    display: none;
}

.fm-file-viewer {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
}

.fm-file-viewer__overlay {
    position: absolute;
    inset: 0;
    background: rgba(17, 24, 39, 0.72);
}

.fm-file-viewer__dialog {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: min(1100px, 96vw);
    height: min(780px, 92vh);
    overflow: hidden;
    border-radius: 0.75rem;
    background: #ffffff;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

.fm-file-viewer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
}

.fm-file-viewer__title {
    min-width: 0;
    overflow: hidden;
    color: #111827;
    font-size: 0.95rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fm-file-viewer__actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 0.5rem;
}

.fm-file-viewer__open,
.fm-file-viewer__close {
    border-radius: 999px;
    padding: 0.35rem 0.8rem;
    border: 1px solid #2563eb;
    background: #ffffff;
    color: #2563eb;
    cursor: pointer;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
}

.fm-file-viewer__close {
    background: #2563eb;
    color: #ffffff;
}

.fm-file-viewer__frame {
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    border: 0;
    background: #ffffff;
}

.fm-category-tabs {
    margin: 1.5rem 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.fm-category-tabs__input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.fm-category-tabs__nav {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.25rem;
    margin-bottom: 0;
    padding-left: 0;
    border-bottom: 1px solid #c7c7c7;
}

.fm-category-tabs__tab {
    display: inline-flex;
    align-items: center;
    min-height: 1.95rem;
    margin-bottom: -1px;
    padding: 0.35rem 0.55rem;
    border: 1px solid #c7c7c7;
    border-bottom-color: transparent;
    border-radius: 0.45rem 0.45rem 0 0;
    background: #ffffff;
    color: #3f4650;
    cursor: pointer;
    font-size: 0.86rem;
    font-weight: 700;
    line-height: 1.2;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.fm-category-tabs__tab:hover {
    background: #f3f4f6;
    border-color: #aeb4bd;
}

.fm-category-tabs__panels {
    border: 1px solid #c7c7c7;
    border-top: 0;
    border-radius: 0 0 0.45rem 0.45rem;
    background: #ffffff;
    padding: 0.85rem;
}

.fm-category-tabs__panel {
    display: none;
}

.fm-category-tabs__panel .fm-files-table {
    margin-top: 0;
    margin-bottom: 0;
}

@media (max-width: 640px) {
    .fm-files-table {
        display: block;
        border-collapse: separate;
        border-spacing: 0;
        background: transparent;
        box-shadow: none;
        font-size: 0.85rem;
    }

    .fm-files-table thead {
        display: none;
    }

    .fm-files-table tbody,
    .fm-files-table tr,
    .fm-files-table td {
        display: block;
        width: 100%;
    }

    .fm-files-table tbody tr {
        margin-bottom: 0.85rem;
        overflow: hidden;
        border: 1px solid #e5e7eb;
        border-radius: 0.65rem;
        background: #ffffff;
        box-shadow: 0 8px 18px rgba(0, 0, 0, 0.05);
    }

    .fm-files-table tbody tr:nth-child(even),
    .fm-files-table tbody tr:nth-child(odd) {
        background: #ffffff;
    }

    .fm-files-table td {
        display: grid;
        grid-template-columns: minmax(6.5rem, 40%) 1fr;
        gap: 0.75rem;
        align-items: center;
        padding: 0.65rem 0.8rem;
        border-top: 1px solid #eef2f7;
        text-align: right;
        white-space: normal;
    }

    .fm-files-table td:first-child {
        border-top: 0;
    }

    .fm-files-table td::before {
        content: attr(data-label);
        color: #6b7280;
        font-weight: 700;
        text-align: left;
    }

    .fm-files-table__category,
    .fm-files-table__document,
    .fm-files-table__date,
    .fm-files-table__version,
    .fm-files-table__download {
        text-align: right;
    }

    .fm-files-table__document {
        font-weight: 650;
    }

    .fm-files-table th.fm-files-table__version,
    .fm-files-table td.fm-files-table__version,
    .fm-files-table th.fm-files-table__download,
    .fm-files-table td.fm-files-table__download,
    .fm-files-table th.fm-files-table__date,
    .fm-files-table td.fm-files-table__date {
        width: auto;
    }

    .fm-file-actions {
        justify-content: flex-end;
    }

    .fm-category-tabs__nav {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 0.25rem;
    }

    .fm-category-tabs__tab {
        flex: 0 0 auto;
        min-height: 1.9rem;
        padding: 0.35rem 0.55rem;
        font-size: 0.82rem;
    }

    .fm-category-tabs__panels {
        padding: 0.7rem;
    }

    .fm-file-viewer {
        padding: 0.5rem;
    }

    .fm-file-viewer__dialog {
        width: 100%;
        height: 94vh;
        border-radius: 0.5rem;
    }

    .fm-file-viewer__header {
        align-items: stretch;
        flex-direction: column;
        gap: 0.5rem;
    }

    .fm-file-viewer__actions {
        justify-content: space-between;
    }
}
