/*
 * IMMGO — Charte : fenêtre modale, confirmation, menu ⋯, toast et étapes d'une opération longue
 * Auteur : Jacks Ngalangala
 */

/* ─── Fenêtre modale (élément <dialog>) ─── */
.modale {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  padding: 0;
  border: 0;
  border-radius: var(--r-tres-grand);
  background: var(--surface);
  color: var(--texte);
  box-shadow: var(--ombre-3);
  overflow: hidden;
}
.modale[open] {
  display: flex;
  flex-direction: column;
  animation: modale-entre 200ms var(--courbe);
}
.modale::backdrop {
  background: rgba(22, 22, 22, 0.55);
  backdrop-filter: blur(2px);
}
.modale-tete {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--e-4);
  padding: var(--e-6) var(--e-6) 0;
}
.modale-titre {
  font-size: var(--taille-titre-3);
  font-weight: var(--graisse-titre);
  line-height: 1.3;
}
.modale-corps {
  padding: var(--e-4) var(--e-6);
  overflow-y: auto;
  color: var(--texte-second);
}
.modale-pied {
  display: flex;
  justify-content: flex-end;
  gap: var(--e-3);
  padding: var(--e-4) var(--e-6) var(--e-6);
}
@keyframes modale-entre {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
}

/* Confirmation d'une action dangereuse */
.confirmation-icone {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: var(--e-2);
  border-radius: 50%;
  background: var(--danger-pale);
  color: var(--danger);
}
.confirmation-icone svg {
  width: 24px;
  height: 24px;
}
.confirmation-saisie {
  margin-top: var(--e-4);
}

/* Sur mobile, la fenêtre devient une feuille posée en bas */
@media (max-width: 599px) {
  .modale {
    width: 100vw;
    max-width: 100vw;
    margin: auto 0 0;
    border-radius: var(--r-tres-grand) var(--r-tres-grand) 0 0;
  }
  .modale-pied {
    flex-direction: column-reverse;
    padding-bottom: max(var(--e-6), env(safe-area-inset-bottom));
  }
  .modale-pied .btn {
    width: 100%;
  }
}

/* ─── Menu ⋯ ─── */
.menu {
  position: relative;
  display: inline-flex;
}
.menu-liste {
  position: fixed;
  top: var(--menu-haut, 0);
  right: var(--menu-droite, 0);
  z-index: 40;
  min-width: 220px;
  padding: var(--e-2);
  background: var(--surface);
  border: 1px solid var(--trait);
  border-radius: var(--r-moyen);
  box-shadow: var(--ombre-3);
  animation: menu-entre 140ms var(--courbe);
}
.menu-item {
  display: flex;
  align-items: center;
  gap: var(--e-3);
  width: 100%;
  min-height: 44px;
  padding: 0 var(--e-3);
  border: 0;
  border-radius: var(--r-petit);
  background: transparent;
  color: var(--texte);
  font-size: var(--taille-corps);
  text-align: left;
  white-space: nowrap;
}
.menu-item svg {
  flex: none;
  width: 20px;
  height: 20px;
  color: var(--texte-second);
}
.menu-item:hover,
.menu-item:focus-visible {
  background: var(--neutre-pale);
  box-shadow: none;
}
.menu-separateur {
  height: 1px;
  margin: var(--e-2) var(--e-1);
  background: var(--trait);
}
.menu-item-danger,
.menu-item-danger svg {
  color: var(--danger);
}
.menu-item-danger:hover,
.menu-item-danger:focus-visible {
  background: var(--danger-pale);
}
@keyframes menu-entre {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

/* ─── Toast ─── */
.toasts {
  position: fixed;
  left: 50%;
  bottom: var(--e-6);
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--e-2);
  transform: translateX(-50%);
  width: min(440px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--e-3);
  width: 100%;
  padding: var(--e-3) var(--e-4);
  border-radius: var(--r-moyen);
  background: var(--nuit);
  color: var(--nuit-texte);
  box-shadow: var(--ombre-3);
  pointer-events: auto;
  animation: toast-entre 220ms var(--courbe);
}
.toast-icone {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
}
.toast-icone svg {
  width: 16px;
  height: 16px;
}
.toast-texte {
  flex: 1;
}
.toast[data-sort='oui'] {
  animation: toast-sort 200ms var(--courbe) forwards;
}
@keyframes toast-entre {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}
@keyframes toast-sort {
  to {
    opacity: 0;
    transform: translateY(8px);
  }
}
@media (max-width: 599px) {
  .toasts {
    bottom: calc(var(--hauteur-onglets-mobile) + var(--e-3));
  }
}

/* ─── Étapes d'une opération longue ─── */
.operation {
  display: flex;
  flex-direction: column;
  gap: var(--e-5);
}
.operation-tete {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--e-3);
}
.operation-pourcentage {
  font-size: var(--taille-titre-2);
  font-weight: var(--graisse-titre);
  font-variant-numeric: tabular-nums;
  color: var(--or-texte);
}
.operation-etapes {
  display: flex;
  flex-direction: column;
  gap: var(--e-1);
}
.operation-etape {
  display: flex;
  align-items: center;
  gap: var(--e-3);
  min-height: 44px;
  color: var(--texte-faible);
}
.operation-texte {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
/* Raison d'un échec, sous l'étape (mode « continuer » : les autres étapes passent quand même) */
.operation-detail {
  font-size: var(--taille-petit);
  font-weight: var(--graisse-normale);
  color: var(--danger);
}
.operation-marque {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--trait-fort);
}
.operation-marque svg {
  width: 16px;
  height: 16px;
}
.operation-etape[data-etat='encours'] {
  color: var(--texte);
  font-weight: var(--graisse-forte);
}
.operation-etape[data-etat='encours'] .operation-marque {
  border-color: var(--or);
  border-right-color: transparent;
  animation: btn-tourne 0.8s linear infinite;
}
.operation-etape[data-etat='fait'] {
  color: var(--texte);
}
.operation-etape[data-etat='fait'] .operation-marque {
  border-color: var(--succes);
  background: var(--succes);
  color: var(--texte-sur-danger);
}
.operation-etape[data-etat='echec'] {
  color: var(--danger);
  font-weight: var(--graisse-forte);
}
.operation-etape[data-etat='echec'] .operation-marque {
  border-color: var(--danger);
  background: var(--danger);
  color: var(--texte-sur-danger);
}
