/* Popup Manager Pro - Structure uniquement */

/* Overlay principal */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75);
    z-index: 999999;
    display: none;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.popup-overlay.popup-show {
    display: flex;
}

/* Positions */
.popup-overlay.popup-position-center {
    justify-content: center;
    align-items: center;
}

.popup-overlay.popup-position-top {
    justify-content: center;
    align-items: flex-start;
    padding-top: 50px;
}

.popup-overlay.popup-position-bottom {
    justify-content: center;
    align-items: flex-end;
    padding-bottom: 50px;
}

.popup-overlay.popup-position-top-left {
    justify-content: flex-start;
    align-items: flex-start;
    padding: 50px 0 0 50px;
}

.popup-overlay.popup-position-top-right {
    justify-content: flex-end;
    align-items: flex-start;
    padding: 50px 50px 0 0;
}

.popup-overlay.popup-position-bottom-left {
    justify-content: flex-start;
    align-items: flex-end;
    padding: 0 0 50px 50px;
}

.popup-overlay.popup-position-bottom-right {
    justify-content: flex-end;
    align-items: flex-end;
    padding: 0 50px 50px 0;
}

/* Overlay désactivé : clics passent à travers, navigation possible */
.popup-overlay.popup-no-overlay {
    background-color: transparent !important;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    pointer-events: none;
}

.popup-overlay.popup-no-overlay .popup-container {
    pointer-events: auto;
}

/* Conteneur de la popup */
.popup-container {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    width: var(--popup-width, 600px);
    max-width: min(var(--popup-width, 600px), calc(100vw - 40px));
    max-height: 90vh;
    min-width: 0;
    box-sizing: border-box;
    flex: 0 1 auto;
    position: relative;
    overflow: hidden;
    transform: scale(0.8) translateY(50px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.popup-container.has-popup-icon,
.popup-container.popup-close-outside {
    overflow: visible;
}

.popup-container.popup-animate-in {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.popup-container.popup-animate-out {
    transform: scale(0.8) translateY(-50px);
    opacity: 0;
}

/* Icône sortante (à cheval sur le bord supérieur) */
.popup-icon {
    position: absolute;
    top: 0;
    z-index: 1001;
    width: 80px;
    height: 80px;
    pointer-events: none;
    line-height: 0;
}

.popup-icon-pos-center {
    left: 50%;
    transform: translate(-50%, -50%);
}

.popup-icon-pos-left {
    left: 28px;
    transform: translateY(-50%);
}

.popup-icon img,
.popup-icon .popup-icon-img {
    display: block;
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin: 0;
}

.popup-container.has-popup-icon .popup-content {
    padding-top: 28px;
}

/* Bouton de fermeture */
.popup-close {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 1002;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.popup-close svg {
    width: 20px;
    height: 20px;
    color: #666;
}

/* Croix à l'extérieur */
.popup-container.popup-close-outside .popup-close {
    top: -44px;
    right: -4px;
    background: rgba(255, 255, 255, 0.15);
}

.popup-container.popup-close-outside .popup-close svg {
    color: #ffffff;
}

.popup-container.popup-close-outside .popup-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Contenu : on laisse le thème gérer */
.popup-content {
    overflow-y: auto;
    max-height: 90vh;
    max-width: 100%;
    text-align: left;
    border-radius: inherit;
}

.popup-thumbnail img {
    width: 100%;
    height: auto;
    display: block;
}

.popup-title {
    padding: 30px 30px 10px;
}

.popup-title h2 {
    margin: 0;
}

.popup-container.has-custom-text .popup-title h2,
.popup-container.has-custom-text .popup-body {
    color: inherit;
}

/* NEW: Alignement du titre */
.popup-title-align-left { text-align: left; }
.popup-title-align-center { text-align: center; }
.popup-title-align-right { text-align: right; }

.popup-body {
    padding: 30px;
}

.popup-body img {
    max-width: 100%;
    height: auto;
}

/* Mode prévisualisation */
.popup-overlay[data-preview-mode="1"]::before {
    content: "PRÉVISUALISATION";
    position: fixed;
    top: 50px;
    right: 20px;
    background: #ff9800;
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 12px;
    z-index: 1000000;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    letter-spacing: 1px;
}

/* Responsive */
@media (max-width: 768px) {
    .popup-container {
        width: min(var(--popup-width, 600px), calc(100vw - 32px));
        max-width: calc(100vw - 32px);
    }
    .popup-title, .popup-body {
        padding-left: 20px;
        padding-right: 20px;
    }
    .popup-icon {
        width: 64px;
        height: 64px;
    }
    .popup-icon img,
    .popup-icon .popup-icon-img {
        width: 64px;
        height: 64px;
    }
    .popup-icon-pos-left {
        left: 16px;
    }
    .popup-container.popup-close-outside .popup-close {
        top: -40px;
        right: 0;
    }
    .popup-overlay.popup-position-top,
    .popup-overlay.popup-position-top-left,
    .popup-overlay.popup-position-top-right {
        padding-top: 16px;
    }
    .popup-overlay.popup-position-bottom,
    .popup-overlay.popup-position-bottom-left,
    .popup-overlay.popup-position-bottom-right {
        padding-bottom: 16px;
    }
    .popup-overlay.popup-position-top-left,
    .popup-overlay.popup-position-bottom-left {
        padding-left: 16px;
    }
    .popup-overlay.popup-position-top-right,
    .popup-overlay.popup-position-bottom-right {
        padding-right: 16px;
    }
}
