/**
 * Styles frontend pour le plugin Carte Projets
 * Adapté aux couleurs et styles du thème Hello Elementor
 */

/* Container principal avec isolation */
.carte-projets-container {
    width: 100%;
    max-width: 100%;
    background-color: var(--e-global-color-secondary, #777158);
    padding: 60px 0;
    /* Isolation des styles pour éviter les conflits */
    isolation: isolate;
    contain: layout style;
    overflow-x: hidden;
    box-sizing: border-box;
}

.carte-projets-wrapper {
    width: 100%;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    align-items: start;
}

/* Section contenu (gauche) */
.carte-projets-content-section {
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Carte de projet */
.project-card {
    background-color: transparent;
    border-radius: 12px;
    padding: 0;
    margin-bottom: 30px;
}

/* Grille principale */
.project-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

/* Badges - Ligne 1, pleine largeur */
.grid-badges {
    grid-column: 1 / -1;
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.badge {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 20px;
    font-family: "Albert Sans", Sans-serif;
    font-size: 12px;
    font-weight: 400;
    text-transform: none;
    font-style: normal;
    text-decoration: none;
    fill: var(--e-global-color-text);
    color: var(--e-global-color-text);
    background-color: var(--e-global-color-af24b01);
    border: none;
    box-shadow: none;
    transition: all .3s;
}

.badge-integration {
    background-color: var(--e-global-color-af24b01);
    color: var(--e-global-color-text);
}

.badge-social {
    background-color: var(--e-global-color-af24b01);
    color: var(--e-global-color-text);
}

/* Titre - Ligne 2, colonne 1 */
.grid-titre {
    grid-column: 1;
    grid-row: 2;
    background-color: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 200px;
    box-sizing: border-box;
}

h3.project-title {
    font-family: inherit;
    font-size: 18px !important; /* Taille forcée pour la première carte */
    font-weight: inherit;
    line-height: 1.2;
    color: var(--e-global-color-text, #363635);
    margin: 0;
}

.project-location {
    font-size: 0.875em;
    color: var(--e-global-color-secondary, #777158);
}

.project-subtitle {
    font-family: inherit;
    font-size: 18px !important; /* Taille forcée pour la première carte */
    font-weight: inherit;
    color: var(--e-global-color-text, #363635);
    margin: 0;
    margin-top: auto;
    line-height: 1.6;
}

/* Image principale - Ligne 2, colonnes 2-3 */
.grid-image-principale {
    grid-column: 2 / -1;
    grid-row: 2;
    border-radius: 8px;
    overflow: hidden;
    height: 200px;
    background-color: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Image secondaire - Ligne 3, colonnes 1-2 */
.grid-image-secondaire {
    grid-column: 1 / 3;
    grid-row: 3;
    border-radius: 8px;
    overflow: hidden;
    height: 200px;
    background-color: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Image tertiaire - Ligne 3, colonne 3 */
.grid-image-tertiaire {
    grid-column: 3;
    grid-row: 3;
    border-radius: 8px;
    overflow: hidden;
    height: 200px;
    background-color: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Image décorative - Ligne 4, colonne 1 */
.grid-image-decorative {
    grid-column: 1;
    grid-row: 4;
    border-radius: 8px;
    overflow: hidden;
    height: 200px;
    background-color: var(--e-global-color-ba2e768, #EDEAE2);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Texte long - Ligne 4, colonnes 2-3 */
.grid-texte-long {
    grid-column: 2 / -1;
    grid-row: 4;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    color: var(--e-global-color-text, #363635);
    background-color: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    height: 200px;
    box-sizing: border-box;
    overflow-y: auto;
}

.grid-texte-long p {
    margin-bottom: 15px;
}

.grid-texte-long p:last-child {
    margin-bottom: 0;
}

/* Style de la barre de défilement pour le texte long */
.grid-texte-long::-webkit-scrollbar {
    width: 6px;
}

.grid-texte-long::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.grid-texte-long::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.grid-texte-long::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* Styles communs pour toutes les images */
.grid-image-principale img,
.grid-image-secondaire img,
.grid-image-tertiaire img,
.grid-image-decorative img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    min-height: 200px;
    display: block;
}

.grid-image-principale img:hover,
.grid-image-secondaire img:hover,
.grid-image-tertiaire img:hover,
.grid-image-decorative img:hover {
    transform: scale(1.05);
}

/* Style spécifique pour l'image décorative */
.grid-image-decorative img {
    object-fit: cover;
}

/* ========== NOUVELLE SECTION CARTE ISOLÉE ========== */

/* Reset et isolation complète */
.cp-map-section {
    /* Reset tous les styles hérités */
    all: initial;
    /* Réappliquer seulement ce dont on a besoin */
    display: block;
    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    box-sizing: border-box;
    position: relative;
}

.cp-map-section * {
    box-sizing: border-box;
}

/* Container interne */
.cp-map-inner {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 0;
    margin: 0;
}

/* Frame de la carte avec dimensions fixes selon viewport */
.cp-map-frame {
    width: 100%;
    position: relative;
    background: transparent;
}

/* Desktop : largeur max de 600px */
@media (min-width: 768px) {
    .cp-map-frame {
        max-width: 600px;
        height: 576px; /* 600 * 0.96 */
    }
}

/* Tablet : 100% largeur, hauteur fixe */
@media (min-width: 481px) and (max-width: 767px) {
    .cp-map-frame {
        width: calc(100vw - 40px);
        max-width: 500px;
        height: 480px;
    }
}

/* Mobile : dimensions fixes */
@media (max-width: 480px) {
    .cp-map-frame {
        width: calc(100vw - 20px);
        max-width: 360px;
        height: 346px; /* 360 * 0.96 */
    }
}

/* Container SVG */
.cp-svg-holder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.cp-svg-holder svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
}

/* Wrapper du bouton contact */
.cp-contact-wrapper {
    display: flex;
    justify-content: center;
    width: 100%;
    padding: 0 20px;
}

/* Nouveau bouton contact isolé */
.cp-contact-btn {
    /* Reset */
    all: initial;
    /* Styles de base */
    display: inline-block;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 18px;
    font-weight: 500;
    color: #ffffff;
    background-color: #EE855D;
    text-decoration: none;
    padding: 15px 30px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    border: none;
    outline: none;
}

.cp-contact-btn:hover {
    background-color: #ffffff;
    color: #EE855D;
    border: 2px solid #EE855D;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

@media (max-width: 480px) {
    .cp-contact-btn {
        font-size: 16px;
        padding: 12px 24px;
    }
}

/* Ancien bouton (pour compatibilité temporaire) */
.carte-projets-map-section .contact-button {
    box-sizing: border-box;
    color: rgb(255, 255, 255) !important;
    display: inline-block;
    line-height: 1;
    fill: rgb(255, 255, 255);
    text-align: center;
    transition: 0.3s;
    box-shadow: none;
    text-decoration: none !important;
    width: auto;
    background-color: var(--e-global-color-accent, #EE855D) !important;
    font-family: var(--e-global-typography-8af468b-font-family, 'Albert Sans'), Sans-serif !important;
    font-size: calc(var(--e-global-typography-8af468b-font-size, 16px) * 2) !important;
    font-weight: var(--e-global-typography-8af468b-font-weight, 500) !important;
    border-radius: 10px !important;
    padding: 20px 30px !important;
    margin: 20px 0 0 0;
}

.carte-projets-map-section .contact-button:hover {
    background-color: var(--e-global-color-550fc50, #C7846C) !important;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    color: rgb(255, 255, 255) !important;
}

/* Styles SVG */
.carte-projets-svg-container #city-markers {
    pointer-events: all;
}

/* Marqueurs SVG */
.city-marker-group {
    cursor: pointer;
}

.city-marker {
    fill: var(--e-global-color-accent, #EE855D);
    stroke: none;
    transition: transform 0.3s ease, fill 0.3s ease, r 0.3s ease;
    transform-origin: center center;
    transform-box: fill-box;
}

.city-marker-group:hover .city-marker {
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}

.city-marker.active {
    transform: scale(1.5);
}

/* Badge de label de ville */
.city-label-bg {
    fill: var(--e-global-color-accent, #EE855D) !important;
    stroke: none !important;
    filter: drop-shadow(0 3px 6px rgba(0,0,0,0.3)) !important;
}

.city-marker-label {
    fill: #FFFEF5 !important;
    font-family: 'Albert Sans', sans-serif !important;
    font-size: 24px !important;
    font-weight: 400 !important; /* Regular */
    line-height: 1 !important;
    pointer-events: none;
}

.city-label-group {
    opacity: 1;
    transition: opacity 0.3s ease;
}

.city-marker-group:hover .city-label-group {
    opacity: 1;
}

/* Placeholder */
.carte-projets-placeholder {
    background-color: white;
    border-radius: 12px;
    padding: 60px 40px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.carte-projets-placeholder p {
    color: var(--e-global-color-secondary, #777158);
    font-family: inherit;
    font-size: inherit;
    margin: 0;
}

/* Message "pas de projets" */
.no-projects {
    text-align: center;
    padding: 40px 20px;
    color: var(--e-global-color-secondary, #777158);
    font-family: inherit;
    font-style: italic;
}

/* Animations */
.carte-projets-content {
    opacity: 1;
    transition: opacity 0.3s ease;
}

.carte-projets-content.loading {
    opacity: 0.5;
}

/* ========== SLIDER STYLES ========== */

/* Conteneur principal du slider */
.projects-slider {
    position: relative;
    width: 100%;
}

/* Conteneur des projets */
.projects-container {
    overflow: hidden;
    position: relative;
    width: 100%;
}

/* Track qui contient tous les slides */
.projects-track {
    display: flex;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

/* Chaque slide */
.project-slide {
    width: 100%;
    flex-shrink: 0;
    opacity: 1;
    visibility: visible;
}

/* Points de navigation */
.slider-dots {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 30px;
    padding: 10px 0;
}

.slider-dot {
    width: 12px;
    height: 12px;
    border: none;
    border-radius: 50%;
    background: #D6CCAF;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0;
    position: relative;
}

.slider-dot:hover {
    background: #C7B798;
    transform: scale(1.2);
}

.slider-dot.active {
    background: var(--e-global-color-accent, #EE855D);
    width: 28px;
    border-radius: 6px;
}

.slider-dot:focus {
    outline: 2px solid var(--e-global-color-accent, #EE855D);
    outline-offset: 3px;
}

/* Responsive */
@media (max-width: 1024px) {
    /* Adapter le texte long pour tablette */
    .grid-texte-long {
        height: auto;
        min-height: 200px;
        max-height: 400px;
        overflow-y: auto;
    }
    
    .carte-projets-wrapper {
        grid-template-columns: 1fr;
        gap: 30px;
    }
    
    .carte-projets-svg-container {
        height: 500px;
    }
    
    /* Grille tablette - 2 colonnes */
    .project-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Adaptation des spans pour tablette */
    .grid-badges {
        grid-column: 1 / -1;
    }
    
    .grid-titre {
        grid-column: 1 / -1;
        grid-row: auto;
    }
    
    .grid-image-principale {
        grid-column: 1 / -1;
        grid-row: auto;
    }
    
    .grid-image-secondaire {
        grid-column: 1;
        grid-row: auto;
    }
    
    .grid-image-tertiaire {
        grid-column: 2;
        grid-row: auto;
    }
    
    .grid-image-decorative {
        grid-column: 1;
        grid-row: auto;
    }
    
    .grid-texte-long {
        grid-column: 1 / -1;
        grid-row: auto;
    }
}

@media (max-width: 767px) {
    /* Adapter le texte long pour mobile - hauteur automatique */
    .grid-texte-long {
        height: auto;
        min-height: auto;
        max-height: none;
        overflow-y: visible;
    }
    
    .carte-projets-container {
        padding: 40px 0;
        overflow-x: hidden;
    }
    
    .carte-projets-wrapper {
        display: flex;
        flex-direction: column;
        max-width: 100%;
        overflow-x: hidden;
    }
    
    .carte-projets-content-section {
        order: 2;
    }
    
    .carte-projets-map-section {
        order: 1;
    }
    
    /* Gestion mobile de la carte SVG */
    .carte-projets-map-section {
        width: 100%;
        max-width: 100%;
        padding: 0 10px;
        box-sizing: border-box;
    }
    
    .carte-projets-svg-container {
        min-height: 350px;
        max-height: 500px;
        aspect-ratio: 1000 / 960;
        width: 100%;
        max-width: 100%;
    }
    
    /* Fallback mobile */
    @supports not (aspect-ratio: 1 / 1) {
        .carte-projets-svg-container {
            height: 400px;
            padding-bottom: 0;
        }
    }
    
    .project-card {
        padding: 20px;
    }
    
    .carte-projets-svg-container {
        height: 500px !important;
        min-height: 400px !important;
        max-height: 70vh !important;
        width: 100% !important;
        position: relative !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .carte-projets-svg-container svg {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
        object-fit: contain !important;
    }
    
    /* Bouton contact mobile */
    .carte-projets-map-section .contact-button {
        width: calc(100% - 40px);
        margin: 20px 20px 0 20px;
        text-align: center;
        padding: 20px 30px !important;
        font-size: calc(var(--e-global-typography-8af468b-font-size, 16px) * 2) !important;
    }
    
    /* Points de navigation mobile */
    .slider-dots {
        padding: 0 20px;
    }
    
    /* Grille mobile - 1 colonne */
    .project-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    /* Tout en pleine largeur sur mobile */
    .grid-badges,
    .grid-titre,
    .grid-image-principale,
    .grid-image-secondaire,
    .grid-image-tertiaire,
    .grid-image-decorative,
    .grid-texte-long {
        grid-column: 1;
        grid-row: auto;
    }
    
    /* Tailles relatives maintenues par les em dans les classes principales */
    
    .grid-badges {
        flex-wrap: wrap;
    }
    
    .badge {
        font-size: 11px; /* Taille fixe pour mobile */
        padding: 5px 8px;
    }
    
}

/* Amélioration de l'accessibilité */
.city-marker:focus {
    outline: 2px solid var(--e-global-color-accent, #EE855D);
    outline-offset: 2px;
}

.contact-button:focus {
    outline: 2px solid var(--e-global-color-secondary, #777158);
    outline-offset: 2px;
}

/* Message d'erreur */
.error-message {
    background-color: #fff3cd;
    color: #856404;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #ffeaa7;
    text-align: center;
    margin: 20px 0;
    font-family: inherit;
}

.error-message p {
    margin: 0;
}

/* Styles pour très petits écrans (< 480px) */
@media (max-width: 480px) {
    .carte-projets-map-section {
        padding: 10px;
    }
    
    /* Ajuster la carte pour très petits écrans */
    .carte-projets-svg-container {
        min-height: 300px;
        max-height: 400px;
    }
    
    /* Réduire la taille du bouton contact sur très petit écran */
    .carte-projets-map-section .contact-button {
        font-size: calc(var(--e-global-typography-8af468b-font-size, 16px) * 1.5) !important;
        padding: 15px 25px !important;
    }
}

/* ========== LIGHTBOX STYLES ========== */

/* Container principal de la lightbox */
.cp-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: none;
}

/* Overlay semi-transparent */
.cp-lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    cursor: pointer;
}

/* Container de l'image */
.cp-lightbox-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 70px 80px 20px 80px; /* Espace pour boutons sur desktop */
}

/* Contenu de la lightbox */
.cp-lightbox-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
}

/* Image dans la lightbox */
.cp-lightbox-image {
    max-width: 100%;
    max-height: 100%;
    min-height: 70vh;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    margin: auto;
}


/* Bouton fermer */
.cp-lightbox-close {
    position: fixed;
    top: 10px;
    right: 10px;
    width: 48px;
    height: 48px;
    background-color: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.cp-lightbox-close svg {
    width: 24px;
    height: 24px;
    transition: transform 0.3s ease;
}

.cp-lightbox-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}


.cp-lightbox-close:hover svg {
    transform: scale(1.1);
}

/* Boutons de navigation */
.cp-lightbox-prev,
.cp-lightbox-next {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    background-color: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 0.8;
    pointer-events: auto;
}

.cp-lightbox-prev svg,
.cp-lightbox-next svg {
    width: 24px;
    height: 24px;
    transition: transform 0.3s ease;
}

.cp-lightbox-prev {
    left: 20px;
}

.cp-lightbox-next {
    right: 20px;
}

.cp-lightbox-prev:hover,
.cp-lightbox-next:hover {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    opacity: 1;
}

.cp-lightbox-prev:hover svg {
    transform: translateX(-2px);
}

.cp-lightbox-next:hover svg {
    transform: translateX(2px);
}

/* Mobile adjustments for lightbox */
@media (max-width: 767px) {
    .cp-lightbox-close svg {
        width: 20px;
        height: 20px;
    }
    
    .cp-lightbox-prev svg,
    .cp-lightbox-next svg {
        width: 20px;
        height: 20px;
    }
    
    .cp-lightbox-close {
        width: 36px;
        height: 36px;
        font-size: 24px;
        top: 10px;
        right: 10px;
    }
    
    .cp-lightbox-prev,
    .cp-lightbox-next {
        position: static;
        transform: none;
        width: 48px;
        height: 48px;
        font-size: 24px;
        border-radius: 12px;
        opacity: 1;
    }
    
    .cp-lightbox-prev {
        left: auto;
    }
    
    .cp-lightbox-next {
        right: auto;
    }
    
    .cp-lightbox-prev:hover,
    .cp-lightbox-next:hover {
        transform: none;
    }
    
    .cp-lightbox-image {
        max-height: calc(100vh - 140px); /* Ajust\u00e9 pour l'espace des boutons en bas */
        min-height: 50vh;
    }
    
    .cp-lightbox-container {
        padding: 10px;
        padding-bottom: 80px; /* Espace pour les boutons de navigation */
        flex-direction: column;
    }
    
    /* Container de navigation en bas sur mobile */
    .cp-lightbox-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 20px;
        padding: 15px;
        pointer-events: auto;
        background: linear-gradient(to top, rgba(0, 0, 0, 0.5), transparent);
    }
}

/* Container de navigation - invisible sur desktop */
.cp-lightbox-nav {
    position: relative;
}

/* Sur desktop, les boutons restent positionnés comme avant */
@media (min-width: 768px) {
    .cp-lightbox-nav {
        display: contents; /* Les enfants se comportent comme s'ils étaient directement dans le parent */
    }
}

/* Curseur sur les images cliquables */
.grid-image-principale img,
.grid-image-secondaire img,
.grid-image-tertiaire img,
.grid-image-decorative img {
    cursor: zoom-in;
}