:root {
    --color-bg:             #f0f2f5;
    --color-surface:        #ffffff;
    --color-border:         #e4e7eb;
    --color-text:           #1a1d23;
    --color-text-muted:     #6b7280;
    --color-immoweb:        #003f7f;
    --color-immoweb-hover:  #002a57;
    --color-immoweb-light:  #e8f0fa;
    --color-trevi:          #c0392b;
    --color-trevi-hover:    #96281b;
    --color-trevi-light:    #fbeaea;
    --color-immovlan:       #e07b00;
    --color-immovlan-hover: #b56200;
    --color-immovlan-light: #fff3e0;
    --color-tag-bg:         #f3f4f6;
    --color-tag-text:       #374151;
    --radius:               10px;
    --shadow-sm:            0 1px 3px rgba(0,0,0,0.08);
    --shadow-md:            0 4px 12px rgba(0,0,0,0.10);
}
* { box-sizing: border-box; }
body {
    margin: 0; padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
}

/* ── Action bar ── */
.action-bar {
    position: sticky; top: 0; z-index: 1000;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-md);
    padding: 10px 20px;
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.action-bar-brand { display: flex; flex-direction: column; gap: 1px; }
.brand-title {
    font-size: 0.95em; font-weight: 700; color: var(--color-text); line-height: 1.2;
}
.brand-subtitle {
    font-size: 0.72em; color: var(--color-text-muted); letter-spacing: 0.2px;
}
.btn-search-primary {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    background: var(--color-immoweb); color: #fff;
    border: none; border-radius: var(--radius);
    padding: 14px 40px; font-size: 1em; font-weight: 700;
    cursor: pointer; transition: background 0.15s, transform 0.1s;
    box-shadow: var(--shadow-md); white-space: nowrap;
}
.btn-search-primary:hover   { background: var(--color-immoweb-hover); transform: translateY(-1px); }
.btn-search-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
/* ── Result links (tab Résultats) ── */
.results-links {
    display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
}
.result-link {
    flex: 1; min-width: 180px;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    padding: 18px 20px; border-radius: var(--radius);
    text-decoration: none; font-size: 1em; font-weight: 700;
    box-shadow: var(--shadow-sm); transition: background 0.15s, transform 0.1s;
}
.result-link:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.result-link-immoweb  { background: var(--color-immoweb);  color: #fff; }
.result-link-immoweb:hover  { background: var(--color-immoweb-hover); }
.result-link-trevi    { background: var(--color-trevi);    color: #fff; }
.result-link-trevi:hover    { background: var(--color-trevi-hover); }
.result-link-immovlan { background: var(--color-immovlan); color: #fff; }
.result-link-immovlan:hover { background: var(--color-immovlan-hover); }

/* ── Params generate button ── */
.params-generate {
    display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 20px 0 4px;
}
.search-hint {
    margin: 0; font-size: 0.82em; color: var(--color-text-muted); text-align: center;
}
.search-progress {
    margin: 0; font-size: 0.82em; color: var(--color-immoweb);
    text-align: center; font-style: italic;
}
.btn-logo {
    width: 20px; height: 20px; border-radius: 4px;
    background: rgba(255,255,255,0.25);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.78em; font-weight: 800;
}
#search-status {
    font-size: 0.82em; color: #c0392b;
    padding: 4px 10px; background: #fbeaea;
    border-radius: 6px; margin-left: auto;
}
[hidden] { display: none !important; }
.spinner {
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
    vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }


/* ── Tabs ── */
.main { max-width: 900px; margin: 0 auto; padding: 20px 20px 40px; }
.tabs {
    display: flex; gap: 4px;
    border-bottom: 2px solid var(--color-border);
    margin-bottom: 20px;
}
.tab-btn {
    padding: 8px 18px; border: none; background: none;
    font-size: 0.88em; font-weight: 600; color: var(--color-text-muted);
    cursor: pointer; border-bottom: 2px solid transparent;
    margin-bottom: -2px; transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover  { color: var(--color-text); }
.tab-btn.active { color: var(--color-immoweb); border-bottom-color: var(--color-immoweb); }

/* ── Params tab ── */
.params-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.params-card {
    background: var(--color-surface); border-radius: var(--radius);
    padding: 16px; box-shadow: var(--shadow-sm); border: 1px solid var(--color-border);
}
.params-card-title {
    font-size: 0.72em; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.8px; color: var(--color-text-muted); margin: 0 0 12px;
}
.param-row {
    display: flex; justify-content: space-between; align-items: flex-start;
    padding: 7px 0; border-bottom: 1px solid #f3f4f6; gap: 12px;
}
.param-row:last-child { border-bottom: none; }
.param-label { color: var(--color-text-muted); font-size: 0.85em; white-space: nowrap; padding-top: 4px; }
.param-value { font-size: 0.85em; text-align: right; flex: 1; }
.form-input {
    width: 100%; padding: 6px 10px; border: 1px solid var(--color-border);
    border-radius: 6px; font-size: 0.85em; color: var(--color-text);
    background: var(--color-bg); outline: none; transition: border-color 0.15s;
}
.form-input:focus { border-color: var(--color-immoweb); background: #fff; box-shadow: 0 0 0 3px var(--color-immoweb-light); }
.form-input-sm { width: 80px; }
.section-compass { display: flex; align-items: center; gap: 16px; }
.section-compass > div { flex: 1; }

/* ── Filter chips ── */
.filter-label {
    font-size: 0.72em; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.8px; color: var(--color-text-muted);
    display: block; margin-bottom: 8px;
}
.filter-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.filter-sep  { color: var(--color-text-muted); font-size: 0.85em; }
.filter-unit { font-size: 0.82em; color: var(--color-text-muted); }
.filter-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 14px; }
.filter-chip {
    display: inline-flex; align-items: center; padding: 3px 10px;
    border-radius: 20px; border: 1px solid var(--color-border);
    background: var(--color-bg); cursor: pointer;
    font-size: 0.78em; font-weight: 500; color: var(--color-text-muted);
    transition: all 0.12s; user-select: none;
}
.filter-chip input[type="checkbox"] { display: none; }
.filter-chip:has(input:checked) {
    background: var(--color-immoweb-light); color: var(--color-immoweb);
    border-color: var(--color-immoweb);
}
.filter-footer {
    display: flex; justify-content: flex-end;
    padding-top: 10px; border-top: 1px solid var(--color-border);
}
.filter-reset {
    background: none; border: 1px solid var(--color-border); border-radius: 6px;
    padding: 6px 14px; font-size: 0.82em; color: var(--color-text-muted);
    cursor: pointer; transition: all 0.12s;
}
.filter-reset:hover { border-color: var(--color-text-muted); color: var(--color-text); }
/* ── EPC slider ── */
.epc-slider-wrap { margin-bottom: 14px; user-select: none; }

.epc-track-container {
    position: relative;
    height: 20px; /* tall enough to show 16px thumbs */
    margin: 4px 0 6px;
}

.epc-track-bg {
    position: absolute;
    top: 50%; left: 0; right: 0; height: 6px;
    transform: translateY(-50%);
    border-radius: 3px;
    background: linear-gradient(to right,
        #1565C0 0%,   #1565C0 12.5%,
        #2E7D32 12.5%, #43A047 25%,
        #43A047 25%,   #66BB6A 37.5%,
        #66BB6A 37.5%, #AFB42B 50%,
        #AFB42B 50%,   #F9A825 62.5%,
        #F9A825 62.5%, #EF6C00 75%,
        #EF6C00 75%,   #D84315 87.5%,
        #D84315 87.5%, #B71C1C 100%
    );
}

.epc-inactive {
    position: absolute;
    top: 50%; height: 6px;
    transform: translateY(-50%);
    background: rgba(240, 242, 245, 0.88);
    pointer-events: none;
    border-radius: 3px;
}

.epc-range {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    pointer-events: none;
    margin: 0; padding: 0;
}
.epc-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    pointer-events: all;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--thumb-color, #555);
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.35);
    cursor: pointer;
    transition: transform 0.1s;
}
.epc-range:active::-webkit-slider-thumb { transform: scale(1.2); }
.epc-range::-moz-range-track  { background: transparent; border: none; }
.epc-range::-moz-range-thumb {
    pointer-events: all;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--thumb-color, #555);
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.35);
    cursor: pointer;
}

