/* =============================================================================
   FRENCH PROPERTY PRICES MAP - Styles
   Apple/Duolingo clean light theme
   ============================================================================= */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: #f5f5f7;
    color: #1d1d1f;
    overflow: hidden;
}

#app {
    display: flex;
    height: 100vh;
    width: 100vw;
}

#map {
    flex: 1;
    height: 100%;
    position: relative;
}

/* ---- Left Panel ---- */
#panel {
    width: 340px;
    min-width: 340px;
    height: 100vh;
    overflow-y: auto;
    background: white;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-right: 1px solid #d2d2d7;
}

/* Scrollbar */
#panel::-webkit-scrollbar {
    width: 6px;
}
#panel::-webkit-scrollbar-track {
    background: transparent;
}
#panel::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}
#panel::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Header */
.panel-header h1 {
    font-size: 1.15rem;
    font-weight: 700;
    color: #1d1d1f;
    letter-spacing: -0.3px;
}

.subtitle {
    font-size: 0.75rem;
    color: #86868b;
    margin-top: 2px;
}

/* Panel sections */
.panel-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.section-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: #1d1d1f;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ---- Pill Buttons (3D Duolingo style) ---- */
.pill-group {
    display: flex;
    gap: 4px;
}

/* ---- Level Radio Buttons (3x2 grid) ---- */
.level-radios {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px 6px;
}

.level-radio {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 6px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    color: #4b4b4b;
    transition: background 0.15s;
}

.level-radio:hover {
    background: #eee;
}

.level-radio input[type="radio"] {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    min-width: 16px;
    border: 2px solid #d2d2d7;
    border-radius: 50%;
    background: #f5f5f7;
    cursor: pointer;
    position: relative;
}

.level-radio input[type="radio"]:checked {
    border-color: #1cb0f6;
    background: #1cb0f6;
}

.level-radio input[type="radio"]:checked::after {
    content: "";
    position: absolute;
    left: 3px;
    top: 3px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: white;
}

.level-radio span {
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-weight: 600;
    font-size: 0.72rem;
}

/* ---- Checkbox Dropdown ---- */
.cb-dropdown {
    position: relative;
}

.cb-toggle {
    width: 100%;
    padding: 8px 28px 8px 10px;
    background: white;
    color: #1d1d1f;
    border: 2px solid #e5e5e5;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.2s ease;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%234b4b4b'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.cb-toggle:hover {
    border-color: #1cb0f6;
}

.cb-menu {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    margin-top: 2px;
    background: white;
    border: 2px solid #e5e5e5;
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.cb-dropdown.open .cb-menu {
    display: block;
}

.cb-menu::-webkit-scrollbar {
    width: 4px;
}
.cb-menu::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 2px;
}

.cb-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 0.75rem;
    color: #1d1d1f;
    transition: background 0.1s;
}

.cb-item:hover {
    background: #f5f5f7;
}

.cb-item.cb-all {
    border-bottom: 2px solid #e5e5e5;
    color: #1cb0f6;
    font-weight: 700;
}

.cb-item input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    min-width: 16px;
    border: 2px solid #d2d2d7;
    border-radius: 3px;
    background: #f5f5f7;
    cursor: pointer;
    position: relative;
}
.cb-item input[type="checkbox"]:checked {
    background: #1cb0f6;
    border-color: #1cb0f6;
}
.cb-item input[type="checkbox"]:checked::after {
    content: "";
    position: absolute;
    left: 4px;
    top: 1px;
    width: 5px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.cb-item-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cb-item-price {
    color: #86868b;
    font-size: 0.68rem;
    white-space: nowrap;
}

/* ---- Dynamic Stat Detail ---- */
.stat-detail {
    font-size: 0.68rem;
    color: #86868b;
}

/* ---- Price Filter ---- */
.price-inputs {
    display: flex;
    align-items: center;
    gap: 6px;
}

.price-inputs input[type="number"] {
    flex: 1;
    padding: 6px 8px;
    background: white;
    color: #1d1d1f;
    border: 2px solid #e5e5e5;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    font-family: inherit;
    width: 0;
    transition: all 0.2s ease;
    -moz-appearance: textfield;
}

.price-inputs input[type="number"]::-webkit-inner-spin-button,
.price-inputs input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
}

