/* dashboard-widgets.css — Widgets compacts integres au dashboard principal.
 * Scope : #dashboardWidgetsZone. */

#dashboardWidgetsZone { margin-top: 8px; }
/* 14/05/2026 audit Boss : flex-wrap pour repartition adaptative selon nb widgets.
   - 1 widget : pleine largeur (pas de colonne vide a cote)
   - 2 widgets : 50/50
   - 3+ : 50/50 + le dernier impair en pleine largeur sous
   Sur < 1100px : tout en pleine largeur (mobile). */
#dashboardWidgetsZone .dw-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
#dashboardWidgetsZone .dw-grid > .dw-card {
  flex: 1 1 100%;
  min-width: 280px;
  margin-bottom: 0;
}
@media (min-width: 1100px) {
  #dashboardWidgetsZone .dw-grid > .dw-card {
    flex: 1 1 calc(50% - 5px);
  }
}
#dashboardWidgetsZone .dw-col { display: flex; flex-direction: column; gap: 10px; }

#dashboardWidgetsZone .dw-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
  box-sizing: border-box;
}
#dashboardWidgetsZone .dw-card-title {
  font-size: 12px; font-weight: 700; margin-bottom: 8px;
  letter-spacing: .02em; display: flex; align-items: center; gap: 4px;
}
#dashboardWidgetsZone .dw-item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12px;
  border-left: 2px solid transparent;
}
#dashboardWidgetsZone .dw-item:hover { background: rgba(255,255,255,.03); }
#dashboardWidgetsZone .dw-item + .dw-item {
  margin-top: 2px; border-top: 1px dashed rgba(255,255,255,.05);
}
#dashboardWidgetsZone .dw-item-title {
  font-size: 12px; font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  /* Audit mobile 23/05/2026 : fluide au lieu de 240px fixe */
  min-width: 0; flex: 1;
}
#dashboardWidgetsZone .dw-item-sub {
  font-size: 10px; color: var(--text3); margin-top: 2px;
}
#dashboardWidgetsZone .dw-item-meta {
  font-size: 10px; font-family: Consolas, monospace;
  color: var(--text2); white-space: nowrap;
  text-align: right;
  /* Audit mobile 23/05/2026 : empêche le badge "PRET a remettre" de déborder
     hors de la card. Mobile : passe sous le titre via flex-wrap. */
  flex-shrink: 0; max-width: 50%;
}
/* Mobile : passe le meta en bas (en-dessous du titre+sub) au lieu de à droite. */
@media (max-width: 480px) {
  #dashboardWidgetsZone .dw-item {
    flex-wrap: wrap;
  }
  #dashboardWidgetsZone .dw-item-meta {
    text-align: left; max-width: 100%; flex: 1 1 100%;
    padding-top: 2px;
  }
}

/* Planification horaire (Phase 2) */
.dash-horaire-drop {
  position: relative; padding: 6px 8px;
  border: 1px dashed rgba(255,255,255,.1);
  border-radius: 6px; margin: 3px 0;
  min-height: 40px;
  font-size: 11px; color: var(--text3);
}
.dash-horaire-drop[data-filled="1"] {
  background: rgba(34,197,94,.08);
  border-color: #22c55e;
}
.dash-horaire-drop.drag-over {
  background: rgba(59,130,246,.12);
  border-color: #3b82f6; border-style: solid;
}
.dash-horaire-drop.conflict {
  background: rgba(239,68,68,.12);
  border-color: #ef4444;
}
.dash-horaire-label {
  position: absolute; top: 4px; left: 8px;
  font-size: 10px; font-weight: 700; color: var(--text3);
  font-family: Consolas, monospace;
}
.dash-horaire-content { padding-left: 46px; font-size: 11px; color: var(--text2); }

/* Bouton "Planifier" sur cartes (Phase 3) */
.dash-planif-btn {
  min-height: 32px; padding: 4px 10px;
  border-radius: 6px; border: 1px solid rgba(59,130,246,.3);
  background: rgba(59,130,246,.1); color: #60a5fa;
  font-size: 11px; font-weight: 600; cursor: pointer;
}
.dash-planif-btn:hover { background: rgba(59,130,246,.2); }

