/* =====================================================================
   tendances.css — Page TENDANCES POLITIQUES adaptée au layout moderne
   (topbar.php + menu_droit.php, fluide / 100% responsive)
   ===================================================================== */

html, body {
    margin: 0;
    padding: 0;
}
body.page-tendances {
    font-family: 'Noto Sans Display', Arial, Helvetica, sans-serif;
    color: #2a3540;
}

/* Annule l'ancien fond bandeau N&B floute du squelette */
.main-container::before,
.main-container::after {
    display: none !important;
    content: none !important;
    background: none !important;
}

.news-tickers { background: none !important; }

/* Alignement vertical : haut du sidebar = haut du contenu */
.page-wrapper-tendances .sidebar-blocks {
    margin-top: 0 !important;
    align-self: start;
}
.page-wrapper-tendances .main-content {
    margin-top: 0 !important;
}

/* =====================================================================
   1. BLOC INTRO
   ===================================================================== */
.tendances-intro {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    background: #ffffff;
    border: 1px solid rgba(0, 80, 125, 0.08);
    border-radius: 14px;
    padding: 14px 18px;
    margin-bottom: clamp(16px, 2vw, 22px);
    box-shadow: 0 3px 12px rgba(0, 80, 125, 0.06);
    position: relative;
    overflow: hidden;
}
.tendances-intro::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, #00507D, #e86c00);
}

.tendances-intro-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: linear-gradient(135deg, #00507D 0%, #0a6391 100%);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 80, 125, 0.22);
}
.tendances-intro-text {
    color: #2a3540;
    font-size: 0.95rem;
    line-height: 1.5;
}
.tendances-intro-text strong { color: #00507D; }
.tendances-intro-cta {
    display: block;
    margin-top: 4px;
    color: #00507D;
    font-size: 0.88rem;
}

/* =====================================================================
   2. CARTE MONDE
   ===================================================================== */
.world-card,
.continent-card {
    background: #ffffff;
    border: 1px solid rgba(0, 80, 125, 0.08);
    border-radius: 16px;
    padding: clamp(14px, 1.8vw, 22px);
    box-shadow: 0 4px 16px rgba(0, 80, 125, 0.08);
    margin-bottom: clamp(16px, 2vw, 22px);
}

.world-card-header,
.continent-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 12px;
    margin-bottom: 14px;
    border-bottom: 1px solid rgba(0, 80, 125, 0.08);
}
.world-card-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, #00507D 0%, #0a6391 100%);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    box-shadow: 0 3px 10px rgba(0, 80, 125, 0.2);
}
.world-title {
    margin: 0;
    font-size: clamp(0.95rem, 1.6vw, 1.15rem);
    font-weight: 800;
    color: #00507D;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1.2;
}

.continent-card-header {
    justify-content: center;
}
.continent-title {
    margin: 0;
    font-size: clamp(0.9rem, 1.4vw, 1.05rem);
    font-weight: 800;
    color: #00507D;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: center;
    line-height: 1.2;
    padding: 6px 14px;
    background: linear-gradient(135deg, rgba(0, 80, 125, 0.08), rgba(232, 108, 0, 0.08));
    border-radius: 999px;
}

/* Conteneur cartes : permet de positionner le bouton "Agrandir" en overlay */
.map-wrap {
    position: relative;
    width: 100%;
}

/* Bouton "Agrandir" : visible en permanence, clair sur mobile et desktop */
.map-zoom-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 5;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    background: linear-gradient(135deg, #e86c00 0%, #ff8c1a 100%);
    color: #ffffff;
    border: none;
    border-radius: 999px;
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(232, 108, 0, 0.35);
    transition: transform 0.2s ease, box-shadow 0.25s ease, background 0.25s ease;
    -webkit-tap-highlight-color: transparent;
}
.map-zoom-btn i {
    font-size: 0.85rem;
}
.map-zoom-btn:hover,
.map-zoom-btn:focus {
    transform: translateY(-1px) scale(1.02);
    box-shadow: 0 6px 18px rgba(232, 108, 0, 0.5);
    outline: none;
}
.map-zoom-btn:active {
    transform: translateY(0) scale(0.98);
}

