/* =========================================================
   RAMDA TABLE — Styles du composant de tableau GLOBAL
   Fichier : ramda-table.css  (à charger avec ramda-table.js)

   Utilise les variables du thème : --color-ink, --color-teal,
   --color-white, --color-gray-border, --color-gray-light,
   --color-gray-medium, --font-sans, --radius-md, --shadow-sm.
   ========================================================= */

/* ============================================================
   1. CONTENEUR DE DÉFILEMENT
   Le wrapper est le SEUL élément qui défile (horizontal + vertical).
   Aucun parent entre lui et le <table> ne doit avoir overflow:hidden,
   sinon "position: sticky" ne fonctionne plus.
   ============================================================ */
.rt-wrapper {
    overflow: auto;
    position: relative;
    -webkit-overflow-scrolling: touch;
    width:100%;
    
}

/* ============================================================
   2. TABLEAU
   Les largeurs sont posées par le JS (colgroup) : mesurées
   automatiquement, puis modifiables par l'utilisateur.
   ============================================================ */
.rt-table {
    --rt-border: var(--color-gray-border, #E5E7EB);
    --rt-head-bg: #f1f5f9;
    --rt-head-color: var(--color-ink, #111827);
    --rt-bg: var(--color-white, #fff);
    --rt-hover: #F9FAFB;

    /* === Nouvelles variables (styles de tableau) === */
    --rt-row-alt: transparent;                 /* bandes alternées */
    --rt-cell-padding-y: 12px;
    --rt-cell-padding-x: 16px;
    --rt-th-padding-y: 10px;
    --rt-th-padding-x: 16px;
    --rt-selected-bg: rgba(14, 124, 134, 0.08);
    --rt-selected-hover-bg: rgba(14, 124, 134, 0.13);
    --rt-border-vertical: transparent;         /* bordures verticales */
    --rt-pin-shadow: 2px 0 4px -2px rgba(0, 0, 0, 0.15);

    table-layout: fixed;
    border-collapse: separate; /* "collapse" fait sauter les bordures avec sticky */
    border-spacing: 0;
    font-family: var(--font-sans, inherit);
    font-size: 13px;
}

/* Mesure automatique des largeurs (classe posée brièvement par le JS) */
.rt-table.rt-measuring {
    table-layout: auto !important;
    width: auto !important;
    min-width: 0 !important;
}
.rt-table.rt-measuring col {
    width: auto !important;
}

.rt-table th,
.rt-table td {
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- En-tête (figé en haut) ---------- */
.rt-table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 0;
    text-align: left;
    background: var(--rt-head-bg);
    color: var(--rt-head-color);
    border-bottom: var(--rt-border-width, 1px) solid var(--rt-border);
}

.rt-th-inner {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: var(--rt-th-padding-y) 6px var(--rt-th-padding-y) var(--rt-th-padding-x);
    min-width: 0;
}

.rt-th-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.rt-th-label.rt-sortable {
    cursor: pointer;
    user-select: none;
}

.rt-sort-ind {
    flex-shrink: 0;
    font-size: 10px;
    color: var(--color-teal, #0E7C86);
}

.rt-th-menu {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--color-gray-medium, #6B7280);
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.rt-th-menu:hover {
    background: #E0F2FE;
    color: var(--color-teal, #0E7C86);
}

.rt-th-menu.is-active {
    background: #E0F2FE;
    color: var(--color-teal, #0E7C86);
}

/* Poignée de redimensionnement (bord droit de l'en-tête) */
.rt-resizer {
    position: absolute;
    top: 0;
    right: 0;
    width: 10px;
    height: 100%;
    cursor: col-resize;
    touch-action: none;
    user-select: none;
    z-index: 2;
}

.rt-resizer::after {
    content: '';
    position: absolute;
    top: 25%;
    bottom: 25%;
    right: 4px;
    width: 2px;
    border-radius: 1px;
    background: var(--rt-border);
    transition: background 0.15s;
}

.rt-resizer:hover::after,
.rt-resizing .rt-resizer::after {
    background: var(--color-teal, #0E7C86);
}

body.rt-no-select {
    user-select: none;
    cursor: col-resize;
}

/* ---------- Lignes et cellules ---------- */
.rt-table td {
    padding: var(--rt-cell-padding-y) var(--rt-cell-padding-x);
    color: var(--color-ink, #111827);
    vertical-align: middle;
    background: var(--rt-bg);
    border-bottom: var(--rt-border-width, 1px) solid var(--rt-border);
    border-right: var(--rt-border-width, 1px) solid var(--rt-border-vertical);
    transition: background 0.15s;
}

/* Dernière colonne : pas de bordure droite verticale */
.rt-table td:last-child {
    border-right: none;
}

/* Bandes alternées (désactivées par défaut : --rt-row-alt = transparent) */
.rt-table tbody tr:nth-child(even) td {
    background: var(--rt-row-alt);
}

/* ============================================================
   SÉLECTION DES LIGNES
   ============================================================ */

/* Colonne de sélection figée à gauche */
.rt-table .rt-selection-cell,
.rt-table .rt-selection-header {
    position: sticky;
    left: 0;
    z-index: 5;

    padding: 0 !important;
    text-align: center;
    vertical-align: middle;
}

/* En-tête de sélection au-dessus des cellules */
.rt-table .rt-selection-header {
    z-index: 15;
}

/* Conserver la disposition horizontale de l'en-tête */
.rt-table .rt-selection-header .rt-th-inner {
    justify-content: flex-start;
    padding-left: var(--rt-th-padding-x);
    padding-right: 6px;
    gap: 4px;
}

/* Cases à cocher */
.rt-table .rt-row-checkbox,
.rt-table .rt-select-all-checkbox {
    appearance: none;
    -webkit-appearance: none;

    display: inline-grid;
    place-content: center;

    width: 17px;
    height: 17px;
    margin: 0;
    padding: 0;

    border: 1.5px solid var(--color-gray-medium, #9CA3AF);
    border-radius: 4px;

    background: var(--color-white, #fff);
    cursor: pointer;

    vertical-align: middle;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

/* Aligner les cases du tbody avec celle de l'en-tête */
.rt-table tbody .rt-selection-cell .rt-row-checkbox {
    transform: translateX(-14px);
}

/* Case cochée */
.rt-table .rt-row-checkbox:checked,
.rt-table .rt-select-all-checkbox:checked {
    background: var(--color-teal, #0E7C86);
    border-color: var(--color-teal, #0E7C86);
}

/* Symbole de validation */
.rt-table .rt-row-checkbox:checked::before,
.rt-table .rt-select-all-checkbox:checked::before {
    content: '';
    width: 8px;
    height: 4px;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(-45deg);
    margin-top: -2px;
}

/* État intermédiaire de la sélection globale */
.rt-table .rt-select-all-checkbox:indeterminate {
    background: var(--color-teal, #0E7C86);
    border-color: var(--color-teal, #0E7C86);
}

.rt-table .rt-select-all-checkbox:indeterminate::before {
    content: '';
    width: 8px;
    height: 2px;
    background: #fff;
}

/* ============================================================
   LIGNE SÉLECTIONNÉE
   ============================================================ */

.rt-table tbody tr:has(.rt-row-checkbox:checked) td {
    background: var(--rt-selected-bg);
}

/* Survol d'une ligne sélectionnée */
.rt-table tbody tr:has(.rt-row-checkbox:checked):hover td {
    background: var(--rt-selected-hover-bg);
}

/* Survol et focus */
.rt-table .rt-row-checkbox:hover,
.rt-table .rt-select-all-checkbox:hover {
    border-color: var(--color-teal, #0E7C86);
}

.rt-table .rt-row-checkbox:focus-visible,
.rt-table .rt-select-all-checkbox:focus-visible {
    outline: 3px solid rgba(14, 124, 134, 0.18);
    outline-offset: 2px;
}

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

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

.rt-table .col-actions {
    text-align: right;
}

.rt-table td.col-actions {
    white-space: nowrap;
}

/* Ligne "aucun résultat" (quand les filtres de colonne vident la liste) */
.rt-table .rt-empty-row td,
.rt-table .rt-empty-row:hover td {
    padding: 40px 16px;
    text-align: center;
    white-space: normal;
    color: var(--color-gray-medium, #6B7280);
    background: var(--rt-bg);
}

.rt-link {
    border: none;
    background: none;
    padding: 0;
    margin-left: 6px;
    color: var(--color-teal, #0E7C86);
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
}

/* ============================================================
   3. COLONNES FIGÉES
   Le JS pose --rt-left-1 … --rt-left-6 sur le <table>
   (= somme des largeurs RÉELLES des colonnes figées précédentes),
   donc ça s'adapte tout seul au redimensionnement.
   ============================================================ */
.rt-table .rt-pin {
    position: sticky;
    z-index: 5;
}

.rt-table thead th.rt-pin {
    z-index: 15; /* le coin (en-tête + colonne figée) passe au-dessus de tout */
}

.rt-table .rt-pin-1 { left: var(--rt-left-1, 0px); }
.rt-table .rt-pin-2 { left: var(--rt-left-2, 0px); }
.rt-table .rt-pin-3 { left: var(--rt-left-3, 0px); }
.rt-table .rt-pin-4 { left: var(--rt-left-4, 0px); }
.rt-table .rt-pin-5 { left: var(--rt-left-5, 0px); }
.rt-table .rt-pin-6 { left: var(--rt-left-6, 0px); }

/* Séparation visuelle après la dernière colonne figée */
.rt-table .rt-pin-last {
    border-right: var(--rt-border-width, 1px) solid var(--rt-border);
    box-shadow: var(--rt-pin-shadow);
}

/* ============================================================
   4. MENU DE COLONNE (tri + filtre)
   ============================================================ */
.rt-menu {
    position: fixed;
    z-index: 9000;
    display: flex;
    flex-direction: column;
    min-width: 230px;
    max-width: min(320px, 92vw);
    max-height: calc(100vh - 16px);
    overflow: hidden;
    background: var(--color-white, #fff);
    border: 1px solid var(--color-gray-border, #E5E7EB);
    border-radius: var(--radius-md, 8px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    font-family: var(--font-sans, inherit);
    font-size: 13px;
    color: var(--color-ink, #111827);
}

.rt-menu-sec {
    padding: 6px;
}

.rt-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-radius: 6px;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.rt-menu-item i {
    width: 14px;
    text-align: center;
    color: var(--color-gray-medium, #6B7280);
}

.rt-menu-item:hover {
    background: #E0F2FE;
    color: var(--color-teal, #0E7C86);
}

.rt-menu-item:hover i {
    color: var(--color-teal, #0E7C86);
}

.rt-menu-item.is-on {
    font-weight: 600;
    color: var(--color-teal, #0E7C86);
}

.rt-menu-item.is-on i {
    color: var(--color-teal, #0E7C86);
}

.rt-menu-sep {
    height: 1px;
    margin: 2px 0;
    background: var(--color-gray-border, #E5E7EB);
}

.rt-menu-filter {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
    padding: 10px;
}

.rt-input {
    width: 100%;
    box-sizing: border-box;
    padding: 7px 9px;
    border: 1px solid var(--color-gray-border, #E5E7EB);
    border-radius: 6px;
    background: var(--color-white, #fff);
    color: inherit;
    font: inherit;
}

.rt-input:focus {
    outline: none;
    border-color: var(--color-teal, #0E7C86);
    box-shadow: 0 0 0 3px rgba(14, 124, 134, 0.1);
}

.rt-range {
    display: flex;
    gap: 6px;
}

.rt-range .rt-input {
    min-width: 0;
}

.rt-range-lbl {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 11px;
    color: var(--color-gray-medium, #6B7280);
}

.rt-menu-list {
    max-height: 190px;
    overflow: auto;
    padding: 4px;
    border: 1px solid var(--color-gray-border, #E5E7EB);
    border-radius: 6px;
}

.rt-check {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
    border-radius: 4px;
    cursor: pointer;
}

.rt-check:hover {
    background: #F3F4F6;
}

.rt-check input {
    flex-shrink: 0;
    width: auto;
    margin: 0;
}

.rt-check span {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rt-check em {
    flex-shrink: 0;
    font-size: 11px;
    font-style: normal;
    color: var(--color-gray-medium, #6B7280);
}

.rt-check-all {
    border-bottom: 1px solid var(--color-gray-border, #E5E7EB);
    border-radius: 4px 4px 0 0;
    margin-bottom: 2px;
    font-weight: 600;
}

.rt-more {
    padding: 6px;
    font-size: 11px;
    color: var(--color-gray-medium, #6B7280);
}

.rt-menu-foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 8px 10px;
    border-top: 1px solid var(--color-gray-border, #E5E7EB);
}

.rt-btn {
    padding: 6px 12px;
    border: 1px solid var(--color-gray-border, #E5E7EB);
    border-radius: 6px;
    background: var(--color-white, #fff);
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.rt-btn:hover {
    border-color: var(--color-teal, #0E7C86);
    color: var(--color-teal, #0E7C86);
}

.rt-btn-primary {
    background: var(--color-teal, #0E7C86);
    border-color: var(--color-teal, #0E7C86);
    color: #fff;
}

.rt-btn-primary:hover {
    background: #0A5F68;
    color: #fff;
}


/* ============================================================
   5. FENÊTRE « COLONNES »
   Configuration : nom, nom personnalisé, afficher, figer, ordre
   ============================================================ */

.rt-cfg-panel[data-rt-panel="columns"] {
    overflow-x: auto;
    min-width: 0;
}

/* Grille de l'en-tête et des lignes */
.rt-cfg-panel[data-rt-panel="columns"] .rt-cfg-head,
#rt-column-rows-list .rt-cfg-row {
    display: grid;
    grid-template-columns: 100px 120px 80px 80px 100px;
    align-items: center;
    gap: 0px;
    min-width: 660px;
    padding: 6px 0;
    border-bottom: 1px solid #F3F4F6;
    box-sizing: border-box;
}

/* En-tête */
.rt-cfg-panel[data-rt-panel="columns"] .rt-cfg-head {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--color-gray-medium, #6B7280);
}

/* Centrer les trois dernières colonnes */
.rt-cfg-panel[data-rt-panel="columns"] .rt-cfg-head span:nth-child(n+3) {
    text-align: center;
}

/* Première colonne fixe */
.rt-cfg-panel[data-rt-panel="columns"] .rt-cfg-head span:first-child,
#rt-column-rows-list .rt-cfg-name-cell {
    position: sticky;
    left: 0;
    z-index: 3;
    background: var(--color-white, #fff);
}

/* Deuxième colonne fixe */
.rt-cfg-panel[data-rt-panel="columns"] .rt-cfg-head span:nth-child(2),
#rt-column-rows-list .rt-cfg-custom-title {
    position: sticky;
    left: 100px;
    z-index: 3;
    background: var(--color-white, #fff);
}

/* En-tête au-dessus des lignes */
.rt-cfg-panel[data-rt-panel="columns"] .rt-cfg-head span:first-child,
.rt-cfg-panel[data-rt-panel="columns"] .rt-cfg-head span:nth-child(2) {
    z-index: 5;
    background: #f1f5f9;
}

/* Nom de colonne */
.rt-cfg-name-cell {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Champ de nom personnalisé */
.rt-cfg-custom-title input {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

/* Cellules Afficher, Figer et Ordre */
.rt-cfg-panel[data-rt-panel="columns"] .rt-cfg-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* Boutons de déplacement */
.rt-cfg-order-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* Boutons Monter / Descendre */
.rt-cfg-order-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--color-gray-border, #E5E7EB);
    border-radius: 6px;
    background: var(--color-white, #fff);
    color: var(--color-ink, #111827);
    font-size: 16px;
    cursor: pointer;
}

/* Bouton Monter */
.rt-cfg-order-actions button[data-direction="up"] {
    border-color: #BBF7D0;
    background: #F0FDF4;
    color: #15803D;
}

/* Bouton Descendre */
.rt-cfg-order-actions button[data-direction="down"] {
    border-color: #FECACA;
    background: #FEF2F2;
    color: #DC2626;
}

/* Boutons désactivés */
.rt-cfg-order-actions button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* Focus clavier */
.rt-cfg-order-actions button:focus-visible {
    outline: 2px solid var(--color-teal, #0E7C86);
    outline-offset: 2px;
}

/* Cellules de configuration des lignes : conserver leur grille */
.rt-cfg-panel-rows .rt-cfg-row {
    grid-template-columns: 1fr minmax(180px, 1fr);
}

/* Indication */
.rt-cfg-hint {
    margin: 12px 0 0;
    font-size: 11px;
    line-height: 1.4;
    color: var(--color-gray-medium, #6B7280);
}


/* ============================================================
   5.1. ONGLETS DE CONFIGURATION
   ============================================================ */

.rt-cfg-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--color-gray-border, #E5E7EB);
}

.rt-cfg-tab {
    position: relative;
    padding: 10px 16px;
    border: none;
    border-radius: 6px 6px 0 0;
    background: transparent;
    color: var(--color-gray-medium, #6B7280);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.rt-cfg-tab:hover {
    color: var(--color-teal, #0E7C86);
    background: #F0F9FA;
}

.rt-cfg-tab.is-active {
    color: var(--color-teal, #0E7C86);
}

.rt-cfg-tab.is-active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--color-teal, #0E7C86);
}

.rt-cfg-tab:focus-visible {
    outline: 2px solid var(--color-teal, #0E7C86);
    outline-offset: -2px;
}

.rt-cfg-panel[hidden] {
    display: none !important;
}

.rt-cfg-panel-rows {
    min-height: 100px;
}

.rt-cfg-panel-rows .rt-cfg-row {
    grid-template-columns: 1fr minmax(180px, 1fr);
}

/* ============================================================
   5.2. ORDRE D'AFFICHAGE DES LANGUES
   ============================================================ */

.rt-cfg-language-order {
    margin-top: 18px;
}

.rt-cfg-order-title {
    margin-bottom: 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-ink, #111827);
}

#rt-cell-language-order-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.rt-cfg-language-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 10px;
    border: 1px solid var(--color-gray-border, #E5E7EB);
    border-radius: var(--radius-md, 8px);
    background: var(--color-white, #fff);
}

.rt-cfg-language-item > span {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-ink, #111827);
}

.rt-cfg-language-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.rt-cfg-language-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--color-gray-border, #E5E7EB);
    border-radius: 6px;
    background: var(--color-white, #fff);
    color: var(--color-ink, #111827);
    font-size: 16px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

/* Bouton pour monter : vert */
.rt-cfg-language-actions button[data-direction="up"] {
    border-color: #BBF7D0;
    background: #F0FDF4;
    color: #15803D;
}

/* Survol du bouton monter */
.rt-cfg-language-actions button[data-direction="up"]:hover:not(:disabled) {
    border-color: #16A34A;
    background: #DCFCE7;
    color: #166534;
}

/* Bouton pour descendre : rouge */
.rt-cfg-language-actions button[data-direction="down"] {
    border-color: #FECACA;
    background: #FEF2F2;
    color: #DC2626;
}

/* Survol du bouton descendre */
.rt-cfg-language-actions button[data-direction="down"]:hover:not(:disabled) {
    border-color: #DC2626;
    background: #FEE2E2;
    color: #991B1B;
}


.rt-cfg-language-actions button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.rt-cfg-language-actions button:focus-visible {
    outline: 2px solid var(--color-teal, #0E7C86);
    outline-offset: 2px;
}

/* ============================================================
   5.3. ONGLET « STYLES DE TABLEAU » (NOUVEAU)
   ============================================================ */

.rt-cfg-panel-styles {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding-top: 4px;
}

.rt-cfg-styles-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.rt-cfg-styles-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-ink, #111827);
}

/* Cartes de presets */
.rt-cfg-presets {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
}

.rt-cfg-preset {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--color-gray-border, #E5E7EB);
    border-radius: var(--radius-md, 8px);
    background: var(--color-white, #fff);
    cursor: pointer;
    text-align: left;
    font: inherit;
    color: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.rt-cfg-preset:hover {
    border-color: var(--color-teal, #0E7C86);
}

.rt-cfg-preset.is-active {
    border-color: var(--color-teal, #0E7C86);
    box-shadow: 0 0 0 2px rgba(14, 124, 134, 0.15);
}

.rt-cfg-preset-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-ink, #111827);
}

/* Aperçu miniature d'un preset */
.rt-cfg-preset-preview {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--color-gray-border, #E5E7EB);
    border-radius: 4px;
    overflow: hidden;
    background: var(--color-white, #fff);
    font-size: 8px;
    line-height: 1;
}

.rt-cfg-preset-preview .rt-cfg-preview-head,
.rt-cfg-preset-preview .rt-cfg-preview-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
}

.rt-cfg-preset-preview .rt-cfg-preview-head span,
.rt-cfg-preset-preview .rt-cfg-preview-row span {
    padding: 4px 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Défaut / minimal : pas de bordures internes, pas de bandes */
[data-preview="default"] .rt-cfg-preview-head,
[data-preview="minimal"] .rt-cfg-preview-head {
    background: #f1f5f9;
}

/* Bandes */
[data-preview="striped"] .rt-cfg-preview-row:nth-child(even) span,
[data-preview="excel"] .rt-cfg-preview-row:nth-child(even) span {
    background: #F3F4F6;
}

/* Bordures */
[data-preview="bordered"] .rt-cfg-preview-head span,
[data-preview="bordered"] .rt-cfg-preview-row span {
    border-right: 1px solid #E5E7EB;
    border-bottom: 1px solid #E5E7EB;
}

/* Excel : en-tête teal */
[data-preview="excel"] .rt-cfg-preview-head span {
    background: #0E7C86;
    color: #fff;
}

/* Sombre */
[data-preview="dark"] .rt-cfg-preview-head span {
    background: #1F2937;
    color: #F9FAFB;
}
[data-preview="dark"] {
    background: #111827;
}
[data-preview="dark"] .rt-cfg-preview-row:nth-child(even) span {
    background: #1F2937;
}
[data-preview="dark"] .rt-cfg-preview-row span {
    color: #E5E7EB;
}

/* Compact */
[data-preview="compact"] .rt-cfg-preview-head span,
[data-preview="compact"] .rt-cfg-preview-row span {
    padding: 2px 3px;
}

/* Options fines */
.rt-cfg-styles-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 16px;
}

.rt-cfg-styles-grid .rt-cfg-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.rt-cfg-styles-grid .rt-cfg-row label {
    font-size: 12px;
    color: var(--color-gray-medium, #6B7280);
}

.rt-cfg-styles-grid .rt-cfg-row input[type="color"] {
    width: 100%;
    height: 34px;
    padding: 2px;
    border: 1px solid var(--color-gray-border, #E5E7EB);
    border-radius: 6px;
    background: var(--color-white, #fff);
    cursor: pointer;
}

.rt-cfg-styles-grid .rt-cfg-row input[type="color"]:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.rt-cfg-styles-grid .rt-cfg-row input[type="checkbox"] {
    width: auto;
}

.rt-cfg-styles-grid .rt-cfg-row select {
    padding: 7px 9px;
    border: 1px solid var(--color-gray-border, #E5E7EB);
    border-radius: 6px;
    background: var(--color-white, #fff);
    font: inherit;
}

.rt-cfg-styles-inline {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Aperçu live */
.rt-cfg-style-preview-wrap {
    border: 1px solid var(--color-gray-border, #E5E7EB);
    border-radius: var(--radius-md, 8px);
    overflow: auto;
    padding: 6px;
    background: var(--color-white, #fff);
}

.rt-cfg-style-preview-wrap .rt-table {
    font-size: 12px;
    width: 100%;
}

.rt-cfg-style-preview-wrap .rt-table th,
.rt-cfg-style-preview-wrap .rt-table td {
    padding: 8px 10px;
}

@media (max-width: 600px) {
    .rt-cfg-styles-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   6. MOBILE
   ============================================================ */
@media (max-width: 768px) {
    .rt-th-inner {
        padding: 8px 4px 8px 8px;
    }

    .rt-table td {
        padding: 10px 8px;
    }

    .rt-menu {
        min-width: 210px;
    }
}

/* ============================================================
   7. MENU : en-tête, corps défilant, feuille mobile, tri multi-niveaux
   ------------------------------------------------------------
   Le menu est UN <div id="rt-column-menu"> partagé (créé par le JS).
   Sur mobile (écran étroit) le JS ajoute la classe .rt-menu-sheet :
   le menu se colle en bas de la zone visible, au-dessus du clavier.
   ============================================================ */

/* Garantit que "hidden" cache le menu, quel que soit l'ordre des feuilles de style */
.rt-menu.hidden {
    display: none !important;
}

.rt-menu-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

/* En-tête du menu : nom de la colonne + bouton fermer */
.rt-menu-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-shrink: 0;
    padding: 6px 6px 6px 14px;
    border-bottom: 1px solid var(--color-gray-border, #E5E7EB);
}

.rt-menu-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.rt-menu-close {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--color-gray-medium, #6B7280);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.rt-menu-close:hover {
    background: #F3F4F6;
    color: var(--color-ink, #111827);
}

/* Seule la zone des filtres défile : tri en haut et boutons en bas restent visibles */
.rt-menu-sec,
.rt-menu-sep,
.rt-menu-foot {
    flex-shrink: 0;
}

.rt-menu-filter {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.rt-menu-list {
    max-height: min(190px, 30vh);
}

/* Case "Ajouter au tri en cours (niveau N)" */
.rt-multi {
    margin: 2px 6px 4px;
    padding: 6px 8px;
    border-radius: 6px;
    background: #F0F9FA;
    font-size: 12px;
}

/* Numéro de niveau dans l'en-tête quand plusieurs colonnes sont triées */
.rt-sort-lvl {
    flex-shrink: 0;
    align-self: flex-start;
    margin-left: -3px;
    font-size: 10px;
    font-weight: 700;
    color: var(--color-teal, #0E7C86);
}

/* --- Mobile : "feuille" au-dessus du clavier --- */
.rt-menu.rt-menu-sheet {
    border-radius: 14px;
    box-shadow: 0 -6px 28px rgba(0, 0, 0, 0.22);
}

.rt-menu-sheet .rt-menu-item {
    padding: 12px 10px;
}

.rt-menu-sheet .rt-check {
    padding: 8px 6px;
}

.rt-menu-sheet .rt-btn {
    padding: 10px 16px;
}

.rt-menu-sheet .rt-menu-close {
    width: 40px;
    height: 40px;
}

/* iOS zoome la page si le texte d'un champ fait moins de 16px : on évite ça */
.rt-menu-sheet .rt-input {
    font-size: 16px;
}

/* =========================================================
   PAGINATION RAMDA TABLE
   ========================================================= */

.rt-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-top: 1px solid var(--border-color, #e5e7eb);
    background: var(--surface-color, #fff);
    font-size: 13px;
    flex-wrap: wrap;
}

.rt-pagination-info {
    color: var(--text-muted, #6b7280);
}

.rt-pagination-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.rt-pagination-size {
    display: flex;
    align-items: center;
    gap: 6px;
}

.rt-pagination select,
.rt-pagination button {
    min-height: 34px;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 6px;
    background: var(--surface-color, #fff);
    color: inherit;
}

.rt-pagination select {
    padding: 4px 8px;
}

.rt-pagination button {
    min-width: 34px;
    padding: 5px 9px;
    cursor: pointer;
}

.rt-pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.rt-pagination-current {
    white-space: nowrap;
    font-weight: 600;
}

@media (max-width: 480px) {
    .rt-pagination {
        align-items: flex-start;
        flex-direction: column;
    }

    .rt-pagination-controls {
        width: 100%;
        justify-content: space-between;
    }
}

/* ============================================================
   8. STYLES DE TABLEAU (presets) — NOUVEAU
   ------------------------------------------------------------
   Chaque preset ne surcharge QUE les variables définies sur
   .rt-table ci-dessus. Aucune règle structurelle n'est modifiée.
   Le preset est appliqué via data-rt-style="…" sur le wrapper
   (ou sur .rt-table lui-même).
   ============================================================ */

/* --- striped : bandes alternées --- */
.rt-wrapper[data-rt-style="striped"] .rt-table,
.rt-table[data-rt-style="striped"] {
    --rt-row-alt: #F3F4F6;
}

/* --- bordered : bordures verticales + horizontales --- */
.rt-wrapper[data-rt-style="bordered"] .rt-table,
.rt-table[data-rt-style="bordered"] {
    --rt-border-vertical: var(--color-gray-border, #E5E7EB);
}

/* --- compact : densité réduite --- */
.rt-wrapper[data-rt-style="compact"] .rt-table,
.rt-table[data-rt-style="compact"] {
    --rt-cell-padding-y: 6px;
    --rt-cell-padding-x: 8px;
    --rt-th-padding-y: 6px;
    --rt-th-padding-x: 10px;
}

/* --- excel : en-tête teal, bandes légères, bordures horizontales --- */
.rt-wrapper[data-rt-style="excel"] .rt-table,
.rt-table[data-rt-style="excel"] {
    --rt-head-bg: var(--color-teal, #0E7C86);
    --rt-head-color: #ffffff;
    --rt-row-alt: #F3F4F6;
    --rt-border: #D1D5DB;
}

.rt-wrapper[data-rt-style="excel"] .rt-table thead th .rt-th-menu,
.rt-table[data-rt-style="excel"] thead th .rt-th-menu {
    color: rgba(255, 255, 255, 0.85);
}
.rt-wrapper[data-rt-style="excel"] .rt-table thead th .rt-th-menu:hover,
.rt-table[data-rt-style="excel"] thead th .rt-th-menu:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
}
.rt-wrapper[data-rt-style="excel"] .rt-table thead th .rt-sort-ind,
.rt-table[data-rt-style="excel"] thead th .rt-sort-ind {
    color: #ffffff;
}

/* --- minimal : bordures fines, hover discret ---
   NOTE : les bordures (épaisseur/couleur/type) sont désormais pilotées
   par les options fines. On ne force donc plus "border-bottom: none" ici :
   on se contente d'alléger l'en-tête et de désactiver l'ombre des colonnes
   figées. La règle générale .rt-table td (var(--rt-border-width) ...)
   reste maîtresse. */
.rt-wrapper[data-rt-style="minimal"] .rt-table,
.rt-table[data-rt-style="minimal"] {
    --rt-hover: #F9FAFB;
    --rt-head-bg: #ffffff;
    --rt-pin-shadow: none;
}

/* --- dark : en-tête sombre, texte clair, bandes sombres --- */
.rt-wrapper[data-rt-style="dark"] .rt-table,
.rt-table[data-rt-style="dark"] {
    --rt-bg: #111827;
    --rt-head-bg: #1F2937;
    --rt-head-color: #F9FAFB;
    --rt-hover: #1F2937;
    --rt-row-alt: #172033;
    --rt-border: #374151;
    --rt-border-vertical: #374151;
    --rt-selected-bg: rgba(14, 124, 134, 0.22);
    --rt-selected-hover-bg: rgba(14, 124, 134, 0.3);
    --rt-pin-shadow: 2px 0 4px -2px rgba(0, 0, 0, 0.5);
}

.rt-wrapper[data-rt-style="dark"] .rt-table td,
.rt-table[data-rt-style="dark"] td {
    color: #E5E7EB;
}

.rt-wrapper[data-rt-style="dark"] .rt-table tbody tr:hover td,
.rt-table[data-rt-style="dark"] tbody tr:hover td {
    background: var(--rt-hover);
}

.rt-wrapper[data-rt-style="dark"] .rt-table .rt-th-menu,
.rt-table[data-rt-style="dark"] .rt-th-menu {
    color: rgba(255, 255, 255, 0.7);
}
.rt-wrapper[data-rt-style="dark"] .rt-table .rt-th-menu:hover,
.rt-table[data-rt-style="dark"] .rt-th-menu:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

/* ============================================================
   DENSITÉ (complément aux presets)
   .rt-density-compact : déjà défini (à conserver)
   .rt-density-none    : padding 0 (aucun espace)
   ============================================================ */
.rt-wrapper.rt-density-none .rt-table,
.rt-table.rt-density-none {
    --rt-cell-padding-y: 0px;
    --rt-cell-padding-x: 0px;
    --rt-th-padding-y: 0px;
    --rt-th-padding-x: 0px;
}

/* ============================================================
   9. IMPRESSION (optionnel, minimal)
   ============================================================ */
@media print {
    .rt-wrapper {
        overflow: visible !important;
    }

    .rt-table {
        table-layout: auto !important;
        width: 100% !important;
    }

    .rt-table .rt-pin,
    .rt-table .rt-selection-cell,
    .rt-table .rt-selection-header {
        position: static !important;
        box-shadow: none !important;
    }

    .rt-table thead th {
        position: static !important;
        background: #f1f5f9 !important;
        color: #111827 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .rt-table tbody tr:nth-child(even) td {
        background: var(--rt-row-alt) !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .rt-th-menu,
    .rt-resizer,
    .rt-load-more {
        display: none !important;
    }
}
/* Densité compacte (pilotée par applyTableStyle) */

.rt-wrapper.rt-density-compact .rt-table,
.rt-table.rt-density-compact {
    --rt-cell-padding-y: 6px;
    --rt-cell-padding-x: 8px;
    --rt-th-padding-y: 6px;
    --rt-th-padding-x: 10px;
}

/* 1ʳᵉ colonne en gras */
.rt-wrapper.rt-first-col-bold .rt-table tbody tr td:nth-child(2),
.rt-wrapper.rt-first-col-bold .rt-table thead tr th:nth-child(2) {
    font-weight: 700;
}

/* Dernière colonne en gras */
.rt-wrapper.rt-last-col-bold .rt-table tbody tr td:last-child,
.rt-wrapper.rt-last-col-bold .rt-table thead tr th:last-child {
    font-weight: 700;
}
