/* =========================================================================
   QUICK-WINS UX (audit 2026-05-05)
   - Skeletons reutilisables (table, list, card, text)
   - Chips de filtres actifs (Documents + Search)
   - Section "Aujourd'hui (X)" sidebar avec badge anime
   - Normalisation icones de header (.h-icon) + masquage emoji legacy en option
   - Polish boutons (espace icone+texte)
   ATTENTION : additif uniquement. .spinner historique reste fonctionnel
   pour ne pas casser les loaders dynamiques injectes par JS.
   ========================================================================= */

/* -------------------------------------------------------------------------
   1. SKELETONS — shimmer reutilisable
   ------------------------------------------------------------------------- */
@keyframes qw-shimmer {
  0%   { background-position: -480px 0; }
  100% { background-position: 480px 0; }
}

.qw-skeleton,
.qw-skeleton-row,
.qw-skeleton-line,
.qw-skeleton-circle {
  background: linear-gradient(
    90deg,
    rgba(148, 163, 184, 0.10) 0%,
    rgba(148, 163, 184, 0.22) 50%,
    rgba(148, 163, 184, 0.10) 100%
  );
  background-size: 960px 100%;
  animation: qw-shimmer 1.4s linear infinite;
  border-radius: 6px;
}
[data-theme="dark"] .qw-skeleton,
[data-theme="dark"] .qw-skeleton-row,
[data-theme="dark"] .qw-skeleton-line,
[data-theme="dark"] .qw-skeleton-circle {
  background: linear-gradient(
    90deg,
    rgba(148, 163, 184, 0.06) 0%,
    rgba(148, 163, 184, 0.14) 50%,
    rgba(148, 163, 184, 0.06) 100%
  );
  background-size: 960px 100%;
}

/* Skeleton TABLE — pour <table-wrap> et listes tabulaires */
.qw-skeleton-table {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px 0;
}
.qw-skeleton-table .qw-skeleton-row {
  height: 36px;
  border-radius: 6px;
}
.qw-skeleton-table .qw-skeleton-row:nth-child(odd)  { width: 100%; }
.qw-skeleton-table .qw-skeleton-row:nth-child(even) { width: 96%; opacity: .85; }

