:root {
    --primary-color: #e2001a;
    --secondary-color: #b30015;
    --background-color: #f8f8f8;
    --text-color: #333;
    --border-color: #e0e0e0;
    --hover-color: #ff1a33;
    --shadow-light: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 4px 15px rgba(0, 0, 0, 0.15);
    --shadow-heavy: 0 8px 25px rgba(0, 0, 0, 0.2);
    --border-radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#darkmodeBtn {
    display: none!important;
}

/* Map Container */
#map {
    width: 100%;
    height: 100vh;
    z-index: 0;
}

/* Masquer le bouton dark mode sur la carte */
.map-container.active #darkmodeBtn {
    display: none !important;
}

/* Modern Markers */
.modern-marker-container {
    background: transparent !important;
    border: none !important;
}

.modern-marker {
    position: relative;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 3px solid;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-medium);
    transition: var(--transition);
    cursor: pointer;
}

.modern-marker:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-heavy);
}

.marker-inner {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 12px;
}

.marker-icon {
    display: block;
    font-size: 12px;
    line-height: 1;
}

.multi-status-indicator {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    background: #8B5CF6;
    border-radius: 50%;
    border: 2px solid white;
}

/* Modern Search Control (Desktop uniquement) */
.modern-search-control {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
}

.search-container {
    display: flex;
    background: white;
    border-radius: 25px;
    box-shadow: var(--shadow-medium);
    overflow: hidden;
    transition: var(--transition);
}

.search-container:focus-within {
    box-shadow: var(--shadow-heavy);
}

#modernSearchBox {
    padding: 12px 20px;
    border: none;
    outline: none;
    font-size: 16px;
    width: 300px;
    font-family: 'Poppins', sans-serif;
}

#searchButton {
    padding: 12px 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 16px;
    transition: var(--transition);
}

#searchButton:hover {
    background: var(--secondary-color);
}

/* Combined Legend - Disposition optimisée */
.combined-legend {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-medium);
    padding: 16px;
    margin: 10px;
    max-width: 320px;
    min-width: 280px;
    transition: var(--transition);
    border: 1px solid rgba(0, 0, 0, 0.05);
    max-height: 70vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.combined-legend:hover {
    box-shadow: var(--shadow-heavy);
}

.legend-section {
    margin-bottom: 20px;
}

.legend-section:last-child {
    margin-bottom: 0;
}

.legend-section h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 8px;
    border-bottom: 2px solid #f0f0f0;
}

.legend-icon {
    font-size: 16px;
}

.legend-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.legend-items.compact {
    gap: 6px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
}

.legend-item.compact {
    padding: 4px 6px;
    gap: 8px;
}

.legend-item:hover {
    background: #f8f9fa;
    transform: translateX(2px);
}

.legend-item.inactive {
    opacity: 0.4;
}

.legend-item.inactive:hover {
    opacity: 0.7;
}

/* Operator Legend */
.operator-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: var(--shadow-light);
    transition: var(--transition);
    flex-shrink: 0;
}

.operator-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-color);
}

/* Status Legend */
.status-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 10px;
    font-weight: bold;
    box-shadow: var(--shadow-light);
    border: 2px solid rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
}

.status-dot.compact {
    width: 16px;
    height: 16px;
    font-size: 9px;
}

.status-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 1;
    gap: 8px;
}

.status-info.compact {
    gap: 6px;
}

.status-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-color);
    flex: 1;
}

.status-count {
    font-size: 10px;
    color: #666;
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 8px;
    font-weight: 600;
    min-width: 18px;
    text-align: center;
    flex-shrink: 0;
}

/* Modern Toggle Control */
.modern-toggle-control {
    z-index: 1001;
}

.modern-toggle-button {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: white;
    box-shadow: var(--shadow-medium);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-size: 18px;
}

.modern-toggle-button:hover {
    background: #f8f9fa;
    box-shadow: var(--shadow-heavy);
    transform: scale(1.05);
}

.modern-toggle-button.active {
    background: var(--primary-color);
    color: white;
}

.modern-toggle-button.active:hover {
    background: var(--secondary-color);
}

.toggle-icon {
    transition: var(--transition);
}

.modern-toggle-button.active .toggle-icon {
    transform: rotate(180deg);
}

/* Modern Popups - Correction complète */
.leaflet-popup-content-wrapper {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-heavy);
    padding: 0;
    overflow: hidden;
}

