/* ==========================================================================
   Carte Dureté de l'Eau - Wallonie
   ========================================================================== */

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

:root {
    --primary: #0a2540;
    --secondary: #1a73e8;
    --accent: #00c9a7;
    --soft: #e8f4f8;
    --text: #1e293b;
    --text-light: #64748b;
    --white: #ffffff;
    --shadow: 0 4px 24px rgba(10, 37, 64, 0.12);
    --shadow-hover: 0 8px 32px rgba(10, 37, 64, 0.18);
    --radius: 16px;
    --radius-sm: 8px;
}

html, body {
    height: 100%;
    font-family: "DM Sans", -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #f0f9ff 0%, #e8f4f8 100%);
    color: var(--text);
    overflow: hidden;
}

/* Layout */
.container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 100vh;
}

.main-content {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
}

/* Header */
.header {
    background: var(--white);
    padding: 10px 24px;
    box-shadow: var(--shadow);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-icon svg {
    width: 26px;
    height: 26px;
    fill: var(--white);
}

.title-group h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}

.title-group span {
    font-size: 0.75rem;
    color: var(--text-light);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Search */
.search-section {
    flex: 1;
    max-width: 500px;
    min-width: 280px;
}

.search-wrapper {
    position: relative;
}

.search-input {
    width: 100%;
    padding: 14px 20px 14px 48px;
    font-size: 0.95rem;
    font-family: inherit;
    border: 2px solid #e2e8f0;
    border-radius: 50px;
    background: var(--soft);
    color: var(--text);
    transition: all 0.3s ease;
    outline: none;
}

.search-input:focus {
    border-color: var(--secondary);
    background: var(--white);
    box-shadow: 0 0 0 4px rgba(26, 115, 232, 0.1);
}

.search-input::placeholder {
    color: var(--text-light);
}

.search-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--text-light);
    pointer-events: none;
}

.search-clear {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border: none;
    background: #e2e8f0;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.search-clear:hover {
    background: #cbd5e1;
}

.search-clear svg {
    width: 14px;
    height: 14px;
    color: var(--text-light);
}

/* Autocomplete */
.autocomplete-list {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hover);
    max-height: 320px;
    overflow-y: auto;
    z-index: 1001;
    display: none;
}

.autocomplete-list.active {
    display: block;
}

.autocomplete-item {
    padding: 14px 20px;
    cursor: pointer;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.2s;
}

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

.autocomplete-item:hover {
    background: var(--soft);
}

.autocomplete-item svg {
    width: 18px;
    height: 18px;
    color: var(--secondary);
    flex-shrink: 0;
    margin-top: 2px;
}

.autocomplete-content {
    flex: 1;
    min-width: 0;
}

.autocomplete-main {
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.autocomplete-sub {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 2px;
}

.autocomplete-loading,
.autocomplete-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-light);
}

/* Map */
#map {
    flex: 1;
    z-index: 1;
}

.leaflet-control-zoom {
    border: none !important;
    box-shadow: var(--shadow) !important;
    border-radius: var(--radius-sm) !important;
    overflow: hidden;
}

.leaflet-control-zoom a {
    background: var(--white) !important;
    color: var(--primary) !important;
    border: none !important;
    width: 36px !important;
    height: 36px !important;
    line-height: 36px !important;
    font-size: 18px !important;
}

.leaflet-control-zoom a:hover {
    background: var(--soft) !important;
}

