/**
 * 🌐 EMOCARD - External Link Popup System
 * Système de popup iframe pour liens externes selon l'identité EMOCARD
 * Design: Couleurs cuivre (#aa7b4c), border-radius 32px, fonts Outfit/Montserrat
 * Version: 2.0.0 - EMOCARD Branded
 */

/* ====== MODAL OVERLAY ====== */
.external-link-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(170, 123, 76, 0.15); /* Cuivre transparent */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 20px;
}

/* État visible */
.external-link-modal.visible {
    opacity: 1;
    visibility: visible;
}

/* ====== CONTENU MODAL ====== */
.external-link-content {
    background: #ffffff;
    border-radius: 32px; /* EMOCARD border-radius standard */
    width: 90vw;
    max-width: 1200px;
    height: 85vh;
    max-height: 800px;
    box-shadow: 
        0 32px 64px rgba(170, 123, 76, 0.25),
        0 0 0 2px rgba(170, 123, 76, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    transform: scale(0.92) translateY(40px);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(170, 123, 76, 0.12);
}

.external-link-modal.visible .external-link-content {
    transform: scale(1) translateY(0);
}

/* ====== HEADER MODAL ====== */
.external-link-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 28px;
    border-bottom: 2px solid rgba(170, 123, 76, 0.15);
    background: linear-gradient(135deg, #faf9f7 0%, #f5f2ef 100%);
    border-radius: 32px 32px 0 0;
    position: relative;
}

.external-link-header::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(170, 123, 76, 0.05) 0%, transparent 100%);
    border-radius: 32px 32px 0 0;
    pointer-events: none;
}

.external-link-title {
    font-family: 'Outfit', sans-serif;
    font-size: 20px;
    font-weight: 700;
    color: #aa7b4c; /* Couleur cuivre EMOCARD */
    margin: 0;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 20px;
    position: relative;
    z-index: 1;
}

.external-link-url {
    font-family: 'Montserrat', sans-serif;
    font-size: 13px;
    color: #8b6937; /* Cuivre plus foncé */
    font-weight: 500;
    position: relative;
    z-index: 1;
}

/* ====== BOUTONS ACTION ====== */
.external-link-actions {
    display: flex;
    gap: 16px;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.external-link-btn {
    padding: 12px 20px;
    border: 2px solid transparent;
    border-radius: 32px; /* EMOCARD border-radius */
    font-family: 'Outfit', sans-serif;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
    text-decoration: none;
    min-width: 140px;
    justify-content: center;
}

.external-link-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(170, 123, 76, 0.25);
}

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

/* Bouton ouvrir dans nouvel onglet - Style EMOCARD premium */
.btn-open-tab {
    background: linear-gradient(135deg, #aa7b4c 0%, #c49366 100%);
    color: #ffffff;
    border-color: #aa7b4c;
    box-shadow: 0 4px 16px rgba(170, 123, 76, 0.3);
}

.btn-open-tab:hover {
    background: linear-gradient(135deg, #c49366 0%, #aa7b4c 100%);
    border-color: #c49366;
    box-shadow: 0 8px 24px rgba(170, 123, 76, 0.4);
}

.btn-open-tab::before {
    content: '🚀'; /* Pictogramme fusée pour "ouvrir" */
    font-size: 16px;
    margin-right: 4px;
}

/* Bouton fermer - Style EMOCARD subtil */
.btn-close {
    background: transparent;
    color: #aa7b4c;
    border-color: rgba(170, 123, 76, 0.3);
}

.btn-close:hover {
    background: rgba(170, 123, 76, 0.1);
    border-color: #aa7b4c;
    color: #8b6937;
}

.btn-close::before {
    content: '✨'; /* Pictogramme étoile pour "rester ici" */
    font-size: 16px;
    margin-right: 4px;
}

/* ====== IFRAME CONTAINER ====== */
.external-link-iframe-container {
    flex: 1;
    position: relative;
    background: #fefefe;
    border-radius: 0 0 32px 32px; /* EMOCARD border-radius */
    overflow: hidden;
}

.external-link-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: #fefefe;
}

/* ====== ÉTAT DE CHARGEMENT ====== */
.external-link-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #faf9f7 0%, #f5f2ef 100%);
    z-index: 10;
}

.external-link-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(170, 123, 76, 0.15);
    border-top: 4px solid #aa7b4c;
    border-radius: 50%;
    animation: emocard-spin 1.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    margin-bottom: 20px;
    box-shadow: 0 4px 16px rgba(170, 123, 76, 0.15);
}

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

.external-link-loading-text {
    font-family: 'Outfit', sans-serif;
    color: #aa7b4c;
    font-size: 16px;
    font-weight: 500;
}

/* ====== FALLBACK CORS ====== */
.external-link-cors-fallback {
    padding: 48px;
    text-align: center;
    background: linear-gradient(135deg, #faf9f7 0%, #f5f2ef 100%);
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 0 0 32px 32px;
}

.cors-icon {
    font-size: 64px;
    margin-bottom: 24px;
    filter: sepia(1) hue-rotate(25deg) saturate(1.2);
}

.cors-title {
    font-family: 'Outfit', sans-serif;
    font-size: 28px;
    font-weight: 700;
    color: #aa7b4c;
    margin-bottom: 16px;
}

.cors-message {
    font-family: 'Montserrat', sans-serif;
    color: #666;
    margin-bottom: 24px;
    line-height: 1.5;
}

.cors-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

/* ====== RESPONSIVE ====== */
@media (max-width: 768px) {
    .external-link-modal {
        padding: 10px;
    }
    
    .external-link-content {
        width: 95vw;
        height: 90vh;
        border-radius: 12px;
    }
    
    .external-link-header {
        padding: 16px 20px;
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
    
    .external-link-title {
        padding-right: 0;
        text-align: center;
    }
    
    .external-link-actions {
        justify-content: center;
    }
    
    .external-link-btn {
        padding: 10px 16px;
        font-size: 16px; /* Plus gros pour mobile */
    }
}

@media (max-width: 480px) {
    .external-link-content {
        width: 98vw;
        height: 95vh;
        border-radius: 8px;
    }
    
    .external-link-header {
        padding: 12px 16px;
    }
    
    .external-link-title {
        font-size: 16px;
    }
    
    .cors-title {
        font-size: 20px;
    }
    
    .cors-actions {
        flex-direction: column;
        width: 100%;
    }
    
    .external-link-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ====== ANIMATIONS AVANCÉES ====== */
@keyframes modalFadeIn {
    from {
        opacity: 0;
        backdrop-filter: blur(0px);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(8px);
    }
}

@keyframes contentSlideUp {
    from {
        transform: scale(0.9) translateY(40px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.external-link-modal.visible {
    animation: modalFadeIn 0.3s ease-out;
}

.external-link-modal.visible .external-link-content {
    animation: contentSlideUp 0.3s ease-out;
}