.leaflet-popup-content {
    margin: 0 !important;
    padding: 0 !important;
    width: auto !important;
    min-width: 280px;
    max-width: 320px;
}

.modern-popup {
    font-family: 'Poppins', sans-serif;
    position: relative;
}

.modern-popup .popup-header {
    color: white;
    padding: 12px 16px;
    margin: 0;
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 40px;
}

.modern-popup .popup-header.popup-header-freemobile {
    background: #666666;
}

.modern-popup .popup-header.popup-header-bouyguestelecom {
    background: #109DB9;
}

.modern-popup .popup-header.popup-header-sfr {
    background: var(--primary-color);
}

.modern-popup .popup-header.popup-header-orange {
    background: #FF6400;
}

.modern-popup .popup-header.popup-header-multiples {
    background: #8B5CF6;
}

.header-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 1;
}

.site-id {
    font-weight: 600;
    font-size: 14px;
}

.site-height {
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.popup-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 18px;
    font-weight: bold;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    margin-left: 8px;
}

.popup-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.popup-body {
    padding: 16px;
}

.site-details {
    margin-bottom: 16px;
}

.detail-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text-color);
}

.detail-icon {
    font-size: 14px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.external-link {
    text-align: center;
    margin-bottom: 16px;
}

.cartoradio-link {
    display: inline-block;
    background: var(--primary-color);
    color: white!important;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    transition: var(--transition);
}

.cartoradio-link:hover {
    background: var(--secondary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-light);
}

.operator-section {
    margin-bottom: 16px;
    border-top: 1px solid #f0f0f0;
    padding-top: 12px;
}

.operator-section:first-child {
    border-top: none;
    padding-top: 0;
}

.operator-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.changes-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.change-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: #f8f9fa;
    border-radius: 6px;
}

.change-icon {
    font-size: 14px;
    font-weight: bold;
    width: 16px;
    text-align: center;
    flex-shrink: 0;
}

.change-details {
    flex: 1;
}

.change-details strong {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 2px;
}

.systems-list {
    font-size: 10px;
    color: #666;
    line-height: 1.2;
}

/* Masquer la croix par défaut de Leaflet */
.leaflet-popup-close-button {
    display: none !important;
}

/* Marker Clustering */
.marker-cluster-small {
    background-color: rgba(181, 226, 140, 0.8);
}

.marker-cluster-small div {
    background-color: rgba(110, 204, 57, 0.8);
}

.marker-cluster-medium {
    background-color: rgba(241, 211, 87, 0.8);
}

.marker-cluster-medium div {
    background-color: rgba(240, 194, 12, 0.8);
}

.marker-cluster-large {
    background-color: rgba(253, 156, 115, 0.8);
}

.marker-cluster-large div {
    background-color: rgba(241, 128, 23, 0.8);
}

.marker-cluster {
    background-clip: padding-box;
    border-radius: 20px;
}

.marker-cluster div {
    width: 30px;
    height: 30px;
    margin-left: 5px;
    margin-top: 5px;
    text-align: center;
    border-radius: 15px;
    font: 12px "Helvetica Neue", Arial, Helvetica, sans-serif;
}

.marker-cluster span {
    line-height: 30px;
    font-weight: bold;
    color: white;
}

/* Responsive Design */
@media (max-width: 768px) {
    /* Masquer la recherche sur mobile */
    .modern-search-control {
        display: none !important;
    }

    .combined-legend {
        margin: 5px;
        padding: 12px;
        min-width: 250px;
        max-width: calc(100vw - 20px);
        max-height: 60vh;
        font-size: 14px;
    }

    .legend-section h4 {
        font-size: 13px;
    }

    .operator-name,
    .status-name {
        font-size: 11px;
    }

    .status-count {
        font-size: 9px;
        padding: 1px 4px;
        min-width: 16px;
    }

    .modern-toggle-button {
        width: 44px;
        height: 44px;
        font-size: 16px;
    }

    .modern-popup {
        max-width: calc(100vw - 40px);
        min-width: 260px;
    }

    .popup-body {
        padding: 12px;
    }

    .detail-item {
        font-size: 12px;
    }

    .change-details strong {
        font-size: 10px;
    }

    .systems-list {
        font-size: 9px;
    }

    /* Safe area insets pour iOS */
    @supports (padding: max(0px)) {
        .combined-legend {
            bottom: max(10px, env(safe-area-inset-bottom));
            right: max(10px, env(safe-area-inset-right));
        }

        .modern-toggle-control {
            top: max(20px, env(safe-area-inset-top));
            right: max(20px, env(safe-area-inset-right));
        }
    }
}

