/* =========================================================================
   SPRINT 2 UX (audit GED 2026-05-05) — additif, zero regression
   1. Vues Timeline + Kanban sur Documents
   2. Document Hero Card (overlay vue detail riche)
   3. Smart Folders dans la sidebar (alimentation IA)
   4. Score de completude Dossier 360 (gauge + checklist)
   ========================================================================= */

/* -------------------------------------------------------------------------
   COMMUN — boutons toggle additionnels
   ------------------------------------------------------------------------- */
.view-toggle .view-toggle-btn[data-mode="timeline"],
.view-toggle .view-toggle-btn[data-mode="kanban"] {
  /* Reuse du style existant view-toggle-btn deja en place */
}

/* -------------------------------------------------------------------------
   1. VUE TIMELINE
   ------------------------------------------------------------------------- */
.tl-wrap { display: flex; flex-direction: column; gap: 4px; padding: 4px 0; }
.tl-day {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
  position: relative;
}
.tl-day:first-child { border-top: none; }
.tl-day-head {
  position: sticky;
  top: 0;
  align-self: start;
  background: var(--bg);
  padding: 6px 10px;
  border-radius: 8px;
  text-align: center;
  z-index: 1;
}
.tl-day-num {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}
.tl-day-month {
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 2px;
}
.tl-day-weekday {
  font-size: .7rem;
  color: var(--text-light);
  margin-top: 4px;
  font-weight: 500;
}
.tl-day-count {
  font-size: .7rem;
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
  margin-top: 6px;
  display: inline-block;
}

.tl-items { display: flex; flex-direction: column; gap: 6px; }
.tl-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: transform .12s, border-color .12s, box-shadow .12s;
  position: relative;
}
.tl-item:hover {
  transform: translateX(2px);
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(37, 99, 235, .08);
}
.tl-item-time {
  font-size: .72rem;
  color: var(--text-light);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  width: 50px;
  flex-shrink: 0;
}
.tl-item-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.tl-item-body { flex: 1; min-width: 0; }
.tl-item-name {
  font-weight: 600;
  font-size: .88rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tl-item-meta {
  font-size: .72rem;
  color: var(--text-light);
  margin-top: 2px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.tl-item-cat {
  font-size: .7rem;
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 600;
  flex-shrink: 0;
}

[data-theme="dark"] .tl-day-head { background: var(--bg-card); }
[data-theme="dark"] .tl-item-icon { background: rgba(255,255,255,.04); }

/* -------------------------------------------------------------------------
   2. VUE KANBAN
   ------------------------------------------------------------------------- */
.kb-wrap {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding: 8px 4px 16px;
  align-items: flex-start;
}
.kb-col {
  flex: 0 0 280px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100vh - 280px);
  min-height: 200px;
}
.kb-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px 8px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 4px;
}
.kb-col-title {
  font-size: .82rem;
  font-weight: 700;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.kb-col-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--primary);
}
.kb-col-count {
  font-size: .72rem;
  background: var(--bg-card);
  color: var(--text-light);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
  border: 1px solid var(--border);
}
.kb-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 60px;
  padding: 2px;
}
.kb-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: grab;
  transition: transform .12s, border-color .12s, box-shadow .12s;
  font-size: .82rem;
  position: relative;
}
.kb-card:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(37, 99, 235, .12);
}
.kb-card:active { cursor: grabbing; }
.kb-card.is-dragging { opacity: .4; transform: scale(.96); }
.kb-card-name {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.3;
}
.kb-card-meta {
  font-size: .7rem;
  color: var(--text-light);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.kb-list.is-drag-over {
  background: var(--primary-light);
  outline: 2px dashed var(--primary);
  outline-offset: -2px;
  border-radius: 6px;
}

/* -------------------------------------------------------------------------
   3. DOCUMENT HERO CARD (overlay vue detail riche)
   ------------------------------------------------------------------------- */
.dhc-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: dhc-fade-in .2s ease-out;
}
@keyframes dhc-fade-in { from { opacity: 0; } to { opacity: 1; } }
.dhc-card {
  background: var(--bg-card);
  border-radius: 16px;
  width: 100%;
  max-width: 1100px;
  max-height: calc(100vh - 48px);
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(15, 23, 42, .4);
  animation: dhc-slide-in .25s ease-out;
}
@keyframes dhc-slide-in { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.dhc-preview {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  min-height: 360px;
}
.dhc-preview img {
  max-width: 100%;
  max-height: 60vh;
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
}
.dhc-preview-fallback {
  font-size: 8rem;
  opacity: .35;
  color: #fff;
}
.dhc-preview-actions {
  margin-top: 16px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.dhc-preview-btn {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .25);
  background: rgba(255, 255, 255, .12);
  color: #fff;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s;
}
.dhc-preview-btn:hover { background: rgba(255, 255, 255, .22); }
.dhc-preview-btn.primary { background: #fff; color: #0f172a; border-color: #fff; }
.dhc-preview-btn.primary:hover { background: var(--accent); border-color: var(--accent); color: #1f1300; }

.dhc-side {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.dhc-side-head {
  padding: 18px 24px 10px;
  border-bottom: 1px solid var(--border);
}
.dhc-breadcrumbs {
  display: flex;
  gap: 6px;
  font-size: .72rem;
  color: var(--text-light);
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.dhc-breadcrumbs span { white-space: nowrap; }
.dhc-breadcrumbs span:not(:last-child)::after {
  content: '›';
  margin-left: 6px;
  color: var(--border);
}
.dhc-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  word-break: break-word;
  margin: 0 0 8px;
}
.dhc-meta-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.dhc-meta-chip {
  font-size: .72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary-dark);
}
.dhc-meta-chip.warn { background: var(--warning-light); color: #92400e; }
.dhc-meta-chip.muted { background: var(--bg); color: var(--text-light); border: 1px solid var(--border); }

.dhc-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.dhc-tab {
  flex: 1;
  padding: 10px 12px;
  text-align: center;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  border: none;
  background: transparent;
  border-bottom: 2px solid transparent;
  transition: color .12s, border-color .12s, background .12s;
}
.dhc-tab:hover { color: var(--text); background: var(--bg-card); }
.dhc-tab.is-active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: var(--bg-card);
}

.dhc-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
}
.dhc-section { margin-bottom: 16px; }
.dhc-section-title {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-light);
  margin-bottom: 8px;
}
.dhc-prop {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
  padding: 5px 0;
  font-size: .82rem;
  border-bottom: 1px dashed var(--border);
}
.dhc-prop:last-child { border-bottom: none; }
.dhc-prop-key { color: var(--text-light); font-weight: 500; }
.dhc-prop-val { color: var(--text); font-weight: 500; word-break: break-word; }

.dhc-summary {
  background: var(--bg);
  border-left: 3px solid var(--primary);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: .82rem;
  line-height: 1.5;
  color: var(--text);
}

.dhc-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.dhc-tag {
  font-size: .7rem;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--info-light);
  color: var(--info);
  font-weight: 500;
}

