/* ================================================================
   CustomPopup – styles front-office v1.3
   Popup 600 × 600, image centrée, fond image ou couleur
   ================================================================ */

/* ---- Overlay ---- */
#cp-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  opacity: 0;
  visibility: hidden;
  transition: opacity .65s cubic-bezier(.4,0,.2,1),
              visibility .65s cubic-bezier(.4,0,.2,1);
  will-change: opacity;
}

#cp-overlay.cp-visible {
  opacity: 1;
  visibility: visible;
}

/* ---- Modal ---- */
#cp-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 9999;

  transform: translate(-50%, -46%) scale(.97);
  opacity: 0;
  visibility: hidden;

  width: 600px;
  height: 600px;

  border-radius: 20px;
  box-shadow:
    0 2px  6px  rgba(0,0,0,.05),
    0 10px 28px rgba(0,0,0,.11),
    0 36px 88px rgba(0,0,0,.20);
  overflow: hidden;

  transition:
    transform  .70s cubic-bezier(.22,1,.36,1),
    opacity    .60s cubic-bezier(.4,0,.2,1),
    visibility .60s cubic-bezier(.4,0,.2,1);

  /* Layout : image produit à gauche, contenu à droite */
  display: flex;
  flex-direction: row;
  will-change: transform, opacity;

  /* Image de fond (optionnelle) – définie en inline style depuis PHP */
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
}

#cp-modal.cp-visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

/* ---- Voile sur le fond image (améliore la lisibilité du texte) ---- */
#cp-bg-veil {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  /* Opacité contrôlée via inline style */
}

/* ---- Image produit (colonne gauche) ---- */
.cp-image-wrap {
  width: 300px;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  overflow: hidden;

  /* Centrage parfait de l'image */
  display: flex;
  align-items: center;
  justify-content: center;

  opacity: 0;
  transition: opacity .85s ease .4s;
}

#cp-modal.cp-visible .cp-image-wrap {
  opacity: 1;
}

.cp-image-wrap img {
  /* Centré, occupe au max la colonne sans dépasser */
  width: 100%;
  height: 100%;
  object-fit: contain;      /* ← contain pour centrer sans recadrer */
  object-position: center;
  display: block;
  padding: 20px;            /* petit espace autour pour ne pas coller aux bords */
  box-sizing: border-box;
}

/* ---- Body (colonne droite) ---- */
.cp-body {
  flex: 1;
  padding: 44px 36px 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow-y: auto;
  position: relative;
  z-index: 1;

  opacity: 0;
  transform: translateY(14px);
  transition:
    opacity   .65s ease .28s,
    transform .65s cubic-bezier(.22,1,.36,1) .28s;
}

#cp-modal.cp-visible .cp-body {
  opacity: 1;
  transform: translateY(0);
}

.cp-body--no-img {
  padding-top: 60px;
}

/* Fond semi-transparent derrière le texte quand il y a une image de fond */
.cp-body--has-bgimg {
  background: rgba(255,255,255,.82);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* ---- Titre ---- */
.cp-title {
  margin: 0 0 18px;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  color: #1a1a1a;
}

/* ---- Texte ---- */
.cp-text {
  font-size: 1rem;
  line-height: 1.7;
  color: #4a4a4a;
  margin: 0 0 28px;
}

.cp-text a {
  color: inherit;
  text-decoration: underline;
}

/* ---- Boutons ---- */
.cp-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: auto;
}

.cp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 30px;
  border-radius: 10px;
  font-size: .95rem;
  font-weight: 600;
  text-decoration: none !important;
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: .01em;
  transition: filter .22s ease, transform .18s ease, box-shadow .22s ease;
}

.cp-btn:hover {
  filter: brightness(1.07);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,.13);
}

.cp-btn:active { transform: translateY(0); }

.cp-btn--primary {
  background: #2563eb;
  color: #fff !important;
  box-shadow: 0 2px 10px rgba(37,99,235,.28);
}

.cp-btn--secondary {
  background: transparent;
  color: #555 !important;
  border: 1.5px solid #d1d5db;
}

.cp-btn--secondary:hover {
  border-color: #9ca3af;
  color: #222 !important;
}

/* ---- Bouton fermer ---- */
#cp-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border: none;
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #444;
  padding: 0;
  z-index: 10;
  box-shadow: 0 1px 6px rgba(0,0,0,.14);
  opacity: 0;
  transition:
    opacity    .45s ease .8s,
    background .2s  ease,
    color      .2s  ease,
    transform  .25s ease;
}

#cp-modal.cp-visible #cp-close { opacity: 1; }

#cp-close:hover {
  background: #fff;
  color: #111;
  transform: rotate(90deg) scale(1.08);
}

#cp-close svg { width: 15px; height: 15px; }

/* ---- Responsive mobile ---- */
@media (max-width: 639px) {
  #cp-modal {
    width: 92vw;
    height: auto;
    max-height: 90vh;
    flex-direction: column;
    overflow-y: auto;
  }

  .cp-image-wrap {
    width: 100%;
    height: 220px;
    flex-shrink: 0;
  }

  .cp-image-wrap img {
    padding: 16px;
  }

  .cp-body {
    padding: 26px 24px 32px;
  }

  .cp-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .cp-btn { text-align: center; }
}
