/* ===== RÉ-ORGANISATION : un bassin, des tuiles ==============================
   Les colonnes côte à côte imposaient un défilement horizontal — pénible en
   temps ordinaire, impraticable en tenant une carte. La disposition retenue
   sépare les rôles : à gauche la source, qui défile verticalement ; à droite
   toutes les destinations, qui tiennent à l'écran quel que soit leur nombre.

   Le geste doit se deviner. Trois choses y concourent : la carte a une poignée
   et un curseur de préhension, donc elle s'attrape ; la tuile survolée s'allume
   en indigo, donc elle accueille ; la tuile qui vient de recevoir tressaille,
   donc quelque chose est arrivé — c'est ce qui remplace le fait de voir la
   carte atterrir, puisqu'elle rejoint un groupe masqué.
   ========================================================================= */

.reorg-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

/* La consigne, en une phrase, qui suit ce qu'on fait. C'est la seule aide de
   l'écran. */
.reorg-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 13.5px;
  color: var(--gray-600);
}
.reorg-hint .lucide { width: 16px; height: 16px; color: var(--accent); }
.reorg.is-picking .reorg-hint { color: var(--accent); font-weight: var(--weight-medium); }
.focus-toggle { margin-left: auto; }

.reorg-split {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: var(--space-4);
  align-items: start;
}

/* ===== Le bassin ===== */

.reorg-pool {
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg, 14px);
  padding: var(--space-3);
  /* Il tient dans la hauteur de la fenêtre et défile en lui-même : c'est le
     seul défilement de l'écran, et il est vertical. */
  max-height: calc(100vh - 260px);
  min-height: 320px;
}

.reorg-pool__head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 0 4px var(--space-2);
}
.reorg-pool__title {
  flex: 1;
  font-size: 14px;
  font-weight: var(--weight-semibold);
  color: var(--gray-700);
}
.reorg-pool__count {
  font-size: 11.5px;
  font-weight: var(--weight-semibold);
  color: var(--gray-500);
  background: var(--gray-100);
  border-radius: var(--radius-full);
  padding: 2px 8px;
}

.reorg-pool__scroller {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  margin-top: var(--space-2);
  scroll-behavior: auto;
}
.reorg-pool__group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.reorg-pool__group[hidden] { display: none; }

.reorg-pool__empty {
  display: none;
  margin: 0;
  padding: var(--space-5) 0;
  text-align: center;
  font-size: 12.5px;
  color: var(--gray-400);
}
/* Un groupe sans aucune carte — équipe réellement vide. Les cartes masquées
   par la recherche comptent encore ici : c'est `reorg-pool__none` qui traite
   ce cas-là. */
.reorg-pool__group:not(:has(.reorg-card)) .reorg-pool__empty { display: block; }
.reorg-pool__none:not([hidden]) { display: block; }

.reorg-search { position: relative; margin-top: var(--space-2); }
.reorg-search__icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--gray-400);
  pointer-events: none;
}
.reorg-search__input {
  width: 100%;
  padding: 7px 12px 7px 32px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-full);
  font-size: 13px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.reorg-search__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--brand-indigo-tint);
}

/* ===== Les tuiles ===== */

/* `auto-fill` plutôt qu'un nombre fixe de colonnes : dix équipes tiennent en
   trois rangées sur un grand écran, en cinq sur un portable, et jamais rien ne
   sort du champ. */
.reorg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: var(--space-3);
}

.reorg-tile {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 104px;
  padding: var(--space-3);
  background: #FAFAFC;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg, 14px);
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease,
              box-shadow 0.16s ease, transform 0.16s ease;
}
.reorg-tile:hover {
  border-color: var(--gray-300);
  box-shadow: 0 2px 10px rgba(16, 20, 40, 0.06);
}
.reorg-tile:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
/* Le point de départ : liseré tireté, comme une case à vider. */
.reorg-tile--unassigned {
  border-style: dashed;
  background: #fff;
}

/* L'équipe ouverte dans le bassin. Discrète : c'est un repère, pas une
   sélection — la seule pilule indigo pleine de l'écran reste « Appliquer ». */