.price-inputs input:focus {
    outline: none;
    border-color: #1cb0f6;
}

.price-sep {
    color: #86868b;
    font-size: 0.8rem;
}

/* Dual range slider */
.range-container {
    position: relative;
    height: 24px;
    margin-top: 2px;
}

.slider-bg {
    position: absolute;
    top: 10px;
    left: 0;
    right: 0;
    height: 4px;
    background: #e5e5e5;
    border-radius: 2px;
    z-index: 1;
}

.slider-track {
    position: absolute;
    top: 10px;
    height: 4px;
    background: linear-gradient(to right, #028758, #FFF64E, #CC000A);
    border-radius: 2px;
    z-index: 1;
    left: 0;
    width: 100%;
}

.range-container input[type="range"] {
    position: absolute;
    width: 100%;
    top: 0;
    height: 24px;
    margin: 0;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    pointer-events: none;
    z-index: 2;
}

.range-container input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    background: transparent;
}

.range-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #1cb0f6;
    pointer-events: all;
    cursor: pointer;
    border: 2px solid white;
    margin-top: -5px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.range-container input[type="range"]::-moz-range-track {
    height: 4px;
    background: transparent;
    border: none;
}

.range-container input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #1cb0f6;
    pointer-events: all;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

/* ---- Legend ---- */
/* ---- Floating Map Overlay (stat + legend) ---- */
.map-overlay {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 10;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    border-radius: 10px;
    padding: 12px 16px;
    min-width: 200px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.map-overlay .country-stat {
    background: none;
    border-radius: 0;
    padding: 0;
    text-align: left;
}

.map-overlay .country-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #86868b;
}

.map-overlay .country-price {
    font-size: 1.3rem;
    font-weight: 700;
    color: #1d1d1f;
}

.map-overlay .stat-detail {
    font-size: 0.65rem;
    color: #86868b;
}

.legend-bar {
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right, #028758, #FFF64E, #CC000A);
}

.legend-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.65rem;
    color: #86868b;
    margin-top: 2px;
}

/* ---- Country Stat ---- */
.country-stat {
    padding: 10px 12px;
    background: #f5f5f7;
    border-radius: 10px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.country-label {
    font-size: 0.7rem;
    color: #86868b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

#country-price {
    font-size: 1.2rem;
    font-weight: 700;
    color: #1d1d1f;
}

/* ---- Explore Section ---- */
.explore-section {
    flex: 1;
}

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

.explore-count-pills {
    display: flex;
    gap: 3px;
}

.count-pill {
    padding: 3px 10px;
    border: none;
    background: #e5e5e5;
    color: #4b4b4b;
    font-size: 0.68rem;
    font-weight: 700;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.1s ease;
    font-family: inherit;
    box-shadow: 0 2px 0 #afafaf;
}

.count-pill:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 0 #afafaf;
}

.count-pill:active {
    transform: translateY(2px);
    box-shadow: 0 0 0 #afafaf;
}

.count-pill.active {
    background: #1cb0f6;
    color: white;
    box-shadow: 0 2px 0 #1899d6;
}

/* Search input */
.explore-search {
    width: 100%;
    padding: 7px 10px;
    background: white;
    color: #1d1d1f;
    border: 2px solid #e5e5e5;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 500;
    font-family: inherit;
    transition: all 0.2s ease;
}

.explore-search:focus {
    outline: none;
    border-color: #1cb0f6;
}

.explore-search::placeholder {
    color: #aeaeb2;
}

/* Explore list rows */
.explore-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    margin-bottom: 3px;
    background: #f5f5f7;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 0.8rem;
}

