:root {
    --primary-color: #667eea;
    --primary-dark: #5568d3;
    --secondary-color: rgba(117, 172, 170, 0.8);
    --danger-color: #ef4444;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    --purple: #8b5cf6;
    --cyan: #06b6d4;
    --pink: #ec4899;
    --gray: #a1a1a1;
    --border-color: #e0e0e0;
    --text-primary: #333;
    --text-secondary: #666;
    --bg-light: #f8f9fa;
    --shadow-sm: 0 2px 6px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 15px rgba(0,0,0,0.15);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text-primary);
    background-color: #f0f0f0;
}

#map {
    height: 100vh;
    width: 100%;
    background-color: #f0f0f0;
}

.control-panel {
    position: absolute;
    top: 20px;
    left: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 260px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    z-index: 1000;
    contain: layout style paint;
}

/* Scrollbar personnalisé */
.control-panel::-webkit-scrollbar {
    width: 8px;
}

.control-panel::-webkit-scrollbar-track {
    background: transparent;
}

.control-panel::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
    border: 2px solid white;
}

.control-panel::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

.panel-header {
    background: var(--secondary-color);
    color: white;
    padding: 15px 20px;
    border-radius: 12px 12px 0 0;
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 15px;
    will-change: transform;
}

.panel-header img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

.panel-header-text {
    flex: 1;
}

.panel-header h1 {
    font-size: 1.05em;
    margin: 0 0 2px 0;
    font-weight: 700;
}

.panel-header h2 {
    font-size: 1.3em;
    margin: 0 0 3px 0;
    font-weight: 700;
}

.panel-header .subtitle {
    font-size: 0.8em;
    opacity: 0.95;
    font-weight: 500;
}

.panel-content {
    padding: 15px;
    font-size: 1.05em;
}

.filter-section {
    margin-bottom: 15px;
}

.info-section {
    margin-bottom: 12px;
    padding: 10px;
    border-radius: 6px;
    font-size: 0.8em;
}

.info-section h4 {
    margin: 0 0 6px 0;
    font-size: 0.9em;
    cursor: pointer;
    user-select: none;
}

.info-section-content {
    display: none;
    font-size: 1em;
}

.info-section-content.open {
    display: block;
}

.info-section h4:before {
    content: '▶ ';
    display: inline-block;
    margin-right: 5px;
    transition: transform 0.3s;
}

.info-section h4.open:before {
    transform: rotate(90deg);
}
.btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 10px;
    transition: all 0.3s ease;
}

