/* Tableaux dynamiques (tri, filtres, recherche, colonnes, pagination, export) — voir static/js/table.js
   Couleurs : uniquement les variables du thème ; propriétés logiques (inline-start/end) pour l'arabe. */

.dt { position: relative; }

/* ---------- barre d'outils ---------- */
.dt-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.dt-search { flex: 1 1 240px; max-width: 380px; }
.dt-search input[type=search] { width: 100%; padding-block: 7px; padding-inline: 32px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); outline: none; transition: .12s; }
.dt-search input[type=search]:focus { border-color: var(--brand); outline: 2px solid var(--brand-100); outline-offset: 0; }
.dt-extra { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* ---------- listes à cartes et catalogues (lot UX-2, voir static/js/searchlist.js) ---------- */
.sl-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.sl-search { flex: 1 1 240px; max-width: 380px; position: relative; }
.sl-search input[type=search] { width: 100%; padding-block: 7px; padding-inline: 32px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); outline: none; transition: .12s; }
.sl-search input[type=search]:focus { border-color: var(--brand); outline: 2px solid var(--brand-100); outline-offset: 0; }
.sl-search svg { position: absolute; inset-inline-start: 9px; top: 50%; transform: translateY(-50%); opacity: .6; pointer-events: none; }
.sl-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sl-filter { display: flex; align-items: center; gap: 5px; }
.sl-spacer { flex: 1 1 0; }
.sl-count { white-space: nowrap; }
.dt-spacer { flex: 1 1 0; }
.dt-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.dt-btn.on { border-color: var(--brand); color: var(--brand-600); background: var(--brand-50); }
.dt-count { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--brand); color: var(--surface); font-size: 11px; font-weight: 700; }

/* ---------- panneau des filtres ---------- */
.dt-filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 4px 12px; padding: 12px 14px 2px; margin-bottom: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.dt-field { margin-bottom: 10px; }
.dt-daterange { display: flex; align-items: center; gap: 6px; }
.dt-daterange input { min-width: 0; flex: 1 1 0; }
@media (min-width: 701px) { .dt-field-wide { grid-column: span 2; } }

/* ---------- puces des filtres actifs ---------- */
.dt-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 10px; }
.dt-chip { display: inline-flex; align-items: center; gap: 4px; padding-block: 2px; padding-inline: 10px 3px; border-radius: 999px; background: var(--brand-50); border: 1px solid var(--brand-100); color: var(--brand-600); font-size: 12px; }
.dt-chip-k { font-weight: 650; }
.dt-chip-k::after { content: " :"; }
[dir="rtl"] .dt-chip-k::after { content: ":"; }
.dt-chip-x { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; padding: 0; }
.dt-chip-x:hover { background: var(--brand-100); }
.dt-chip-x svg { width: 12px; height: 12px; }

/* ---------- tableau ---------- */
.dt-card { overflow: hidden; }
.dt-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.dt-scroll:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.dt-table th { white-space: nowrap; }
.dt-table th.dt-sortable { padding: 0; }
.dt-sort { display: flex; align-items: center; gap: 5px; width: 100%; padding: 10px 12px; border: 0; background: transparent; color: inherit; font: inherit; text-transform: inherit; letter-spacing: inherit; text-align: start; cursor: pointer; }
.dt-sort:hover { color: var(--ink); }
.dt-sort.on { color: var(--brand-600); }
.dt-sort-ind { display: inline-flex; opacity: 0; transition: opacity .12s; }
.dt-sort-ind svg { width: 12px; height: 12px; }
.dt-sort:hover .dt-sort-ind, .dt-sort:focus-visible .dt-sort-ind { opacity: .4; }
.dt-sort.on .dt-sort-ind { opacity: 1; }
th.num .dt-sort { justify-content: flex-end; }
.dt-table th.dt-center, .dt-table td.dt-center { text-align: center; }
th.dt-center .dt-sort { justify-content: center; }
.dt :focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.dt-table tr.clickable:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.dt-table tr.clickable:focus-visible td { background: var(--brand-50); }
.dt-empty-row td { padding: 0; }
.dt-empty-row:hover td { background: transparent; }
.dt-empty { display: flex; flex-direction: column; align-items: center; padding-bottom: 22px; }