.reorg-tile.is-source {
  background: var(--brand-indigo-tint-2, #F4F5FF);
  border-color: var(--accent);
}
.reorg-tile.is-source .reorg-tile__name { color: var(--accent); }

.reorg-tile__head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.reorg-tile__name {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  font-weight: var(--weight-semibold);
  color: var(--gray-700);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reorg-tile__count {
  font-size: 11.5px;
  font-weight: var(--weight-semibold);
  color: var(--gray-500);
  background: var(--gray-100);
  border-radius: var(--radius-full);
  padding: 2px 8px;
}

/* Les visages se chevauchent : ils disent la composition de l'équipe sans
   prendre la place d'une liste. */
.reorg-tile__stack {
  display: flex;
  align-items: center;
  min-height: 28px;
}
.reorg-tile__stack .ds-avatar {
  width: 26px;
  height: 26px;
  font-size: 10px;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(16, 20, 40, 0.12);
}
.reorg-tile__stack .ds-avatar + .ds-avatar { margin-left: -9px; }
.reorg-tile__more {
  margin-left: 6px;
  font-size: 11.5px;
  font-weight: var(--weight-medium);
  color: var(--gray-500);
}

.reorg-tile__drop {
  display: none;
  font-size: 12px;
  color: var(--gray-400);
}
.reorg-tile.is-empty .reorg-tile__drop { display: block; }
.reorg-tile.is-empty .reorg-tile__stack { display: none; }

/* Accueil : pendant un glisser, ou quand une carte est sélectionnée au clic. */
.reorg-tile.is-over,
.reorg.is-picking .reorg-tile:hover {
  background: var(--brand-indigo-tint);
  border-color: var(--accent);
  border-style: solid;
  box-shadow: 0 0 0 3px rgba(86, 93, 246, 0.14);
  transform: translateY(-2px);
}

/* Toutes les destinations s'éclairent dès qu'on soulève quelqu'un : on voit du
   même coup où l'on peut aller. */
.reorg.is-dragging .reorg-tile { border-color: var(--gray-300); }

@keyframes reorgReceived {
  0%   { transform: none; }
  35%  { transform: scale(1.04); box-shadow: 0 0 0 4px var(--brand-indigo-tint); }
  100% { transform: none; }
}
.reorg-tile.just-received { animation: reorgReceived 0.42s ease; }

/* ===== Les cartes ===== */

.reorg-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md, 10px);
  cursor: grab;
  transition: box-shadow 0.16s ease, border-color 0.16s ease,
              transform 0.16s ease, opacity 0.16s ease;
}
.reorg-card:hover {
  border-color: var(--gray-300);
  box-shadow: 0 2px 8px rgba(16, 20, 40, 0.07);
  transform: translateY(-1px);
}
.reorg-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.reorg-card:active { cursor: grabbing; }

.reorg-card__body { flex: 1; min-width: 0; }
.reorg-card__name {
  display: block;
  font-size: 13.5px;
  font-weight: var(--weight-medium);
  color: var(--gray-700);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reorg-card__job {
  display: block;
  font-size: 11.5px;
  color: var(--gray-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reorg-card__grip {
  width: 14px;
  height: 14px;
  color: var(--gray-300);
  opacity: 0;
  transition: opacity 0.16s ease;
}
.reorg-card:hover .reorg-card__grip { opacity: 1; }

.reorg-card.is-dragging { opacity: 0.4; }
.reorg-card.is-picked {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--brand-indigo-tint);
}
/* Déplacée, pas encore appliquée. */
.reorg-card.is-moved {
  border-left: 3px solid var(--accent);
  background: linear-gradient(90deg, var(--brand-indigo-tint) 0%, #fff 42%);
}
/* La recherche masque les cartes hors résultat : `[hidden]` suffit, la
   feuille de base le traduit en `display: none`. */

/* ===== La barre de validation ===== */

.reorg-apply {
  position: sticky;
  bottom: var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-4);
  padding: 10px 14px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-full);
  box-shadow: 0 6px 24px rgba(16, 20, 40, 0.12);
  animation: reorgBarIn 0.2s ease;
}
@keyframes reorgBarIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.reorg-apply__count {
  flex: 1;
  font-size: 13.5px;
  font-weight: var(--weight-medium);
  color: var(--gray-700);
}

@media (max-width: 991.98px) {
  .reorg-split { grid-template-columns: 1fr; }
  .reorg-pool { max-height: 46vh; }
  .focus-toggle { display: none; }
}