.search-marker {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Info Panel */
.info-panel {
    position: absolute;
    right: 20px;
    top: 20px;
    width: 380px;
    max-width: calc(100% - 40px);
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hover);
    z-index: 1000;
    overflow: hidden;
    transform: translateX(calc(100% + 40px));
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.info-panel.active {
    transform: translateX(0);
}

.info-panel-header {
    background: linear-gradient(135deg, var(--primary) 0%, #0f3a5c 100%);
    color: var(--white);
    padding: 15px;
    position: relative;
}

.info-panel-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.info-panel-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

.info-panel-close svg {
    width: 18px;
    height: 18px;
    color: var(--white);
}

.zone-name {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 4px;
    padding-right: 40px;
}

.zone-code {
    font-size: 0.8rem;
    opacity: 0.7;
    font-family: "Space Mono", monospace;
}

.info-panel-body {
    padding: 20px;
    max-height: calc(100vh - 280px);
    overflow-y: auto;
}

.info-section {
    margin-bottom: 24px;
}

.info-section:last-child {
    margin-bottom: 0;
}

.info-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 10px 0;
    border-bottom: 1px solid #f1f5f9;
}

.info-label {
    color: var(--text-light);
    font-size: 0.9rem;
    flex-shrink: 1;
}

.info-value {
    font-weight: 500;
    color: var(--text);
    text-align: right;
    max-width: 65%;
    word-wrap: break-word;
}

.info-value a {
    color: var(--secondary);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.info-value a:hover {
    text-decoration: underline;
}

.info-value a svg {
    flex-shrink: 0;
}

/* Dureté Display */
.durete-display {
    text-align: center;
    margin-bottom: 16px;
}

.durete-value-large {
    font-family: "Space Mono", monospace;
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
}

.durete-value-large.tres-douce {
    color: #22c55e;
}
.durete-value-large.douce {
    color: #84cc16;
}
.durete-value-large.moyenne {
    color: #eab308;
}
.durete-value-large.dure {
    color: #f97316;
}
.durete-value-large.tres-dure {
    color: #ef4444;
}

#dureteValue {
    font-size: 2em;
    font-weight: bolder;
}

.durete-label {
    font-size: 0.95rem;
    color: #64748b;
    font-weight: 500;
}

/* Dureté Gauge avec repères */
.durete-gauge-container {
    background: #f8fafc;
    border-radius: var(--radius-sm);
    padding: 16px;
}

.durete-gauge {
    position: relative;
    height: 12px;
    background: linear-gradient(
        to right,
        #22c55e 0%,
        #22c55e 14.5%,
        #84cc16 14.5%,
        #84cc16 27.3%,
        #eab308 27.3%,
        #eab308 45.5%,
        #f97316 45.5%,
        #f97316 63.6%,
        #ef4444 63.6%,
        #ef4444 100%
    );
    border-radius: 6px;
    margin-bottom: 8px;
}

.durete-gauge-fill {
    display: none;
}

.durete-marker {
    position: absolute;
    top: -4px;
    width: 4px;
    height: 20px;
    background: var(--primary);
    border-radius: 2px;
    transform: translateX(-50%);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    display: none;
}

.durete-scale {
    position: relative;
    height: 20px;
    margin-bottom: 4px;
}

.durete-tick {
    position: absolute;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: var(--text-light);
    font-family: "Space Mono", monospace;
}

.durete-tick::before {
    content: "";
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 1px;
    height: 6px;
    background: #cbd5e1;
}

.durete-tick span {
    display: block;
    margin-top: 2px;
}

.durete-categories {
    display: flex;
    justify-content: space-between;
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: 8px;
}

.durete-categories span {
    flex: 1;
    text-align: center;
}

.cat-tres-douce {
    color: #22c55e;
    flex: 0.145 !important;
    text-align: left !important;
}
.cat-douce {
    color: #84cc16;
    flex: 0.128 !important;
}
.cat-moyenne {
    color: #eab308;
    flex: 0.182 !important;
}
.cat-dure {
    color: #f97316;
    flex: 0.181 !important;
}
.cat-tres-dure {
    color: #ef4444;
    flex: 0.364 !important;
    text-align: right !important;
}

/* Precaution Banner */
.precaution-banner {
    margin-top: 16px;
    display: none;
}

.precaution-banner p {
    font-size: 0.85rem;
    color: #64748b;
    line-height: 1.4;
}

/* Legend */
.legend {
    position: absolute;
    left: 20px;
    bottom: 30px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 20px;
    z-index: 999;
    max-width: 200px;
}

.legend-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.legend-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
    color: var(--text);
}

.legend-color {
    width: 20px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

/* Loading */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    transition: opacity 0.3s;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--soft);
    border-top-color: var(--secondary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        padding: 12px 16px;
        gap: 12px;
    }

    .title-group h1 {
        font-size: 1rem;
    }

    .search-section {
        flex: 1 1 100%;
        max-width: none;
        order: 3;
    }

    .info-panel {
        right: 10px;
        left: 10px;
        width: auto;
        max-width: none;
        top: auto;
        bottom: 10px;
        max-height: 50vh;
        transform: translateY(calc(100% + 20px));
    }

    .info-panel.active {
        transform: translateY(0);
    }

    .info-panel-body {
        max-height: calc(50vh - 100px);
    }

    .legend {
        left: 10px;
        bottom: 10px;
        padding: 12px 14px;
        max-width: 180px;
    }

    .legend-title {
        font-size: 0.7rem;
    }

    .legend-item {
        font-size: 0.7rem;
    }
}

@media (max-width: 480px) {
    .title-group h1 {
        font-size: 0.9rem;
    }

    .title-group span {
        display: none;
    }

    .logo-icon {
        width: 38px;
        height: 38px;
    }

    .durete-value-large {
        font-size: 2rem;
    }

    .durete-categories {
        font-size: 0.55rem;
    }
}