@media (max-width: 480px) {
    .combined-legend {
        min-width: 220px;
        padding: 10px;
    }

    .legend-section {
        margin-bottom: 15px;
    }

    .legend-items.compact {
        gap: 4px;
    }

    .legend-item.compact {
        padding: 3px 5px;
    }

    .operator-dot {
        width: 12px;
        height: 12px;
    }

    .status-dot.compact {
        width: 14px;
        height: 14px;
        font-size: 8px;
    }
}

/* Animation pour l'apparition des légendes */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.combined-legend[style*="display: block"] {
    animation: slideInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .combined-legend {
        background: #2d3748;
        color: white;
        border-color: rgba(255, 255, 255, 0.1);
    }

    .legend-section h4 {
        color: white;
        border-bottom-color: rgba(255, 255, 255, 0.1);
    }

    .legend-item:hover {
        background: rgba(255, 255, 255, 0.1);
    }

    .operator-name,
    .status-name {
        color: #e2e8f0;
    }

    .status-count {
        background: rgba(255, 255, 255, 0.1);
        color: #cbd5e0;
    }

    .modern-popup .popup-body {
        background: #2d3748;
        color: white;
    }

    .detail-item, .detail-label, .detail-value, .section-title {
        color: #e2e8f0!important;
    }

    .change-item {
        background: rgba(255, 255, 255, 0.05);
    }

    .change-details strong {
        color: #e2e8f0;
    }

    .systems-list {
        color: #a0aec0;
    }
    .operator-btn {
        color: white!important;
    }
}

/* Print styles */
@media print {
    .combined-legend,
    .modern-search-control,
    .modern-toggle-control {
        display: none !important;
    }
}

/* Enhanced Popup Styles */
.enhanced-popup {
    font-family: 'Poppins', sans-serif;
    position: relative;
}

.enhanced-popup .popup-body {
    padding: 16px;
    max-height: 70vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.info-section {
    margin-bottom: 20px;
}

.info-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-color);
    margin: 0 0 10px 0;
    display: flex;
    align-items: center;
    gap: 6px;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

.detail-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.detail-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 12px;
    line-height: 1.4;
}

.detail-label {
    font-weight: 500;
    color: #666;
    min-width: 80px;
    flex-shrink: 0;
}

.detail-value {
    color: var(--text-color);
    font-weight: 400;
    flex: 1;
    word-break: break-word;
}

/* Status specific styles */
.generation-3g {
    color: #f59e0b;
    font-weight: 600;
}

.generation-4g {
    color: #3b82f6;
    font-weight: 600;
}

.generation-5g {
    color: #ef4444;
    font-weight: 600;
}

.status-en-service {
    color: #10b981;
    font-weight: 600;
}

.status-hors-service {
    color: #ef4444;
    font-weight: 600;
}

/* Operator section styles */
.operator-section {
    margin-bottom: 12px;
    background: #f8f9fa;
    padding: 8px;
    border-radius: 6px;
}

.operator-title {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.changes-grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.change-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 4px;
    font-size: 11px;
}

.change-icon {
    font-size: 12px;
    font-weight: bold;
    width: 14px;
    text-align: center;
    flex-shrink: 0;
}

.change-details {
    flex: 1;
}

.change-details strong {
    display: block;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 1px;
}

.systems-list {
    font-size: 9px;
    color: #666;
    line-height: 1.2;
}

/* External link styles */
.external-link {
    text-align: center;
    margin: 16px 0;
    padding-top: 12px;
}

.cartoradio-link {
    display: inline-block;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    transition: var(--transition);
}

.cartoradio-link:hover {
    background: var(--secondary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-light);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .enhanced-popup .popup-body {
        padding: 12px;
        max-height: 60vh;
    }

    .section-title {
        font-size: 12px;
    }

    .detail-item {
        font-size: 11px;
    }

    .detail-label {
        min-width: 70px;
    }

    .operator-title {
        font-size: 11px;
    }

    .change-item {
        font-size: 10px;
    }
}

/* Scrollbar styling */
.enhanced-popup .popup-body::-webkit-scrollbar {
    width: 4px;
}

.enhanced-popup .popup-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 2px;
}

.enhanced-popup .popup-body::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 2px;
}

.enhanced-popup .popup-body::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}