@font-face {
  font-family: 'Chewy';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/chewy-latin.woff2') format('woff2');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/inter-latin.woff2') format('woff2');
}

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

:root {
    --color-primary: #F9D06C;
    --color-primary-dark: #E5B84A;
    --color-primary-light: #FCE8A6;
    --color-header: #66A6DE;
    --color-header-dark: #4D8BC2;
    --color-accent: #52B788;
    --color-cream: #FDFAF3;
    --color-cream-2: #F5EFE0;
    --color-border: #E8DCC0;
    --color-text: #2B2418;
    --color-muted: #6B5D4A;
    --color-warm: #A7956E;
    --color-bio: #2D6A4F;
    --color-confirmed: #2D6A4F;
    --color-probable: #B26A3D;
    --color-none: #A7956E;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.12);
    --shadow-lg: 0 20px 60px rgba(0,0,0,0.3);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--color-cream);
    color: var(--color-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Scrollbar harmonisée */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--color-cream-2);
}

::-webkit-scrollbar-thumb {
    background: var(--color-warm);
    border-radius: 5px;
    border: 2px solid var(--color-cream-2);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-primary);
}

header {
    background: var(--color-header);
    color: white;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    position: relative;
    z-index: 50;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

header .logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    flex-shrink: 0;
}

header .logo-img {
    height: 20px;
    width: auto;
    max-width: 120px;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

footer .footer-logo {
    display: flex;
    align-items: center;
    font-family: 'Chewy', cursive, sans-serif;
    font-size: 1rem;
    color: white;
    gap: 8px;
    text-decoration: none;
}

footer .footer-logo-img {
    height: 20px;
    width: auto;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

header nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

header nav a {
    color: white;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
    white-space: nowrap;
}

header nav a:hover {
    background: rgba(255,255,255,0.2);
}

header .btn-primary,
.btn-primary {
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 9px 16px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
    box-shadow: 0 2px 0 var(--color-primary-dark);
}

header .btn-primary:hover,
.btn-primary:hover {
    background: var(--color-primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 3px 0 var(--color-primary-dark);
}

header .btn-primary:active,
.btn-primary:active {
    transform: translateY(1px);
    box-shadow: none;
}

header h1,
header .subtitle {
    display: none;
}

/* Filter bar */
#filter-bar {
    background: white;
    border-bottom: 1px solid var(--color-border);
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.filter-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.filter-row-secondary {
    align-items: center;
}

.filter-group {
    flex: 1;
    min-width: 180px;
    position: relative;
}

.filter-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-muted);
    margin-bottom: 4px;
}

.filter-group select,
.search-input-wrapper input[type="text"],
.modal-content input[type="text"],
.modal-content input[type="email"],
.modal-content input[type="tel"],
.modal-content textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    background: white;
    color: var(--color-text);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
}

.filter-group select {
    cursor: pointer;
    appearance: auto;
}

.filter-group select:focus,
.search-input-wrapper input[type="text"]:focus,
.modal-content input:focus,
.modal-content textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.12);
}

.search-input-wrapper {
    position: relative;
}

.search-input-wrapper input[type="text"] {
    padding: 9px 32px 9px 12px;
}

.clear-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--color-warm);
    cursor: pointer;
    padding: 2px 6px;
    line-height: 1;
    border-radius: var(--radius-sm);
}

.clear-btn:hover {
    color: var(--color-text);
    background: var(--color-cream-2);
}

/* Checkbox filters */
.filter-bio,
.filter-confirmed {
    flex: 0 0 auto;
    min-width: auto;
    display: flex;
    align-items: center;
}

.bio-label,
.confirmed-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text);
    padding: 6px 10px;
    border-radius: var(--radius-md);
    background: var(--color-cream);
    border: 1px solid var(--color-border);
    transition: background 0.2s, border-color 0.2s;
    user-select: none;
}

.bio-label:hover,
.confirmed-label:hover {
    background: #EDF6E6;
    border-color: var(--color-primary-light);
}

.bio-label input[type=checkbox],
.confirmed-label input[type=checkbox] {
    width: 16px;
    height: 16px;
    accent-color: var(--color-bio);
    cursor: pointer;
}

.filter-badge {
    display: inline-block;
    background: var(--color-primary);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 12px;
    white-space: nowrap;
}

.filter-badge.hidden {
    display: none;
}

.btn-locate {
    margin-bottom: 0;
    width: auto;
    white-space: nowrap;
}

/* Radius slider */
#radius-group {
    flex: 1 1 200px;
    min-width: 180px;
}

.radius-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.radius-row input[type="range"] {
    flex: 1;
    accent-color: var(--color-primary);
    cursor: pointer;
}

#radius-value {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-primary);
    min-width: 55px;
}

/* App layout */
#app {
    display: flex;
    flex: 1;
    min-height: 0;
    height: calc(100vh - 220px);
}

