.mdm-popup {
  --mdm-popup-width: 640px;
  --mdm-popup-bg: #fff;
  --mdm-popup-color: #1a1a1a;
  --mdm-popup-overlay: #000;
  --mdm-popup-overlay-opacity: 0.6;
  padding: 0;
  border: 0;
  background: var(--mdm-popup-bg);
  color: var(--mdm-popup-color);
  box-sizing: border-box;
  overflow: auto;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.mdm-popup.is-open {
  opacity: 1;
  transform: none;
}

.mdm-popup__content {
  padding: 1.5rem 1.25rem 1.25rem;
}

.mdm-popup__content > :first-child { margin-top: 0; }
.mdm-popup__content > :last-child { margin-bottom: 0; }

.mdm-popup__close {
  position: absolute;
  top: 0.375rem;
  right: 0.375rem;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.mdm-popup__close:hover,
.mdm-popup__close:focus-visible {
  background: rgba(127, 127, 127, 0.2);
}

.mdm-popup__close:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* Modale centrée */
.mdm-popup--modale {
  width: calc(100% - 2rem);
  max-width: var(--mdm-popup-width);
  max-height: calc(100dvh - 2rem);
  margin: auto;
  border-radius: 12px;
  transform: translateY(1rem);
}

.mdm-popup--modale::backdrop {
  background: color-mix(in srgb, var(--mdm-popup-overlay) calc(var(--mdm-popup-overlay-opacity) * 100%), transparent);
}

/* Bandeaux */
.mdm-popup--bandeau-haut,
.mdm-popup--bandeau-bas {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
  max-width: none;
  margin: 0;
  z-index: 9999;
}

.mdm-popup--bandeau-haut {
  top: 0;
  bottom: auto;
  transform: translateY(-100%);
}

.mdm-popup--bandeau-bas {
  top: auto;
  bottom: 0;
  transform: translateY(100%);
}

.mdm-popup--bandeau-haut .mdm-popup__content,
.mdm-popup--bandeau-bas .mdm-popup__content {
  padding: 0.75rem 3rem 0.75rem 1rem;
}

/* Encart en bas à droite */
.mdm-popup--slide-in {
  position: fixed;
  top: auto;
  left: auto;
  right: 1.5rem;
  bottom: 1.5rem;
  width: calc(100% - 3rem);
  max-width: min(var(--mdm-popup-width), 420px);
  max-height: calc(100dvh - 3rem);
  margin: 0;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  transform: translateY(1.5rem);
  z-index: 9999;
}

/* Largeur ajustée au contenu (modale et encart) */
.mdm-popup--fit.mdm-popup--modale,
.mdm-popup--fit.mdm-popup--slide-in {
  width: fit-content;
  min-width: min(20rem, calc(100% - 2rem));
  max-width: calc(100% - 2rem);
}

.mdm-popup--fit.mdm-popup--slide-in {
  max-width: min(32rem, calc(100% - 3rem));
}

@media (prefers-reduced-motion: reduce) {
  .mdm-popup {
    transition: none;
    transform: none;
  }
}
