/**
 * LDStarter Popup - Styles Frontend
 *
 * Les variables CSS sont injectées dynamiquement depuis la config PHP.
 * Voir: inc/frontend.php -> inject_css_variables()
 *
 * @package LDStarter
 * @subpackage Popup
 */

/* ==========================================================================
   Base
   ========================================================================== */

.ldstarter-popup {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.ldstarter-popup.is-visible {
    opacity: 1;
    visibility: visible;
}

/* Position (le conteneur plein ecran ancre la boite popup) */
.ldstarter-popup--pos-top-right {
    align-items: flex-start;
    justify-content: flex-end;
}
.ldstarter-popup--pos-bottom-right {
    align-items: flex-end;
    justify-content: flex-end;
}
/* En position coin, la boite ne prend pas toute la largeur */
.ldstarter-popup--pos-top-right .ldstarter-popup__container,
.ldstarter-popup--pos-bottom-right .ldstarter-popup__container {
    width: auto;
}

/* ==========================================================================
   Overlay
   ========================================================================== */

.ldstarter-popup__overlay {
    position: absolute;
    inset: 0;
    background-color: var(--ldstarter-popup-overlay, rgba(0, 0, 0, 0.6));
    cursor: pointer;
}

/* ==========================================================================
   Container
   ========================================================================== */

.ldstarter-popup__container {
    position: relative;
    width: 100%;
    max-width: var(--ldstarter-popup-max-width, 500px);
    max-height: 90vh;
    overflow-y: auto;
    background-color: var(--ldstarter-popup-bg, #FFFFFF);
    border-radius: var(--ldstarter-popup-radius, 16px);
    box-shadow: var(--ldstarter-popup-shadow, 0 25px 50px -12px rgba(0, 0, 0, 0.25));
}

/* Animations */
.ldstarter-popup[data-animation="fade-scale"] .ldstarter-popup__container {
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.ldstarter-popup[data-animation="fade-scale"].is-visible .ldstarter-popup__container {
    transform: scale(1);
}

.ldstarter-popup[data-animation="slide-up"] .ldstarter-popup__container {
    transform: translateY(30px);
    transition: transform 0.3s ease;
}

.ldstarter-popup[data-animation="slide-up"].is-visible .ldstarter-popup__container {
    transform: translateY(0);
}

.ldstarter-popup[data-animation="fade"] .ldstarter-popup__container {
    transition: none;
}

/* ==========================================================================
   Close Button
   ========================================================================== */

.ldstarter-popup__close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background-color: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    color: var(--ldstarter-popup-close-color, #6B7280);
    cursor: pointer;
    transition: color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}

.ldstarter-popup__close:hover {
    color: var(--ldstarter-popup-close-hover, #374151);
    background-color: #FFFFFF;
    transform: scale(1.1);
}

.ldstarter-popup__close:focus {
    outline: 2px solid var(--ldstarter-popup-primary, #00CCCC);
    outline-offset: 2px;
}

.ldstarter-popup__close svg {
    width: 20px;
    height: 20px;
}

/* ==========================================================================
   Image
   ========================================================================== */

.ldstarter-popup__image {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: var(--ldstarter-popup-radius, 16px) var(--ldstarter-popup-radius, 16px) 0 0;
}

.ldstarter-popup__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ==========================================================================
   Content
   ========================================================================== */

.ldstarter-popup__content {
    padding: var(--ldstarter-popup-padding, 2rem);
}

/* Si pas d'image, arrondir les coins du haut */
.ldstarter-popup__container:not(:has(.ldstarter-popup__image)) .ldstarter-popup__content {
    border-radius: var(--ldstarter-popup-radius, 16px);
}

/* ==========================================================================
   Title
   ========================================================================== */

.ldstarter-popup__title {
    margin: 0 0 1rem 0;
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--ldstarter-popup-text, #1F2937);
}

/* ==========================================================================
   Description
   ========================================================================== */

.ldstarter-popup__description {
    margin-bottom: 1.5rem;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--ldstarter-popup-text, #4B5563);
    opacity: 0.85;
}

.ldstarter-popup__description p {
    margin: 0 0 0.75rem 0;
}

.ldstarter-popup__description p:last-child {
    margin-bottom: 0;
}

.ldstarter-popup__description a {
    color: var(--ldstarter-popup-primary, #00CCCC);
    text-decoration: underline;
}

.ldstarter-popup__description a:hover {
    text-decoration: none;
}

/* ==========================================================================
   Custom Content (Template personnalisé)
   ========================================================================== */

.ldstarter-popup__custom-content {
    margin-top: 1rem;
    margin-bottom: 1rem;
}

/* Reset des styles pour les formulaires intégrés */
.ldstarter-popup__custom-content input[type="text"],
.ldstarter-popup__custom-content input[type="email"],
.ldstarter-popup__custom-content input[type="tel"],
.ldstarter-popup__custom-content textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 1px solid #D1D5DB;
    border-radius: 8px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ldstarter-popup__custom-content input[type="text"]:focus,
.ldstarter-popup__custom-content input[type="email"]:focus,
.ldstarter-popup__custom-content input[type="tel"]:focus,
.ldstarter-popup__custom-content textarea:focus {
    outline: none;
    border-color: var(--ldstarter-popup-primary, #00CCCC);
    box-shadow: 0 0 0 3px rgba(0, 204, 204, 0.1);
}

.ldstarter-popup__custom-content button[type="submit"],
.ldstarter-popup__custom-content input[type="submit"] {
    width: 100%;
    padding: 0.875rem 1.5rem;
    margin-top: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: #FFFFFF;
    background-color: var(--ldstarter-popup-primary, #00CCCC);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: filter 0.2s ease, transform 0.2s ease;
}

.ldstarter-popup__custom-content button[type="submit"]:hover,
.ldstarter-popup__custom-content input[type="submit"]:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
}

/* Styles spécifiques MailerLite - masquer les éléments inutiles */
.ldstarter-popup__custom-content .ml-form-embedContainer {
    width: 100% !important;
}

.ldstarter-popup__custom-content .ml-form-embedWrapper {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
}

.ldstarter-popup__custom-content .ml-form-embedBody {
    padding: 0 !important;
}

.ldstarter-popup__custom-content .ml-form-embedContent {
    display: none !important;
}

/* ==========================================================================
   CTA Button
   ========================================================================== */

.ldstarter-popup__cta {
    margin-top: 1.5rem;
}

.ldstarter-popup__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    color: var(--ldstarter-popup-btn-text, #FFFFFF);
    background-color: var(--ldstarter-popup-primary, #00CCCC);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.ldstarter-popup__button:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.ldstarter-popup__button:focus {
    outline: 2px solid var(--ldstarter-popup-primary, #00CCCC);
    outline-offset: 2px;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 640px) {
    .ldstarter-popup {
        padding: 0.5rem;
    }

    .ldstarter-popup__container {
        max-height: 95vh;
    }

    .ldstarter-popup__content {
        padding: 1.25rem;
    }

    .ldstarter-popup__title {
        font-size: 1.25rem;
    }

    .ldstarter-popup__description {
        font-size: 0.9375rem;
    }

    .ldstarter-popup__close {
        width: 32px;
        height: 32px;
    }

    .ldstarter-popup__close svg {
        width: 18px;
        height: 18px;
    }
}

/* ==========================================================================
   Accessibility - Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .ldstarter-popup,
    .ldstarter-popup__container,
    .ldstarter-popup__close,
    .ldstarter-popup__button {
        transition: none;
    }
}

/* ==========================================================================
   Body Lock (when popup is open)
   ========================================================================== */

body.ldstarter-popup-open {
    overflow: hidden;
}