.btn-secondary {
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-secondary:hover {
    background: var(--primary-color);
    color: white;
}

.stats-mini {
    background: var(--bg-light);
    padding: 10px 12px;
    border-radius: 8px;
    margin-top: 12px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    font-size: 0.85em;
}

.stat-value {
    font-weight: bold;
    color: var(--primary-color);
}

.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 30px 40px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    text-align: center;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Labels communes */
.custom-label {
    background: transparent !important;
    border: none !important;
}

.commune-label {
    background: rgba(255, 255, 255, 0.75);
    border: 3px solid var(--primary-color);
    border-radius: 10px;
    padding: 10px 14px 8px 14px;
    font-size: 11px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    font-weight: 600;
    white-space: nowrap;
    backdrop-filter: blur(5px);
    cursor: pointer;
    transition: all 0.3s ease;
    will-change: transform;
}

.commune-label:hover {
    background: rgba(255, 255, 255, 0.95);
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    border-color: var(--primary-dark);
}

.commune-label .click-hint {
    display: block;
    text-align: center;
    font-size: 9px;
    color: var(--primary-color);
    margin-top: 6px;
    padding-top: 4px;
    border-top: 1px dashed var(--primary-color);
    font-weight: 500;
    opacity: 0.8;
}

.commune-label .commune-name {
    color: var(--primary-color);
    font-size: 13px;
    margin-bottom: 6px;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 4px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.commune-label .stat-line {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 3px 0;
    color: #333;
    font-size: 11px;
}

.commune-label .stat-icon {
    font-size: 15px;
    min-width: 18px;
}

/* Badges de score */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-excellent {
    background: var(--success-color);
    color: white;
}

.badge-tres-bon {
    background: var(--info-color);
    color: white;
}

.badge-bon {
    background: var(--purple);
    color: white;
}

.badge-moyen {
    background: var(--warning-color);
    color: white;
}

.badge-faible {
    background: var(--danger-color);
    color: white;
}

.badge-limitee {
    background: #6b7280;
    color: white;
}

.badge-excellente {
    background: var(--success-color);
    color: white;
}

.badge-bonne {
    background: var(--info-color);
    color: white;
}

.badge-moyenne {
    background: var(--warning-color);
    color: white;
}

/* Statistique en couleur */
.stat-positive {
    color: var(--success-color);
    font-weight: 700;
}

.stat-neutral {
    color: var(--info-color);
}

.stat-negative {
    color: var(--danger-color);
}

/* POI labels */
.poi-label {
    background: transparent !important;
    border: none !important;
    cursor: pointer;
}

.poi-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.poi-icon {
    font-size: 24px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.poi-name {
    background: rgba(255, 255, 255, 0.9);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}

.poi-label > div:hover {
    transform: scale(1.15);
    z-index: 1001;
}

/* Popup */
.popup-header {
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 8px;
    font-size: 1.1em;
}

.popup-row {
    margin: 4px 0;
    font-size: 0.9em;
    line-height: 1.6;
}

/* Légende */
.legend {
    position: absolute;
    bottom: 30px;
    right: 20px;
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    z-index: 1000;
    font-size: 0.85em;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}

.legend h4 {
    margin: 0 0 10px 0;
    font-size: 1em;
    color: #333;
    font-weight: 600;
}

.legend-section {
    margin-bottom: 15px;
}

.legend-section-title {
    font-size: 0.9em;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 5px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 3px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 5px 0;
}

.legend-icon {
    font-size: 16px;
    min-width: 20px;
}

.info-section-dynamisme {
    background: #f0f4ff;
}

.info-section-dynamisme h4 {
    color: var(--primary-color);
    margin-top: 0;
}

.info-section-dynamisme p {
    margin: 4px 0;
    line-height: 1.4;
}

.info-section-dynamisme .info-text {
    font-size: 1em;
    color: var(--text-secondary);
    line-height: 1.4;
}

.info-section-accessibilite {
    background: #f0f9f7;
}

.info-section-accessibilite h4 {
    color: #1f7f6f;
    margin-top: 0;
}

.info-section-accessibilite .info-text {
    font-size: 1em;
    color: var(--text-secondary);
    line-height: 1.4;
}

.info-section-sources {
    background: #fff5f0;
}

.info-section-sources h4 {
    color: #c1592b;
    margin-top: 0;
}

.info-section-sources .info-text {
    font-size: 1em;
    color: var(--text-secondary);
    line-height: 1.3;
    margin: 3px 0;
}

.info-section-sources strong {
    color: var(--primary-color);
}

.info-section-communes {
    background: #f5f5f5;
}

.info-section-communes h4 {
    color: #333;
    margin-top: 0;
}

.info-section-communes .info-text {
    font-size: 1em;
    color: var(--text-secondary);
    line-height: 1.3;
    margin: 2px 0;
}

.info-section-poi {
    background: #f0f4ff;
}

.info-section-poi h4 {
    color: var(--primary-color);
    margin-top: 0;
}

.info-section-poi .poi-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 4px 0;
    font-size: 1em;
    color: var(--text-secondary);
}

.poi-legend-item svg {
    flex-shrink: 0;
}

.info-section-statistiques {
    background: #f5f7ff;
}

.info-section-statistiques h4 {
    color: var(--primary-color);
    margin-top: 0;
}
        
.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 0.95em;
    border-bottom: 1px solid rgba(102, 126, 234, 0.1);
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-row .stat-value {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 1.1em;
}