.dhc-related-list { display: flex; flex-direction: column; gap: 4px; }
.dhc-related-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--bg);
  border-radius: 6px;
  font-size: .8rem;
  cursor: pointer;
  transition: background .12s;
}
.dhc-related-item:hover { background: var(--primary-light); color: var(--primary-dark); }
.dhc-related-icon { font-size: 1rem; }

.dhc-foot {
  padding: 12px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  background: var(--bg);
  flex-wrap: wrap;
}
.dhc-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, .2);
  color: #fff;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .12s;
}
.dhc-close:hover { background: rgba(255, 255, 255, .35); }

@media (max-width: 920px) {
  .dhc-card { grid-template-columns: 1fr; max-height: calc(100vh - 48px); }
  .dhc-preview { min-height: 240px; }
  .dhc-preview img { max-height: 220px; }
}

[data-theme="dark"] .dhc-related-item { background: rgba(255,255,255,.04); }
[data-theme="dark"] .dhc-related-item:hover { background: rgba(96, 165, 250, .15); color: #93c5fd; }

/* -------------------------------------------------------------------------
   4. SMART FOLDERS (sidebar)
   ------------------------------------------------------------------------- */
.sf-section {
  margin-top: 12px;
  padding: 0 12px;
  /* Audit GED 2026-05-06 : separateur subtil pour delimiter la section */
  border-top: 1px solid rgba(255, 255, 255, .08);
  padding-top: 8px;
}
.sf-title {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  /* Audit GED 2026-05-06 : passe de .35 a .72 pour respecter WCAG AA (4.5:1)
     sur fond sidebar #0f172a. Le titre etait quasi-invisible (3:1). */
  color: rgba(255, 255, 255, .72);
  padding: 8px 4px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* Audit GED 2026-05-09 : titre cliquable pour replier/deplier la liste
     (fix petit ecran : sans collapse, le bloc Smart Folders pousse le menu
     nav hors de la zone visible). */
  cursor: pointer;
  user-select: none;
  border-radius: 6px;
  transition: background .15s, color .15s;
}
.sf-title:hover {
  background: rgba(255, 255, 255, .06);
  color: rgba(255, 255, 255, .92);
}
.sf-title:focus-visible {
  outline: 2px solid #60a5fa;
  outline-offset: 2px;
}
.sf-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s ease;
  /* Position fermee : chevron pointe vers le bas (oriente "click pour deplier") */
  transform: rotate(-90deg);
  color: rgba(255, 255, 255, .55);
}
.sf-title-open .sf-chevron {
  /* Position ouverte : chevron pointe vers le haut (oriente "click pour replier") */
  transform: rotate(0deg);
  color: rgba(255, 255, 255, .85);
}
@media (prefers-reduced-motion: reduce) {
  .sf-chevron { transition: none; }
}
/* La liste est masquee via l'attribut HTML `hidden` quand replie.
   Aucune regle CSS necessaire en mode replie : `hidden` = display:none.
   Quand depliee, la liste reprend son display:flex defini en .sf-list. */