/* Cartes interactives — ratio fixe pour eviter les cartes geantes vides */
#world-overview-map {
    width: 100%;
    aspect-ratio: 16 / 8;
    max-height: 520px;
    min-height: 260px;
    border-radius: 12px;
    cursor: zoom-in;
    background: linear-gradient(180deg, #f7fbfd 0%, #eef4f8 100%);
    overflow: hidden;
}
.continent-map {
    width: 100%;
    aspect-ratio: 16 / 10;
    max-height: 280px;
    min-height: 200px;
    border-radius: 12px;
    cursor: zoom-in;
    background: linear-gradient(180deg, #f7fbfd 0%, #eef4f8 100%);
    overflow: hidden;
}
/* Oceanie s'etend sur 2 colonnes => carte plus large => ratio different */
.continent-card.oceanie .continent-map {
    aspect-ratio: 16 / 7;
    max-height: 240px;
}

/* Grille des continents : 2 colonnes max, oceanie sur 2 colonnes pleine largeur */
.continent-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(14px, 1.6vw, 20px);
}
.continent-card.oceanie {
    grid-column: 1 / -1;
    width: 100%;
}

/* =====================================================================
   3. LEGENDES
   ===================================================================== */
.legend-wrapper { margin-top: 14px; }
.legend-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    margin-bottom: 12px;
    gap: 10px;
}
.legend-total-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.legend-total-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: rgba(232, 108, 0, 0.12);
    color: #e86c00;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
}
.legend-total {
    font-size: 0.85rem;
    color: #00507D;
    font-weight: 600;
}
.legend-total strong {
    color: #e86c00;
    font-size: 1rem;
    margin-left: 4px;
}
.last-update {
    text-align: right;
    font-size: 0.75rem;
    color: #6b7886;
    font-style: italic;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    justify-content: flex-end;
}
.last-update i { color: #e86c00; }

.legend,
.continent-legend {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
}
.continent-legend {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
/* Sur la carte oceanie (qui est large), legende plus dense */
.continent-card.oceanie .continent-legend {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.legend-item,
.continent-legend-item {
    display: flex;
    align-items: center;
    background: #f7fbfd;
    border: 1px solid rgba(0, 80, 125, 0.1);
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #00507D;
    cursor: pointer;
    transition: background 0.25s ease, border-color 0.25s ease, transform 0.2s ease, box-shadow 0.25s ease;
    user-select: none;
    min-width: 0;
}
.legend-item:hover,
.continent-legend-item:hover {
    background: #ffffff;
    border-color: rgba(232, 108, 0, 0.4);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 80, 125, 0.08);
}
.legend-item.active-filter,
.continent-legend-item.active-filter {
    background: linear-gradient(135deg, rgba(232, 108, 0, 0.14), rgba(232, 108, 0, 0.06));
    border-color: #e86c00;
    box-shadow: 0 4px 14px rgba(232, 108, 0, 0.18);
}

.color-box,
.c-color-box {
    width: 16px;
    height: 16px;
    margin-right: 10px;
    border-radius: 4px;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.15);
}

.legend-item span,
.continent-legend-item span {
    line-height: 1.3;
    flex: 1 1 auto;
    min-width: 0;
    /* on autorise le wrap : la legende n'est plus tronquee */
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-word;
}
.legend-item span small,
.continent-legend-item span small {
    display: block;
    font-size: 0.7rem;
    font-weight: 500;
    color: #6b7886;
    margin-top: 2px;
    white-space: nowrap;
}

.continent-legend-wrapper { margin-top: 14px; }
.continent-legend-total {
    text-align: center;
    font-weight: 600;
    color: #00507D;
    font-size: 0.82rem;
    margin: 10px 0 10px 0;
    padding-top: 10px;
    border-top: 1px solid rgba(0, 80, 125, 0.08);
}
.continent-legend-total strong {
    color: #e86c00;
    font-size: 1rem;
    margin-left: 4px;
}

/* Bouton "Annuler le filtre" */
.reset-filter-btn {
    display: none;
    margin: 14px auto 0 auto;
    padding: 8px 18px;
    background: linear-gradient(135deg, #e86c00 0%, #ff8c1a 100%);
    color: #fff;
    font-weight: 700;
    font-size: 0.78rem;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(232, 108, 0, 0.28);
    transition: transform 0.2s ease, box-shadow 0.25s ease, background 0.25s ease;
    align-items: center;
    gap: 6px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.reset-filter-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(232, 108, 0, 0.4);
}
.reset-filter-btn i {
    font-size: 0.85rem;
}

/* =====================================================================
   4. MODAL (carte zoomée)
   ===================================================================== */
.map-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(10, 22, 35, 0.84);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.map-modal.open { display: flex; }
.map-modal-box {
    position: relative;
    width: min(96vw, 1500px);
    height: min(92vh, 980px);
    background: #ffffff;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}
.map-modal-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: #00507D;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0 0 10px 0;
    padding-right: 46px;
}
.map-modal-close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #e86c00 0%, #ff8c1a 100%);
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
    box-shadow: 0 4px 12px rgba(232, 108, 0, 0.3);
    transition: transform 0.2s ease, box-shadow 0.25s ease;
}
.map-modal-close:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 18px rgba(232, 108, 0, 0.45);
}
#modal-map {
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    border-radius: 12px;
    background: transparent !important;
}