/* squelettes pendant un chargement */
.dt-skel td { padding-block: 13px; }
.dt-skel:hover td { background: transparent; }
.dt-skel-bar { display: block; height: 10px; border-radius: 5px; background: linear-gradient(90deg, var(--line-2) 0%, var(--line) 50%, var(--line-2) 100%); background-size: 200% 100%; animation: dt-shimmer 1.2s ease-in-out infinite; }
@keyframes dt-shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .dt-skel-bar { animation: none; } }

/* ---------- pied : résumé, pagination ---------- */
.dt-footer { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 9px 14px; border-top: 1px solid var(--line-2); background: var(--surface-2); font-size: 12.5px; color: var(--muted); }
.dt-footer:empty { display: none; }
.dt-summary { font-variant-numeric: tabular-nums; }
.dt-pager { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-inline-start: auto; }
.dt-pager .btn.icon { padding: 4px 6px; }
.dt-pager .btn:disabled { opacity: .45; cursor: default; }
.dt-num { min-width: 30px; justify-content: center; font-variant-numeric: tabular-nums; }
.dt-num.on { background: var(--brand-100); border-color: var(--brand); color: var(--brand-600); }
.dt-gap { padding: 0 3px; }
.dt-prev svg { transform: rotate(180deg); }
[dir="rtl"] .dt-prev svg { transform: none; }
[dir="rtl"] .dt-next svg { transform: rotate(180deg); }
.dt-size-box { display: inline-flex; align-items: center; gap: 6px; }
.dt-size-box select { width: auto; padding: 3px 6px; }
.dt-sentinel { width: 1px; height: 1px; }

/* ---------- menu Colonnes ---------- */
.dt-pop-wrap { position: relative; }
.dt-pop { position: absolute; top: calc(100% + 6px); inset-inline-end: 0; z-index: 40; width: 290px; max-width: calc(100vw - 32px); padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.dt-pop-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.dt-pop-hint { margin-bottom: 6px; }
.dt-col-list { list-style: none; margin: 0; padding: 0; max-height: min(55vh, 420px); overflow-y: auto; }
.dt-col-item { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: var(--radius-sm); background: var(--surface); }
.dt-col-item:hover { background: var(--surface-2); }
.dt-col-item .check { display: flex; align-items: center; gap: 8px; flex: 1; cursor: pointer; font-size: 13px; }
.dt-grip { cursor: grab; color: var(--muted); letter-spacing: -3px; padding-inline: 2px 6px; user-select: none; font-weight: 700; }
.dt-ghost { opacity: .5; background: var(--brand-50); }

/* lecteurs d'écran uniquement */
.dt-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- mobile ---------- */
@media (max-width: 700px) {
  .dt-search { flex-basis: 100%; max-width: none; }
  .dt-spacer { display: none; }
  .dt-btn .dt-lbl { display: none; }
  .dt-pager { margin-inline-start: 0; }
  .dt-table td, .dt-table th { white-space: nowrap; }
}

/* ---------- impression (feuille construite à la demande, limitée au tableau) ---------- */
.dt-print-sheet { display: none; }
@media print {
  body.dt-printing { height: auto; background: var(--surface); }
  body.dt-printing > *:not(.dt-print-sheet) { display: none !important; }
  body.dt-printing .dt-print-sheet { display: block; font-size: 11px; color: var(--ink); }
  .dt-print-sheet h2 { margin-bottom: 4px; }
  .dt-print-meta { color: var(--muted); margin-bottom: 10px; }
  .dt-print-sheet .tbl th { position: static; }
  .dt-print-sheet thead { display: table-header-group; }
  .dt-print-sheet tr { break-inside: avoid; }
  .dt-print-sheet td, .dt-print-sheet th { padding: 4px 6px; }
  .dt-print-sheet .progress { display: none; }
  .dt-print-sheet .mono { white-space: nowrap; }
}
