/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f5;
    color: #333;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 100%;
    margin: 0 auto;
}

/* Header */
header {
    background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
    color: white;
    padding: 20px 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 30px;
}

header h1 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 5px;
}

.subtitle {
    font-size: 14px;
    opacity: 0.9;
}

/* Search */
.search-container {
    position: relative;
    min-width: 250px;
}

#city-search {
    width: 100%;
    padding: 10px 15px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    outline: none;
    transition: all 0.2s;
}

#city-search:focus {
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#city-search::placeholder {
    color: #999;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: 8px;
    margin-top: 5px;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    display: none;
}

.search-results.active {
    display: block;
}

.search-result-item {
    padding: 10px 15px;
    cursor: pointer;
    color: #333;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.15s;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background-color: #f0f0f0;
}

.search-result-city {
    font-weight: 500;
    font-size: 14px;
}

.search-result-info {
    font-size: 11px;
    color: #666;
    margin-top: 2px;
}

/* Info Panel */
.info-panel {
    background: white;
    padding: 12px 30px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
}

.stats {
    display: flex;
    flex-direction: row;
    gap: 20px;
    min-width: 200px;
    flex-shrink: 0;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.stat-label {
    font-size: 10.5px;
    color: #666;
    white-space: nowrap;
}

.stat-value {
    font-size: 18px;
    font-weight: 600;
    color: #2563eb;
}

.legend {
    font-size: 10px;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 15px;
    flex: 0 0 auto;
    max-width: 65%;
}

.legend h3 {
    font-size: 10px;
    margin-bottom: 3px;
    margin-top: 0;
    color: #333;
    font-weight: 600;
}

.legend ul {
    list-style: none;
}

.legend li {
    margin-bottom: 2px;
    color: #666;
    line-height: 1.3;
    font-size: 9.5px;
}

/* Marker legend */
.marker-legend {
    margin-bottom: 0;
}

.marker-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
    border: 2px solid #fff;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);
}

.marker-dot.primaire {
    background-color: #3b82f6; /* Blue for primary schools */
}

.marker-dot.college {
    background-color: #eab308; /* Yellow for middle schools */
}

.marker-dot.lycee {
    background-color: #dc2626; /* Red for high schools */
}

.info-list li {
    margin-bottom: 2px;
}

.legend-section {
    min-width: 0;
}

/* Filters Panel */
.filters-panel {
    background: white;
    padding: 15px 30px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    border-top: 1px solid #e5e5e5;
}

.filters-content {
    display: flex;
    align-items: center;
    gap: 30px;
    flex-wrap: wrap;
}

.filters-content h3 {
    font-size: 13px;
    margin: 0;
    color: #333;
    font-weight: 600;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-group > label {
    font-size: 11px;
    font-weight: 500;
    color: #666;
    margin: 0;
}

.checkbox-group {
    display: flex;
    gap: 15px;
    align-items: center;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: #333;
    cursor: pointer;
    margin: 0;
    font-weight: normal;
}

.checkbox-label input[type="checkbox"] {
    cursor: pointer;
    width: 14px;
    height: 14px;
}

.checkbox-label span {
    user-select: none;
}

.language-select {
    font-size: 11px;
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    color: #333;
    cursor: pointer;
    min-width: 120px;
}

.language-select:focus {
    outline: none;
    border-color: #2563eb;
}

/* Map */
#map {
    flex: 1;
    width: 100%;
    min-height: 500px;
}

/* Popup Content */
.popup-content {
    font-size: 13px;
    line-height: 1.6;
    max-width: 400px;
}

.popup-content h3 {
    font-size: 16px;
    color: #2563eb;
    margin-bottom: 10px;
    border-bottom: 2px solid #2563eb;
    padding-bottom: 5px;
}

.popup-content h4 {
    font-size: 13px;
    margin-top: 12px;
    margin-bottom: 6px;
    color: #333;
    font-weight: 600;
}

.school-info p {
    margin: 4px 0;
    font-size: 12px;
}

.school-info strong {
    color: #555;
    font-weight: 500;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    margin-right: 6px;
}

.badge-public {
    background-color: #dbeafe;
    color: #1e40af;
}

.badge-prive {
    background-color: #fef3c7;
    color: #92400e;
}

.ips-context {
    font-size: 11px;
    color: #666;
    font-style: italic;
    margin-top: 2px;
}

.highlight-metric {
    background-color: #f0fdf4;
    padding: 8px;
    border-radius: 4px;
    border-left: 3px solid #10b981;
    margin: 8px 0;
}

.highlight-metric strong {
    color: #059669;
}

/* Popup Expandable Sections */
.popup-section {
    margin: 12px 0;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    overflow: hidden;
}

.popup-section summary {
    padding: 10px 12px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    color: #2563eb;
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    transition: background 0.2s;
}

.popup-section summary::-webkit-details-marker {
    display: none;
}

.popup-section summary::before {
    content: '▶';
    display: inline-block;
    margin-right: 8px;
    font-size: 10px;
    transition: transform 0.2s;
}

.popup-section[open] summary::before {
    transform: rotate(90deg);
}

.popup-section summary:hover {
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
}

.popup-section[open] summary {
    border-bottom: 1px solid #e5e5e5;
}

.popup-section .school-info,
.popup-section .political-info {
    padding: 12px;
}

/* Political Info */
.political-info {
    font-size: 11px;
}

.political-info p {
    margin: 6px 0;
    line-height: 1.4;
}

.political-info strong {
    color: #555;
    font-weight: 500;
}

/* Leaflet Popup Customization */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
    padding: 5px;
}

.leaflet-popup-content {
    margin: 15px;
    max-width: 400px !important;
}

.leaflet-popup-tip {
    background: white;
}

/* Leaflet Tooltip Customization */
.leaflet-tooltip {
    background-color: rgba(0, 0, 0, 0.8);
    border: none;
    border-radius: 4px;
    color: white;
    font-size: 12px;
    padding: 6px 10px;
}

/* Responsive */
@media (max-width: 1200px) {
    .legend {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

@media (max-width: 768px) {
    .info-panel {
        flex-direction: column;
        align-items: flex-start;
        padding: 10px 20px;
    }

    .stats {
        width: 100%;
        flex-wrap: wrap;
        gap: 10px;
    }

    .stat {
        flex-direction: column;
        align-items: flex-start;
    }

    .legend {
        grid-template-columns: 1fr;
        max-width: 100%;
        gap: 8px;
        font-size: 9px;
    }

    .legend h3 {
        font-size: 9px;
    }

    .legend li {
        font-size: 8.5px;
        line-height: 1.2;
        margin-bottom: 1px;
    }

    .filters-panel {
        padding: 12px 20px;
    }

    .filters-content {
        gap: 15px;
    }

    .filter-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
        width: 100%;
    }

    .checkbox-group {
        gap: 10px;
        flex-wrap: wrap;
    }

    .language-select {
        width: 100%;
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .search-container {
        width: 100%;
    }

    header h1 {
        font-size: 20px;
    }

    .popup-content {
        font-size: 11px;
    }

    .popup-content h3 {
        font-size: 14px;
    }

    .popup-content h4 {
        font-size: 11px;
    }

    .school-info p {
        font-size: 10px;
    }

    .political-info {
        font-size: 10px;
    }

    .popup-section summary {
        font-size: 12px;
        padding: 8px 10px;
    }

    .popup-section .school-info,
    .popup-section .political-info {
        padding: 10px;
    }
}