.epc-scale-labels {
    display: flex;
    justify-content: space-between;
    padding: 0 7px; /* ~half thumb width to align labels with thumb centres */
    margin-bottom: 3px;
}
.epc-scale-labels span {
    font-size: 0.64em; font-weight: 600;
    color: var(--color-text-muted);
    line-height: 1; text-align: center;
    width: 0; overflow: visible; white-space: nowrap;
}

.epc-groups {
    display: flex;
    padding: 0 7px;
    margin-bottom: 4px;
}
.epc-group {
    font-size: 0.64em; text-align: center;
    color: var(--color-text-muted); opacity: 0.4;
    transition: opacity 0.15s, color 0.15s, font-weight 0.15s;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.epc-group:nth-child(1) { width: 22.22%; }
.epc-group:nth-child(2) { width: 22.22%; }
.epc-group:nth-child(3) { width: 33.33%; }
.epc-group:nth-child(4) { width: 22.22%; }
.epc-group--active { opacity: 1; font-weight: 700; color: var(--color-text); }

.epc-sel-label {
    font-size: 0.74em; text-align: center;
    color: var(--color-text-muted); font-weight: 500;
}

.provider-badge {
    display: inline-block; font-size: 0.7em; font-weight: 500;
    padding: 1px 5px; border-radius: 3px; margin-left: 5px; vertical-align: middle;
    background: #f3f4f6; color: var(--color-text-muted);
    cursor: help; position: relative; white-space: nowrap;
}
.provider-badge::after {
    content: attr(data-tooltip);
    position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
    background: #1a1d23; color: #fff; font-size: 0.82em; font-weight: 400;
    padding: 4px 8px; border-radius: 5px; white-space: nowrap;
    opacity: 0; pointer-events: none; transition: opacity 0.15s;
}
.provider-badge:hover::after { opacity: 1; }
.tag {
    display: inline-block; background: var(--color-tag-bg); color: var(--color-tag-text);
    padding: 2px 8px; border-radius: 5px; font-size: 0.8em; font-weight: 500; margin: 1px 2px;
}

/* ── Map tab ── */
.map-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 8px; flex-wrap: wrap; gap: 8px;
}
.map-title {
    font-size: 0.95em; font-weight: 700; color: var(--color-text);
}
.map-legend {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.78em; color: var(--color-text-muted);
}
.map-legend-dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: #2a84cb; flex-shrink: 0;
}
#map { height: 520px; border-radius: var(--radius); border: 1px solid var(--color-border); }