.sf-list[hidden] { display: none; }
.sf-list { display: flex; flex-direction: column; gap: 2px; }
.sf-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: .82rem;
  font-weight: 500;
  /* Audit GED 2026-05-06 : forcer une couleur lisible (avant : var(--text-sidebar)
     qui peut etre trop sombre selon le theme). 90% blanc = 11:1 contraste. */
  color: rgba(255, 255, 255, .92);
  cursor: pointer;
  transition: background .15s, color .15s, transform .12s, border-color .15s;
  border: 1px solid transparent;
}
.sf-item:hover {
  background: rgba(255, 255, 255, .1);
  color: #fff;
  border-color: rgba(255, 255, 255, .14);
  transform: translateX(1px);
}
.sf-item-icon {
  width: 24px; height: 24px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .82rem;
  font-weight: 700;
  flex-shrink: 0;
}
/* Audit GED 2026-05-06 : opacite icon background 22% -> 32%, color +4% pour
   distinction nette des severites. Tous AA contraste sur fond bleu marine. */
.sf-item-icon.danger  { background: rgba(248, 113, 113, .32); color: #fecaca; }
.sf-item-icon.warning { background: rgba(251, 191, 36, .32);  color: #fde68a; }
.sf-item-icon.info    { background: rgba(96, 165, 250, .32);  color: #bfdbfe; }
.sf-item-icon.success { background: rgba(74, 222, 128, .32);  color: #bbf7d0; }
.sf-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: inherit;
}
.sf-item-count {
  font-size: .72rem;
  /* Audit GED 2026-05-06 : badge trop transparent avant (.08 fond + .82 texte).
     On passe a .18 fond + .98 texte pour qu'il soit lisible meme a 0. */
  background: rgba(255, 255, 255, .18);
  color: rgba(255, 255, 255, .98);
  padding: 2px 9px;
  border-radius: 999px;
  font-weight: 700;
  min-width: 24px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, .1);
}
/* Compteur a 0 : visuellement plus discret (pas d'urgence) mais reste lisible */
.sf-item-count[data-zero="true"] {
  background: rgba(255, 255, 255, .08);
  color: rgba(255, 255, 255, .55);
  border-color: transparent;
}
.sf-item:hover .sf-item-count {
  background: rgba(255, 255, 255, .25);
  color: #fff;
  border-color: rgba(255, 255, 255, .2);
}
.sf-item-loading {
  font-style: italic;
  color: rgba(255, 255, 255, .55);
  padding: 8px 10px;
  font-size: .76rem;
}

/* -------------------------------------------------------------------------
   5. COMPLETUDE GAUGE (Dossier 360)
   ------------------------------------------------------------------------- */
.cs-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 18px 22px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 22px;
  align-items: center;
}
.cs-gauge-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.cs-gauge {
  width: 130px; height: 130px;
  position: relative;
}
.cs-gauge svg {
  width: 100%; height: 100%;
  transform: rotate(-90deg);
}
.cs-gauge-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 10;
}
.cs-gauge-fg {
  fill: none;
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset .8s cubic-bezier(.4, .0, .2, 1);
}
.cs-gauge.is-low .cs-gauge-fg    { stroke: var(--danger); }
.cs-gauge.is-mid .cs-gauge-fg    { stroke: var(--warning); }
.cs-gauge.is-good .cs-gauge-fg   { stroke: var(--success); }
.cs-gauge-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-weight: 800;
}
.cs-gauge-pct { font-size: 1.7rem; line-height: 1; }
.cs-gauge-frac {
  font-size: .68rem;
  font-weight: 600;
  color: var(--text-light);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.cs-gauge-label {
  font-size: .7rem;
  color: var(--text-light);
  font-weight: 600;
  text-align: center;
  margin-top: -4px;
}
.cs-checklist {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 6px 14px;
}
.cs-check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: .82rem;
}
.cs-check-icon {
  width: 18px; height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
}
.cs-check-icon.is-ok { background: var(--success-light); color: #065f46; }
.cs-check-icon.is-ko { background: var(--bg); color: var(--text-light); border: 1px dashed var(--border); }
.cs-check-name { flex: 1; color: var(--text); }
.cs-check-item.is-ko .cs-check-name { color: var(--text-light); text-decoration: line-through; text-decoration-thickness: 1px; }
.cs-actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 720px) {
  .cs-card { grid-template-columns: 1fr; }
  .cs-gauge-wrap { margin: 0 auto; }
}

@media (prefers-reduced-motion: reduce) {
  .dhc-overlay, .dhc-card, .cs-gauge-fg { animation: none; transition: none; }
}