#sidebar {
    width: 380px;
    min-width: 380px;
    background: white;
    overflow-y: auto;
    padding: 16px;
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
}

.search-box {
    margin-bottom: 12px;
    position: relative;
}

.search-box label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-muted);
    margin-bottom: 4px;
}

.search-box input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box input[type="text"]:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.12);
}

.results-count {
    font-size: 0.8rem;
    color: var(--color-muted);
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--color-border);
}

.gaec-list {
    list-style: none;
    flex: 1;
    overflow-y: auto;
}

.gaec-item {
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.gaec-item:hover {
    background: #F1F8EA;
    border-color: var(--color-primary-light);
    transform: translateX(2px);
}

.gaec-item .gaec-nom {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--color-primary-dark);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.gaec-item .gaec-meta {
    font-size: 0.8rem;
    color: var(--color-muted);
    margin-top: 2px;
}

.gaec-item .gaec-type {
    display: inline-block;
    background: #E9F5DE;
    color: var(--color-primary-dark);
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 12px;
    margin-top: 4px;
    font-weight: 500;
}

.gaec-item .gaec-distance {
    float: right;
    font-size: 0.75rem;
    color: var(--color-primary);
    font-weight: 600;
}

#map {
    flex: 1;
    min-width: 0;
    background: #E5E3DF;
}

/* Autocomplete */
.autocomplete-items {
    position: absolute;
    z-index: 100;
    width: 100%;
    background: white;
    border: 1px solid var(--color-border);
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    max-height: 200px;
    overflow-y: auto;
    display: none;
    box-shadow: var(--shadow-md);
}

.autocomplete-items .item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.15s;
}

.autocomplete-items .item:hover {
    background: #F1F8EA;
}

.autocomplete-items .item.active {
    background: #E9F5DE;
    color: var(--color-primary-dark);
    font-weight: 500;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(43, 36, 24, 0.55);
    backdrop-filter: blur(2px);
}

.modal-content {
    background: white;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 550px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 24px;
    position: relative;
    z-index: 1;
    box-shadow: var(--shadow-lg);
}

.modal-content.modal-small {
    max-width: 480px;
}

.modal-content h2 {
    color: var(--color-primary-dark);
    font-size: 1.35rem;
    margin-bottom: 6px;
}

.modal-subtitle {
    color: var(--color-muted);
    font-size: 0.9rem;
    margin-bottom: 16px;
    line-height: 1.45;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 1.6rem;
    cursor: pointer;
    color: var(--color-warm);
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s, color 0.2s;
}

.modal-close:hover {
    color: var(--color-text);
    background: var(--color-cream-2);
}

.modal-content form label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-muted);
    margin: 12px 0 4px;
}

.modal-content form input,
.modal-content form textarea {
    margin-bottom: 2px;
}

.modal-content form textarea {
    resize: vertical;
    min-height: 70px;
}

.modal-content .btn-submit {
    margin-top: 16px;
    width: 100%;
    padding: 11px;
    font-size: 0.95rem;
}

/* Form feedback */
.form-feedback {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 500;
    text-align: center;
}

.form-feedback.success {
    background: #E9F5DE;
    color: var(--color-primary-dark);
    border: 1px solid #B7D6A2;
}

.form-feedback.error {
    background: #FCE8E6;
    color: #9A3B32;
    border: 1px solid #E7B3AD;
}

.form-feedback.hidden {
    display: none;
}

/* Detail modal */
.detail-nom {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--color-primary-dark);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.detail-type {
    display: inline-block;
    background: #E9F5DE;
    color: var(--color-primary-dark);
    padding: 3px 12px;
    border-radius: 12px;
    font-size: 0.8rem;
    margin-bottom: 12px;
    font-weight: 500;
}

.detail-info {
    margin-bottom: 16px;
}

.detail-info p {
    font-size: 0.9rem;
    color: var(--color-muted);
    margin-bottom: 4px;
}

.detail-info p strong {
    color: var(--color-text);
}

.detail-produits h3 {
    font-size: 1rem;
    color: var(--color-primary-dark);
    margin-bottom: 8px;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 4px;
}

.produit-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--color-cream);
    font-size: 0.85rem;
}

.produit-item .produit-nom {
    font-weight: 500;
}

.produit-item .produit-prix {
    color: var(--color-primary);
    font-weight: 600;
}

.detail-desc {
    font-style: italic;
    color: var(--color-muted);
    margin-top: 6px;
    line-height: 1.5;
}

.detail-link {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
}

.detail-link:hover {
    text-decoration: underline;
    color: var(--color-primary-dark);
}

.detail-actions {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border);
    display: flex;
    justify-content: flex-end;
}

.itinerary-wrapper {
    position: relative;
}

.btn-itinerary {
    padding: 10px 20px;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
    font-weight: 600;
}

.btn-itinerary:hover {
    background: var(--color-primary-dark);
}