.explore-row:hover {
    background: #e8e8ed;
}

.explore-rank {
    font-size: 0.7rem;
    font-weight: 700;
    color: #1cb0f6;
    min-width: 16px;
}

.explore-info {
    flex: 1;
    min-width: 0;
}

.explore-name {
    color: #1d1d1f;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.explore-sub {
    font-size: 0.65rem;
    color: #86868b;
}

.explore-price {
    font-weight: 700;
    color: #1cb0f6;
    font-size: 0.8rem;
    white-space: nowrap;
}

.explore-bar-wrap {
    width: 40px;
    height: 4px;
    background: #e5e5e5;
    border-radius: 2px;
    overflow: hidden;
}

.explore-bar {
    height: 100%;
    border-radius: 2px;
    background: #1cb0f6;
    transition: width 0.3s;
}

.explore-empty {
    font-size: 0.75rem;
    color: #86868b;
    text-align: center;
    padding: 12px 0;
}

/* ---- Footer ---- */
.footer {
    padding-top: 8px;
    border-top: 1px solid #e5e5e5;
    font-size: 0.65rem;
    color: #aeaeb2;
    line-height: 1.5;
}

/* ---- Floating Tooltip ---- */
#tooltip {
    position: fixed;
    z-index: 1000;
    pointer-events: none;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid #d2d2d7;
    border-radius: 10px;
    padding: 10px 14px;
    min-width: 180px;
    max-width: 260px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    backdrop-filter: blur(8px);
}

#tooltip.hidden {
    display: none;
}

.tt-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: #1d1d1f;
    margin-bottom: 4px;
}

.tt-price {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1cb0f6;
    margin-bottom: 6px;
}

.tt-details {
    display: flex;
    flex-direction: column;
    gap: 1px;
    font-size: 0.72rem;
    color: #86868b;
}

/* ---- Theme Toggle Button ---- */
.theme-toggle {
    width: 34px;
    height: 34px;
    border: none;
    background: #f5f5f7;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s ease;
    box-shadow: 0 2px 0 #e0e0e0;
}

.theme-toggle:hover {
    background: #e8e8ed;
    transform: translateY(-1px);
    box-shadow: 0 3px 0 #e0e0e0;
}

.theme-toggle:active {
    transform: translateY(2px);
    box-shadow: 0 0 0 #e0e0e0;
}

/* =============================================================================
   DARK MODE
   ============================================================================= */

body.dark-mode {
    background-color: #1a1a1a;
    color: #e5e5e5;
}

body.dark-mode #panel {
    background: #242424;
    border-right-color: #333;
}

body.dark-mode #panel::-webkit-scrollbar-thumb {
    background: #555;
}

body.dark-mode .panel-header h1 {
    color: #ffffff;
}

body.dark-mode .subtitle {
    color: #888;
}

body.dark-mode .section-label {
    color: #e5e5e5;
}

/* Dark mode radio buttons */
body.dark-mode .level-radio {
    color: #e5e5e5;
}

body.dark-mode .level-radio:hover {
    background: #333;
}

body.dark-mode .level-radio input[type="radio"] {
    background: #3a3a3a;
    border-color: #555;
}

body.dark-mode .level-radio input[type="radio"]:checked {
    background: #1cb0f6;
    border-color: #1cb0f6;
}

/* Dark mode checkbox dropdown */
body.dark-mode .cb-toggle {
    background-color: #2a2a2a;
    color: #e5e5e5;
    border-color: #444;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23e5e5e5'/%3E%3C/svg%3E");
}

body.dark-mode .cb-toggle:hover {
    border-color: #1cb0f6;
}