/* Multi-selection (Phase 3) */
.dash-multi-toolbar {
  display: none; gap: 8px; align-items: center;
  padding: 8px 12px; margin-bottom: 10px;
  background: linear-gradient(135deg, rgba(59,130,246,.15), rgba(139,92,246,.1));
  border: 1px solid rgba(59,130,246,.3);
  border-radius: 8px;
}
.dash-multi-toolbar.open { display: flex; }
.dash-multi-checkbox {
  position: absolute; top: 8px; left: 8px;
  width: 22px; height: 22px;
  accent-color: #3b82f6; cursor: pointer;
  display: none; z-index: 2;
}
body.dash-multi-mode .dash-multi-checkbox { display: block; }

/* Popup planification (Phase 3 mobile fallback) */
#dash-planif-popup {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,.6);
  display: none; align-items: center; justify-content: center;
  padding: 16px;
}
#dash-planif-popup.open { display: flex; }
#dash-planif-popup .dp-box {
  background: #0f172a; color: #e2e8f0;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px;
  max-width: 420px; width: 100%;
  padding: 18px;
}
#dash-planif-popup .dp-title { font-size: 15px; font-weight: 700; margin-bottom: 12px; }
#dash-planif-popup .dp-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
#dash-planif-popup input, #dash-planif-popup select {
  width: 100%; min-height: 40px; padding: 8px 10px; font-size: 14px;
  border-radius: 8px; border: 1px solid rgba(255,255,255,.1);
  background: rgba(15,23,42,.7); color: #e2e8f0; box-sizing: border-box;
}
#dash-planif-popup .dp-actions { display: flex; gap: 8px; margin-top: 14px; }
#dash-planif-popup .dp-btn {
  flex: 1; min-height: 44px; padding: 10px; border-radius: 8px;
  font-weight: 600; cursor: pointer; border: 0;
}
#dash-planif-popup .dp-btn-primary { background: #3b82f6; color: #fff; }
#dash-planif-popup .dp-btn-ghost { background: transparent; color: #94a3b8; border: 1px solid rgba(255,255,255,.1); }

@media (max-width: 900px) {
  #dashboardWidgetsZone .dw-grid { grid-template-columns: 1fr; }
}

/* ─────────────────────────────────────────────────────────────────────────
   SKELETON LOADING (24/05/2026 audit UX)
   Affiche un placeholder shimmer pendant le fetch des widgets (avant -> zone
   vide pendant 1-3s sur 4G lente, puis pop brutal des cartes).
   ───────────────────────────────────────────────────────────────────────── */
#dashboardWidgetsZone .dw-skeleton-card { opacity: .85; }
#dashboardWidgetsZone .dw-skeleton {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#dashboardWidgetsZone .dw-skeleton__line {
  height: 12px;
  background: linear-gradient(90deg, var(--surface) 0%, var(--border) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: dw-skeleton-shimmer 1.5s infinite;
  border-radius: 4px;
}
#dashboardWidgetsZone .dw-skeleton__line--short { width: 60%; }
@keyframes dw-skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─────────────────────────────────────────────────────────────────────────
   PORTRAIT TABLETTE : widgets repliables en <details> (24/05/2026)
   But : reduire le scroll avant le calendrier sur tablette portrait.
   "Atelier en cours" reste ouvert par defaut (info la plus consultee).
   ───────────────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  #dashboardWidgetsZone details.dw-collapsible {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 8px;
    overflow: hidden;
  }
  #dashboardWidgetsZone details.dw-collapsible > summary {
    cursor: pointer;
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 700;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
  }
  #dashboardWidgetsZone details.dw-collapsible > summary::-webkit-details-marker { display: none; }
  #dashboardWidgetsZone details.dw-collapsible > summary::after {
    content: '\25BC'; /* down arrow */
    margin-left: auto;
    font-size: 10px;
    color: var(--text3);
    transition: transform .2s;
  }
  #dashboardWidgetsZone details.dw-collapsible[open] > summary::after { transform: rotate(180deg); }
  #dashboardWidgetsZone details.dw-collapsible .dw-collapsible-body { padding: 0 4px 8px; }
}
