/**
 * Styles pour le système de popups publicitaires
 */

/* ========================================
   OVERLAY PRINCIPAL
   ======================================== */
.popup-ad-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.popup-ad-overlay.show {
    opacity: 1;
}

/* ========================================
   CONTENEUR DU POPUP
   ======================================== */
.popup-ad-container {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    position: relative;
    transform: scale(0.8);
    transition: transform 0.3s ease-in-out;
    z-index: 1;
    display: flex;
    flex-direction: column;
}

.popup-ad-overlay.show .popup-ad-container {
    transform: scale(1);
}

/* ========================================
   EN-TÊTE DU POPUP
   ======================================== */
.popup-ad-header {
    position: relative;
    padding: 15px 20px 0;
    text-align: right;
    z-index: 35;
}

.popup-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: relative;
    z-index: 40;
}

.popup-close-btn:hover {
    background: #f0f0f0;
    color: #333;
}

.popup-close-btn:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* ========================================
   CONTENU DU POPUP
   ======================================== */
.popup-ad-content {
    padding: 0 20px 20px;
    position: relative;
    z-index: 1;
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.popup-ad-link {
    display: block;
    text-decoration: none;
    transition: transform 0.2s ease;
}

.popup-ad-link:hover {
    transform: scale(1.02);
}

.popup-ad-image {
    width: 100%;
    max-height: 300px;
    height: auto;
    border-radius: 8px;
    display: block;
    position: relative;
    z-index: 1;
    object-fit: cover;
    flex-shrink: 0;
    overflow: hidden;
}

/* ========================================
   SECTION NEWSLETTER
   ======================================== */
.popup-newsletter-section {
    padding: 20px;
    border-top: 1px solid #eee;
    background: #f8f9fa;
    border-radius: 0 0 12px 12px;
    position: relative;
    z-index: 10;
    flex-shrink: 0;
    min-height: 200px;
    overflow-y: auto;
}

.popup-newsletter-section h3 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

.popup-newsletter-section p {
    margin: 0 0 15px 0;
    color: #666;
    font-size: 14px;
    line-height: 1.5;
}

/* ========================================
   FORMULAIRE NEWSLETTER
   ======================================== */
.popup-newsletter-form {
    margin-top: 15px;
    position: relative;
    z-index: 15;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
}

.popup-newsletter-form .form-group {
    margin-bottom: 15px;
}

.popup-newsletter-form .form-control {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
    position: relative;
    z-index: 20;
    background: white;
}

.popup-newsletter-form .form-control:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.popup-newsletter-form .btn {
    width: 100%;
    padding: 12px 20px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
    position: relative;
    z-index: 20;
    margin-top: 10px;
}

.popup-newsletter-form .btn:hover {
    background: #0056b3;
}

.popup-newsletter-form .btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

/* ========================================
   MESSAGES DE SUCCÈS/ERREUR
   ======================================== */
.newsletter-success,
.newsletter-error {
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
    text-align: center;
    position: relative;
    z-index: 25;
}

.newsletter-success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
}

.newsletter-error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
}

.newsletter-success p,
.newsletter-error p {
    margin: 0;
    font-weight: 500;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */
@media (max-width: 768px) {
    .popup-ad-container {
        width: 95%;
        max-width: none;
        margin: 20px;
        max-height: 85vh;
    }

    .popup-ad-header {
        padding: 10px 15px 0;
    }

    .popup-ad-content {
        padding: 0 15px 15px;
    }

    .popup-ad-image {
        max-height: 200px;
    }

    .popup-newsletter-section {
        padding: 15px;
        min-height: 180px;
    }

    .popup-newsletter-form .form-control {
        padding: 10px 12px;
        font-size: 16px; /* Éviter le zoom sur iOS */
    }

    .popup-newsletter-form .btn {
        padding: 12px 15px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .popup-ad-container {
        width: 98%;
        margin: 10px;
        max-height: 80vh;
    }

    .popup-ad-header {
        padding: 8px 12px 0;
    }

    .popup-ad-content {
        padding: 0 12px 12px;
    }

    .popup-ad-image {
        max-height: 150px;
    }

    .popup-newsletter-section {
        padding: 12px;
        min-height: 160px;
    }

    .popup-newsletter-section h3 {
        font-size: 16px;
    }

    .popup-newsletter-section p {
        font-size: 13px;
    }

    .popup-newsletter-form .form-control {
        font-size: 16px;
    }

    .popup-newsletter-form .btn {
        font-size: 16px;
    }
}

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes popupFadeIn {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes popupFadeOut {
    from {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    to {
        opacity: 0;
        transform: scale(0.8) translateY(-20px);
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========================================
   ÉTATS DE CHARGEMENT
   ======================================== */
.popup-ad-container.loading {
    pointer-events: none;
}

.popup-ad-container.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ========================================
   ACCESSIBILITÉ
   ======================================== */
.popup-ad-overlay:focus {
    outline: none;
}

/* ========================================
   MODE SOMBRE
   ======================================== */
@media (prefers-color-scheme: dark) {
    .popup-ad-container {
        background: #2d3748;
        color: #e2e8f0;
    }

    .popup-newsletter-section {
        background: #1a202c;
        border-top-color: #4a5568;
    }

    .popup-newsletter-form {
        background: #1a202c;
    }

    .popup-newsletter-form .form-control {
        background: #4a5568;
        border-color: #718096;
        color: #e2e8f0;
    }

    .popup-newsletter-form .form-control::placeholder {
        color: #a0aec0;
    }

    .popup-close-btn {
        color: #a0aec0;
    }

    .popup-close-btn:hover {
        background: #4a5568;
        color: #e2e8f0;
    }
}