/* =====================================================================
   POPUP MOBILE persistant (remplace le tooltip natif dans la modal)
   ===================================================================== */
.map-mobile-popup {
    position: fixed;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    width: min(420px, 92vw);
    background: #ffffff;
    border: 2px solid #e86c00;
    border-radius: 16px;
    padding: 14px 14px 12px 14px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
    z-index: 100001;
    display: none;
    flex-direction: column;
    gap: 10px;
    color: #2a3540;
    font-family: inherit;
    animation: popupSlideUp 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes popupSlideUp {
    from { opacity: 0; transform: translate(-50%, 24px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}

.map-mobile-popup-close {
    position: absolute;
    top: 6px;
    right: 8px;
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(0, 80, 125, 0.08);
    color: #00507D;
    border-radius: 50%;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
    padding: 0;
    font-family: inherit;
}
.map-mobile-popup-close:hover,
.map-mobile-popup-close:active {
    background: #e86c00;
    color: #ffffff;
}

.map-mobile-popup-body {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-right: 30px;
}

.map-mobile-popup-photo {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 50%;
    border: 2px solid #e86c00;
    flex-shrink: 0;
    background: #f5f9fb;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #6b7886;
    font-size: 1.3rem;
}

.map-mobile-popup-info {
    flex: 1 1 auto;
    min-width: 0;
}
.map-mobile-popup-country {
    font-size: 1rem;
    font-weight: 800;
    color: #00507D;
    line-height: 1.2;
    margin-bottom: 2px;
}
.map-mobile-popup-leader {
    font-size: 0.88rem;
    color: #2a3540;
    line-height: 1.3;
    margin-bottom: 2px;
}
.map-mobile-popup-trend {
    font-size: 0.72rem;
    color: #6b7886;
    font-style: italic;
    line-height: 1.2;
}

.map-mobile-popup-cta {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 14px;
    background: linear-gradient(135deg, #e86c00 0%, #ff8c1a 100%);
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(232, 108, 0, 0.35);
    transition: transform 0.2s ease, box-shadow 0.25s ease;
    -webkit-tap-highlight-color: transparent;
}
.map-mobile-popup-cta:hover,
.map-mobile-popup-cta:active {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(232, 108, 0, 0.5);
}
.map-mobile-popup-cta i {
    transition: transform 0.2s ease;
}
.map-mobile-popup-cta:hover i,
.map-mobile-popup-cta:active i {
    transform: translateX(3px);
}

/* Tooltips jsvectormap : toujours visibles */
.jvm-tooltip {
    z-index: 100000 !important;
    pointer-events: auto !important;
    font-family: inherit !important;
    background: #00507D !important;
    border: 1px solid rgba(255,255,255,0.15) !important;
    border-radius: 10px !important;
    padding: 8px 12px !important;
    font-size: 0.82rem !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3) !important;
}
#modal-map path,
#modal-map circle { cursor: pointer !important; }

/* =====================================================================
   5. RESPONSIVE
   ===================================================================== */

/* Tablette */
@media (max-width: 1100px) {
    .legend-header {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 6px;
    }
    .legend-total-wrap { justify-content: center; }
    .last-update { text-align: center; justify-content: center; }
}

/* Tablette portrait : 1 colonne continents */
@media (max-width: 900px) {
    .continent-grid {
        grid-template-columns: 1fr;
    }
    .continent-card.oceanie {
        grid-column: auto;
    }
    /* Toutes les cartes continents reviennent au meme ratio */
    .continent-map,
    .continent-card.oceanie .continent-map {
        aspect-ratio: 16 / 9;
        max-height: 260px;
    }
    /* Tooltips repositionnés en bas sur petit écran (lisibilité) */
    .jvm-tooltip {
        position: fixed !important;
        bottom: 16px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: min(92vw, 420px) !important;
        max-width: 92vw !important;
        text-align: center;
        white-space: normal !important;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4) !important;
    }
}

/* Mobile */
@media (max-width: 600px) {
    .tendances-intro {
        padding: 12px 14px;
        gap: 10px;
    }
    .tendances-intro-icon {
        width: 36px;
        height: 36px;
        font-size: 0.95rem;
    }
    .tendances-intro-text { font-size: 0.88rem; }

    .world-card,
    .continent-card {
        padding: 14px;
        border-radius: 14px;
    }
    .world-card-header { gap: 10px; padding-bottom: 10px; margin-bottom: 12px; }
    .world-card-icon { width: 34px; height: 34px; font-size: 0.92rem; }
    .world-title { font-size: 0.9rem; }
    .continent-title { font-size: 0.85rem; padding: 5px 12px; }

    #world-overview-map { aspect-ratio: 16 / 10; max-height: 320px; }
    .continent-map,
    .continent-card.oceanie .continent-map { aspect-ratio: 16 / 10; max-height: 240px; }

    .legend,
    .continent-legend {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .legend-item,
    .continent-legend-item {
        padding: 8px 10px;
        font-size: 0.76rem;
    }
    .color-box,
    .c-color-box { width: 14px; height: 14px; margin-right: 8px; }

    .legend-total {
        font-size: 0.8rem;
    }
    .last-update { font-size: 0.7rem; }

    .reset-filter-btn {
        padding: 8px 16px;
        font-size: 0.72rem;
    }

    .map-modal { padding: 10px; }
    .map-modal-box {
        padding: 12px;
        border-radius: 14px;
        width: 100%;
        height: 100%;
    }
    .map-modal-title {
        font-size: 0.85rem;
        padding-right: 40px;
    }
    .map-modal-close {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }
    /* Bouton agrandir : icone seule sur petit ecran */
    .map-zoom-btn {
        padding: 8px 10px;
        font-size: 0;
        gap: 0;
        border-radius: 50%;
        width: 38px;
        height: 38px;
        justify-content: center;
    }
    .map-zoom-btn i { font-size: 0.95rem; }
    .map-zoom-btn span { display: none; }
}

/* Très petit mobile */
@media (max-width: 380px) {
    .tendances-intro {
        flex-direction: column;
        gap: 10px;
    }
    .tendances-intro-icon { width: 34px; height: 34px; }
    #world-overview-map { aspect-ratio: 16 / 11; max-height: 280px; }
    .continent-map,
    .continent-card.oceanie .continent-map { aspect-ratio: 16 / 11; max-height: 220px; }
    .world-title { font-size: 0.84rem; letter-spacing: 0.02em; }
}

/* Très grand écran : on garde des cartes équilibrées */
@media (min-width: 1600px) {
    #world-overview-map { max-height: 520px; }
    .continent-map { max-height: 280px; }
    .continent-card.oceanie .continent-map { max-height: 240px; }
}
