:root {
    --bg-color: #f8f9fa;
    --menu-bg: rgba(255, 255, 255, 0.9);
    --text-color: #333;
    --border-color: rgba(0, 0, 0, 0.1);
    --shadow-color: rgba(0, 0, 0, 0.2);
    --popup-bg: white;
    --popup-text: #333;
    --link-color: #0078A8;
    --sidebar-bg: white;
    --sidebar-text: #333;
}

.dark-mode {
    --bg-color: #121212;
    --menu-bg: rgba(30, 30, 30, 0.9);
    --text-color: #f0f0f0;
    --border-color: rgba(200, 200, 200, 0.2);
    --shadow-color: rgba(0, 0, 0, 0.4);
    --popup-bg: #2d2d2d;
    --popup-text: #f0f0f0;
    --link-color: #4da6ff;
    --sidebar-bg: #2d2d2d;
    --sidebar-text: #f0f0f0;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: Arial, sans-serif;
    overflow: hidden;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s;
}

#menu, #sidebar {
    position: absolute;
    z-index: 1000;
    background: var(--menu-bg);
    padding: 5px 8px;
    border-radius: 4px;
    box-shadow: 0 0 10px var(--shadow-color);
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

#menu {
    top: 50px;
    left: 10px;
}

#sidebar {
    right: 10px;
    top: 50px;
    width: 320px;
    height: calc(100vh - 100px);
    transform: translateX(120%);
    transition: transform 0.3s, background-color 0.3s, color 0.3s;
    overflow-y: auto;
    margin: 0 10px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
}

#sidebar.visible {
    transform: translateX(0);
}

#menu ul {
    list-style: none;
    margin: 0;
    padding: 10px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}

#menu li {
    margin: 0 6px;
}

#menu a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: bold;
    padding: 3px 5px;
    font-size: 14px;
}

#menu a:hover {
    color: var(--link-color);
}

.search-container {
    position: relative;
    margin: 0 6px;
}

#search-box {
    padding: 8px 10px 8px 32px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    width: 200px;
    font-size: 14px;
    transition: all 0.3s;
    outline: none;
    background: var(--menu-bg);
    color: var(--text-color);
}

#search-box:focus {
    border-color: var(--link-color);
    box-shadow: 0 0 5px var(--link-color);
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-color);
}

#map {
    width: 100%;
    height: 100vh;
}

#sidebar h2 {
    margin-top: 0;
    color: var(--sidebar-text);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.leaflet-popup-content-wrapper {
    background: var(--popup-bg);
    color: var(--popup-text);
    padding: 0;
    text-align: center;
    border-radius: 4px;
}

.leaflet-popup-content {
    margin: 0;
    width: 200px;
}

.popup-image {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 4px 4px 0 0;
}

.popup-title {
    font-weight: bold;
    margin: 8px 0 4px 0;
    color: var(--popup-text);
}

.popup-link {
    color: var(--link-color);
    text-decoration: none;
    font-size: 13px;
    display: block;
    margin-top: 8px;
}

.theme-toggle {
    cursor: pointer;
    padding: 3px 6px;
    font-size: 16px;
}

.detail-section {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.detail-section h3 {
    margin-top: 0;
    color: var(--sidebar-text);
    font-size: 1.2em;
}

.security-très-sûr { color: #2ecc71; font-weight: bold; }
.security-sûr { color: #27ae60; font-weight: bold; }
.security-moyen { color: #f39c12; font-weight: bold; }
.security-risqué { color: #e67e22; font-weight: bold; }
.security-très-risqué { color: #e74c3c; font-weight: bold; }

.desirability-score {
    margin: 15px 0;
}

.score-value {
    font-size: 1.5em;
    font-weight: bold;
    text-align: center;
    margin-bottom: 5px;
    color: var(--sidebar-text);
}

.score-bar {
    height: 10px;
    background: #ecf0f1;
    border-radius: 5px;
    overflow: hidden;
}

.score-bar::before {
    content: '';
    display: block;
    height: 100%;
    width: calc(var(--score) * 1%);
    background: linear-gradient(to right, #2ecc71, #f1c40f);
    border-radius: 5px;
}

.data-source {
    color: var(--sidebar-text);
    font-style: italic;
    margin-top: 10px;
    opacity: 0.8;
}

.error {
    color: #e74c3c;
    padding: 10px;
    background: #fadbd8;
    border-radius: 4px;
}

button {
    background: #3498db;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
}

button:hover {
    background: #2980b9;
}

/* Bouton burger et menu mobile */
.burger-menu {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 2rem;
    height: 2rem;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 10;
}

.burger-bar {
    width: 2rem;
    height: 0.25rem;
    background: var(--text-color);
    border-radius: 10px;
    transition: all 0.3s ease;
}

.menu {
    position: fixed;
    top: 0;
    left: -100%;
    width: 80%;
    max-width: 300px;
    height: 100vh;
    background: var(--menu-bg);
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
    transition: left 0.3s ease;
    z-index: 9;
    padding: 5rem 2rem;
    color: var(--text-color);
}

.menu ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.menu li {
    margin-bottom: 1rem;
}

.menu a {
    text-decoration: none;
    color: var(--text-color);
    font-size: 1.2rem;
}

.menu a:hover {
    color: var(--link-color);
}

#menu-mobile {
    position: absolute;
    top: 0;
    left: -250px;
    z-index: 1000;
    width: 200px;
    height: 100vh;
    background: var(--menu-bg);
    padding: 50px 10px;
    box-shadow: 5px 0 10px rgba(0, 0, 0, 0.2);
    transition: left 0.3s;
    color: var(--text-color);
}

#menu-mobile ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

#menu-mobile li {
    margin: 15px 0;
    padding: 10px;
}

#menu-mobile a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: bold;
    font-size: 16px;
}

#menu-mobile a:hover {
    color: var(--link-color);
}

@media (min-width: 992px) {
    #menu-burger {
        display: none;
    }
}

@media (max-width: 768px) {
    .burger-menu {
        display: flex;
    }
    .menu.active {
        left: 0;
    }
}

@media (max-width: 600px) {
    #menu, #sidebar {
        top: 5px;
        left: 5px;
        right: 5px;
        width: calc(100% - 10px);
        margin: 0 5px;
    }
    #menu ul {
        flex-direction: column;
        align-items: center;
    }
    #menu li {
        margin: 4px 0;
    }
    #search-box {
        width: 100%;
    }

    #menu-burger {
        width: auto;
        margin-left: 20px;
        position: relative;
        left: 0;
    }

    #menu {
        display: none;
    }

    #close-menu {
        display: block;
        position: absolute;
        top: 10px;
        right: 10px;
        font-size: 20px;
        cursor: pointer;
        z-index: 1002;
    }
}