body.dark-mode .cb-menu {
    background: #2a2a2a;
    border-color: #444;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

body.dark-mode .cb-menu::-webkit-scrollbar-thumb {
    background: #555;
}

body.dark-mode .cb-item {
    color: #e5e5e5;
}

body.dark-mode .cb-item:hover {
    background: #333;
}

body.dark-mode .cb-item.cb-all {
    border-bottom-color: #444;
    color: #1cb0f6;
}

body.dark-mode .cb-item input[type="checkbox"] {
    background: #3a3a3a;
    border-color: #555;
}
body.dark-mode .cb-item input[type="checkbox"]:checked {
    background: #1cb0f6;
    border-color: #1cb0f6;
}

body.dark-mode .cb-item-price {
    color: #888;
}

/* Dark mode stat */
body.dark-mode .country-stat {
    background: none;
}

body.dark-mode .country-label {
    color: #999;
}

body.dark-mode .country-price {
    color: #ffffff;
}

body.dark-mode .stat-detail {
    color: #999;
}

/* Dark mode price inputs */
body.dark-mode .price-inputs input[type="number"] {
    background: #2a2a2a;
    color: #e5e5e5;
    border-color: #444;
}

body.dark-mode .price-inputs input:focus {
    border-color: #1cb0f6;
}

body.dark-mode .price-sep {
    color: #888;
}

/* Dark mode slider */
body.dark-mode .slider-bg {
    background: #1a1a1a;
}

body.dark-mode .range-container input[type="range"]::-webkit-slider-thumb {
    border-color: #2a2a2a;
}

body.dark-mode .range-container input[type="range"]::-moz-range-thumb {
    border-color: #2a2a2a;
}

/* Dark mode map overlay */
body.dark-mode .map-overlay {
    background: rgba(36, 36, 36, 0.92);
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

body.dark-mode .map-overlay .country-price {
    color: #ffffff;
}

body.dark-mode .legend-labels {
    color: #999;
}

/* Dark mode count pills */
body.dark-mode .count-pill {
    background: #2a2a2a;
    color: #e5e5e5;
    box-shadow: 0 2px 0 #1a1a1a;
}

body.dark-mode .count-pill:hover {
    box-shadow: 0 3px 0 #1a1a1a;
}

body.dark-mode .count-pill.active {
    background: #1cb0f6;
    color: white;
    box-shadow: 0 2px 0 #1899d6;
}

/* Dark mode search */
body.dark-mode .explore-search {
    background: #2a2a2a;
    color: #e5e5e5;
    border-color: #444;
}

body.dark-mode .explore-search:focus {
    border-color: #1cb0f6;
}

body.dark-mode .explore-search::placeholder {
    color: #666;
}

/* Dark mode explore rows */
body.dark-mode .explore-row {
    background: #2a2a2a;
}

body.dark-mode .explore-row:hover {
    background: #333;
}

body.dark-mode .explore-name {
    color: #e5e5e5;
}

body.dark-mode .explore-sub {
    color: #888;
}

body.dark-mode .explore-bar-wrap {
    background: #1a1a1a;
}

body.dark-mode .explore-empty {
    color: #888;
}

/* Dark mode footer */
body.dark-mode .footer {
    border-top-color: #333;
    color: #666;
}

/* Dark mode tooltip */
body.dark-mode #tooltip {
    background: rgba(36, 36, 36, 0.96);
    border-color: #444;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

body.dark-mode .tt-name {
    color: #ffffff;
}

body.dark-mode .tt-details {
    color: #888;
}

/* Dark mode theme toggle */
body.dark-mode .theme-toggle {
    background: #2a2a2a;
    box-shadow: 0 2px 0 #1a1a1a;
}

body.dark-mode .theme-toggle:hover {
    background: #333;
    box-shadow: 0 3px 0 #1a1a1a;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    #app {
        flex-direction: column-reverse;
    }
    #panel {
        width: 100%;
        min-width: unset;
        height: 40vh;
        border-right: none;
        border-top: 1px solid #d2d2d7;
    }
    body.dark-mode #panel {
        border-top-color: #333;
    }
    #map {
        height: 60vh;
    }
}