/* ── Cities toggle + panel ── */
.cities-toggle {
    display: flex; align-items: center; gap: 6px;
    margin-top: 12px; padding: 0; background: none; border: none;
    font-size: 0.82em; color: var(--color-text-muted); cursor: pointer;
    text-decoration: underline; text-underline-offset: 3px;
    text-decoration-color: transparent; transition: color 0.15s, text-decoration-color 0.15s;
}
.cities-toggle:hover { color: var(--color-text); text-decoration-color: var(--color-border); }
.cities-toggle-chevron {
    font-size: 1.1em; display: inline-block; transition: transform 0.2s;
}
.cities-panel {
    margin-top: 8px; background: var(--color-surface);
    border: 1px solid var(--color-border); border-radius: var(--radius);
    overflow: hidden;
}
.cities-filter-wrap {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 14px; border-bottom: 1px solid var(--color-border);
    background: #fff;
}
.cities-filter-icon { font-size: 0.9em; flex-shrink: 0; opacity: 0.5; }
.cities-filter-input {
    flex: 1; border: none; outline: none; background: transparent;
    font-size: 0.85em; color: var(--color-text);
}
.cities-filter-input::placeholder { color: var(--color-text-muted); }
.city-count {
    background: var(--color-tag-bg); color: var(--color-text-muted);
    font-size: 0.75em; font-weight: 600; padding: 2px 8px; border-radius: 20px;
}
.city-list { list-style: none; padding: 0; margin: 0; }
.city-item {
    display: flex; align-items: center; padding: 9px 18px;
    border-bottom: 1px solid #f9fafb; gap: 12px;
}
.city-item:last-child { border-bottom: none; }
.city-item:hover { background: #fafbfc; }
.city-name   { flex: 1; font-size: 0.88em; font-weight: 500; }
.city-links  { display: flex; gap: 6px; }
.city-link   { font-size: 0.75em; font-weight: 600; padding: 3px 10px; border-radius: 5px; text-decoration: none; transition: opacity 0.15s; }
.city-link:hover { opacity: 0.8; }
.city-link-immoweb  { background: var(--color-immoweb-light);  color: var(--color-immoweb); }
.city-link-trevi    { background: var(--color-trevi-light);    color: var(--color-trevi); }
.city-link-immovlan { background: var(--color-immovlan-light); color: var(--color-immovlan); }
.empty-state { padding: 40px; text-align: center; color: var(--color-text-muted); font-size: 0.88em; }

/* ── Footer ── */
.footer {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 28px 20px; font-size: 0.75em; color: var(--color-text-muted);
    border-top: 1px solid var(--color-border);
}
.footer-repo {
    color: var(--color-text-muted); text-decoration: none;
    display: inline-flex; align-items: center; gap: 6px;
    font-weight: 500; transition: color 0.15s;
}
.footer-repo:hover { color: var(--color-text); }
.footer-meta {
    font-size: 0.92em; letter-spacing: 0.02em; opacity: 0.6;
}

/* ── Lang switcher ── */
.lang-switcher { display: flex; gap: 4px; margin-left: auto; }
.lang-btn {
    padding: 4px 10px; border-radius: 6px; border: 1px solid var(--color-border);
    font-size: 0.78em; font-weight: 600; color: var(--color-text-muted);
    text-decoration: none; background: none; transition: all 0.12s;
}
.lang-btn:hover { border-color: var(--color-immoweb); color: var(--color-immoweb); }
.lang-btn.active { background: var(--color-immoweb); color: #fff; border-color: var(--color-immoweb); }

/* ── Responsive ── */
@media (max-width: 640px) {
    .params-grid { grid-template-columns: 1fr; }
    .results-links { flex-direction: column; }
    .result-link { min-width: unset; }
    .city-links { flex-wrap: wrap; }
}