/* Skeleton LIST — pour listes verticales (recent-docs, dash-litiges...) */
.qw-skeleton-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 0;
}
.qw-skeleton-list .qw-skeleton-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}
.qw-skeleton-list .qw-skeleton-circle {
  width: 32px; height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
}
.qw-skeleton-list .qw-skeleton-stack {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.qw-skeleton-list .qw-skeleton-line { height: 10px; }
.qw-skeleton-list .qw-skeleton-line.short { width: 40%; height: 8px; }
.qw-skeleton-list .qw-skeleton-line.medium { width: 70%; }
.qw-skeleton-list .qw-skeleton-line.long { width: 90%; }

/* Skeleton CARD — pour KPI / chart placeholder */
.qw-skeleton-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 0;
}
.qw-skeleton-card .qw-skeleton-circle { width: 48px; height: 48px; }
.qw-skeleton-card .qw-skeleton-stack {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.qw-skeleton-card .qw-skeleton-line.value { height: 22px; width: 50%; }
.qw-skeleton-card .qw-skeleton-line.label { height: 10px; width: 75%; }

/* Skeleton TEXT — paragraphes / blocs */
.qw-skeleton-text {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 6px 0;
}
.qw-skeleton-text .qw-skeleton-line { height: 10px; }
.qw-skeleton-text .qw-skeleton-line.long  { width: 100%; }
.qw-skeleton-text .qw-skeleton-line.med   { width: 80%; }
.qw-skeleton-text .qw-skeleton-line.short { width: 55%; }

/* Pause animation si l'utilisateur prefere reduire les mouvements */
@media (prefers-reduced-motion: reduce) {
  .qw-skeleton, .qw-skeleton-row, .qw-skeleton-line, .qw-skeleton-circle {
    animation: none;
    background: rgba(148, 163, 184, 0.16);
  }
}

/* -------------------------------------------------------------------------
   2. CHIPS DE FILTRES ACTIFS
   ------------------------------------------------------------------------- */
.qw-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 8px 0 12px;
  min-height: 0;
  transition: min-height .15s ease;
}
.qw-chips:empty { display: none; }
.qw-chips-label {
  font-size: .72rem;
  color: var(--text-light);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-right: 4px;
}
.qw-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 10px;
  background: var(--primary-light);
  color: var(--primary-dark);
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: .76rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .15s, border-color .15s, transform .12s;
}
.qw-chip-key {
  font-weight: 500;
  opacity: .75;
  font-size: .7rem;
  margin-right: 2px;
}
.qw-chip-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: none;
  background: rgba(0,0,0,.06);
  color: inherit;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  flex-shrink: 0;
  transition: background .12s;
}
.qw-chip-close:hover {
  background: rgba(0,0,0,.18);
}
.qw-chip:hover {
  background: var(--primary);
  color: #fff;
}
.qw-chip:hover .qw-chip-close {
  background: rgba(255,255,255,.25);
}
.qw-chip-clear-all {
  background: transparent;
  color: var(--danger);
  border: 1px dashed var(--danger);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: .72rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.qw-chip-clear-all:hover {
  background: var(--danger);
  color: #fff;
}

[data-theme="dark"] .qw-chip-close { background: rgba(255,255,255,.10); }
[data-theme="dark"] .qw-chip-close:hover { background: rgba(255,255,255,.22); }

/* -------------------------------------------------------------------------
   3. SIDEBAR — Section "Aujourd'hui (X)"
   ------------------------------------------------------------------------- */
.qw-today-block {
  margin: 4px 12px 8px;
  padding: 12px 14px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.18), rgba(99, 102, 241, 0.18));
  border: 1px solid rgba(96, 165, 250, 0.25);
  cursor: pointer;
  transition: transform .15s, border-color .15s, background .15s;
  position: relative;
  overflow: hidden;
}
.qw-today-block:hover {
  transform: translateY(-1px);
  border-color: rgba(96, 165, 250, 0.55);
}
.qw-today-block::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    120deg,
    transparent 0%,
    rgba(255, 255, 255, 0.06) 50%,
    transparent 100%
  );
  transform: translateX(-100%);
  transition: transform .8s ease;
}
.qw-today-block:hover::before { transform: translateX(100%); }
.qw-today-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.qw-today-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .82rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: .2px;
}
.qw-today-title svg {
  width: 16px; height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}
.qw-today-badge {
  min-width: 24px;
  height: 22px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #1f1300;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .3px;
  box-shadow: 0 0 0 0 rgba(245, 158, 11, .55);
  animation: qw-today-pulse 2.2s ease-out infinite;
}
.qw-today-badge.is-zero {
  background: rgba(148, 163, 184, 0.35);
  color: rgba(255, 255, 255, .8);
  animation: none;
  box-shadow: none;
}
@keyframes qw-today-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(245, 158, 11, .55); }
  70%  { box-shadow: 0 0 0 10px rgba(245, 158, 11, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}
.qw-today-summary {
  margin-top: 6px;
  font-size: .72rem;
  color: rgba(226, 232, 240, .8);
  line-height: 1.35;
  min-height: 16px;
}
.qw-today-block.is-loading .qw-today-summary {
  color: rgba(226, 232, 240, .45);
  font-style: italic;
}
@media (prefers-reduced-motion: reduce) {
  .qw-today-badge { animation: none; }
  .qw-today-block::before { transition: none; }
}

/* Mise en avant Documents en sidebar (#1 de Principal) */
.nav-item[data-page="documents"].qw-pin-primary {
  font-weight: 600;
}

/* -------------------------------------------------------------------------
   4. ICONES DE HEADER (.h-icon) — uniformise les SVG inline dans <h2>
   ------------------------------------------------------------------------- */
.h-icon {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -3px;
  margin-right: 8px;
  flex-shrink: 0;
  display: inline-block;
}
.card-header h2 {
  display: inline-flex;
  align-items: center;
  gap: 0;
}
/* Boutons : si on injecte des SVG inline a cote du texte */
.btn .h-icon, .btn-icon .h-icon {
  width: 14px;
  height: 14px;
  margin-right: 6px;
  vertical-align: -2px;
}

/* -------------------------------------------------------------------------
   5. POLISH — petits ajustements visuels
   ------------------------------------------------------------------------- */
.filters { align-items: center; }
.filters input, .filters select { transition: border-color .15s, box-shadow .15s; }
.filters input:focus, .filters select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
  outline: none;
}