.itinerary-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    min-width: 180px;
    z-index: 10;
    overflow: hidden;
}

.itinerary-menu.hidden {
    display: none;
}

.itinerary-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.15s;
}

.itinerary-option:hover {
    background: #F1F8EA;
}

.itinerary-icon {
    font-size: 1.1rem;
}

.produit-cat {
    color: var(--color-warm);
    font-size: 0.75rem;
    font-weight: 400;
}

/* Leaflet popup harmonized */
.leaflet-popup-content {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.9rem;
    line-height: 1.4;
}

.leaflet-popup-content .popup-nom {
    font-weight: 700;
    color: var(--color-primary-dark);
    font-size: 1rem;
}

.leaflet-popup-content .popup-commune {
    color: var(--color-muted);
    font-size: 0.85rem;
}

.leaflet-popup-content .popup-type {
    display: inline-block;
    background: #E9F5DE;
    color: var(--color-primary-dark);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    margin-top: 4px;
    font-weight: 500;
}

.leaflet-popup-content .popup-btn {
    display: block;
    margin-top: 8px;
    padding: 7px 12px;
    background: var(--color-primary);
    color: white;
    text-align: center;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 0.85rem;
    cursor: pointer;
    border: none;
    width: 100%;
    font-weight: 500;
    transition: background 0.2s;
}

.leaflet-popup-content .popup-btn:hover {
    background: var(--color-primary-dark);
}

/* Badges */
.badge-confirmed,
.badge-probable,
.badge-none,
.badge-bio {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 4px;
    vertical-align: middle;
    line-height: 1;
}

.badge-confirmed {
    background: var(--color-confirmed);
}

.badge-bio {
    background: var(--color-bio);
}

.badge-probable {
    background: var(--color-probable);
}

.badge-none {
    background: var(--color-none);
}

/* In sidebar list */
.gaec-nom .badge-confirmed,
.gaec-nom .badge-probable,
.gaec-nom .badge-none,
.gaec-nom .badge-bio {
    font-size: 0.65rem;
    padding: 1px 5px;
}

/* In detail modal */
.detail-nom .badge-confirmed,
.detail-nom .badge-probable,
.detail-nom .badge-none,
.detail-nom .badge-bio {
    font-size: 0.75rem;
    padding: 2px 8px;
}

/* Footer */
footer {
    background: var(--color-header);
    color: white;
    padding: 28px 24px;
    margin-top: auto;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
}

.footer-logo {
    font-family: 'Chewy', cursive, sans-serif;
    font-size: 1.4rem;
    letter-spacing: 0.5px;
}

.footer-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.footer-nav a {
    color: white;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

.footer-nav a:hover {
    background: rgba(255,255,255,0.2);
}

.footer-copy {
    font-size: 0.8rem;
    opacity: 0.9;
    margin-top: 4px;
}

/* Responsive */
@media (max-width: 900px) {
    header {
        padding: 10px 16px;
    }

    header nav {
        gap: 6px;
    }

    header nav a {
        font-size: 0.85rem;
        padding: 5px 8px;
    }

    header .btn-primary {
        padding: 7px 12px;
        font-size: 0.85rem;
    }
}

@media (max-width: 768px) {
    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 12px 14px;
    }

    header .logo {
        font-size: 1.35rem;
    }

    header nav {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 6px;
    }

    header nav a,
    header .btn-primary {
        font-size: 0.8rem;
        padding: 5px 8px;
    }

    #filter-bar {
        padding: 10px 12px;
    }

    .filter-row {
        flex-direction: column;
        gap: 8px;
        align-items: stretch;
    }

    .filter-group {
        min-width: 100%;
    }

    .filter-row-secondary {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }

    #radius-group {
        order: 1;
        flex: 1 1 100%;
    }

    #app {
        flex-direction: column;
        height: calc(100vh - 240px);
    }

    #sidebar {
        width: 100%;
        min-width: 100%;
        flex: 0 0 45%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
    }

    #map {
        flex: 1;
        height: auto;
        min-height: 0;
    }

    .modal-content {
        width: 95%;
        max-height: 85vh;
        padding: 16px;
    }

    .modal-content h2 {
        font-size: 1.15rem;
    }

    .itinerary-menu {
        right: auto;
        left: 0;
    }

    footer {
        padding: 20px 16px;
    }

    .footer-logo {
        font-size: 1.2rem;
    }

    .footer-nav a {
        font-size: 0.85rem;
        padding: 5px 10px;
    }
}

@media (max-width: 480px) {
    header nav a {
        padding: 4px 6px;
        font-size: 0.75rem;
    }

    header .btn-primary {
        padding: 5px 10px;
        font-size: 0.75rem;
    }

    #app {
        height: calc(100vh - 220px);
    }

    #sidebar {
        flex: 0 0 50%;
    }
}

/* Hidden utility */
.hidden {
    display: none !important;
}
