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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f5f5f5;
    color: #333;
}

header {
    background: linear-gradient(135deg, #2d6a4f, #40916c);
    color: white;
    padding: 16px 24px;
    text-align: center;
}

header h1 {
    font-size: 1.6rem;
    font-weight: 700;
}

header .subtitle {
    font-size: 0.9rem;
    opacity: 0.85;
    margin-top: 2px;
}

#filter-bar {
    background: white;
    border-bottom: 1px solid #ddd;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

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

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

.filter-group {
    flex: 1;
    position: relative;
}

.filter-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 4px;
}

.filter-group select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 0.9rem;
    background: white;
    color: #333;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
    appearance: auto;
}

.filter-group select:focus {
    border-color: #40916c;
    box-shadow: 0 0 0 2px rgba(64, 145, 108, 0.15);
}

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

.search-input-wrapper input[type="text"] {
    width: 100%;
    padding: 9px 32px 9px 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.search-input-wrapper input[type="text"]:focus {
    border-color: #40916c;
    box-shadow: 0 0 0 2px rgba(64, 145, 108, 0.15);
}

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

.clear-btn:hover {
    color: #333;
    background: #f0f0f0;
}

.filter-badge {
    display: inline-block;
    background: #40916c;
    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;
}

#app {
    display: flex;
    height: calc(100vh - 140px);
}

#sidebar {
    width: 380px;
    min-width: 380px;
    background: white;
    overflow-y: auto;
    padding: 16px;
    border-right: 1px solid #ddd;
    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: #555;
    margin-bottom: 4px;
}

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

.search-box input[type="text"]:focus {
    border-color: #40916c;
    box-shadow: 0 0 0 2px rgba(64, 145, 108, 0.15);
}

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

.radius-row input[type="range"] {
    flex: 1;
    accent-color: #40916c;
}

#radius-value {
    font-size: 0.85rem;
    font-weight: 600;
    color: #40916c;
    min-width: 50px;
}

.btn-primary {
    width: 100%;
    padding: 10px;
    background: #2d6a4f;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 12px;
}

.btn-primary:hover {
    background: #1b4332;
}

.results-count {
    font-size: 0.8rem;
    color: #777;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}

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

.gaec-item {
    padding: 10px 12px;
    border: 1px solid #eee;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.gaec-item:hover {
    background: #f0fdf4;
    border-color: #40916c;
}

.gaec-item .gaec-nom {
    font-weight: 600;
    font-size: 0.95rem;
    color: #2d6a4f;
}

.gaec-item .gaec-meta {
    font-size: 0.8rem;
    color: #666;
    margin-top: 2px;
}

.gaec-item .gaec-type {
    display: inline-block;
    background: #d8f3dc;
    color: #2d6a4f;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 12px;
    margin-top: 4px;
}

.gaec-item .gaec-distance {
    float: right;
    font-size: 0.75rem;
    color: #40916c;
    font-weight: 600;
}

#map {
    flex: 1;
}

.autocomplete-items {
    position: absolute;
    z-index: 100;
    width: 100%;
    background: white;
    border: 1px solid #ccc;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 200px;
    overflow-y: auto;
    display: none;
}

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

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

.autocomplete-items .item.active {
    background: #d8f3dc;
}

.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(0, 0, 0, 0.5);
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 550px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 24px;
    position: relative;
    z-index: 1;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
}

.modal-close:hover {
    color: #333;
}

.detail-nom {
    font-size: 1.3rem;
    font-weight: 700;
    color: #2d6a4f;
    margin-bottom: 4px;
}

.detail-type {
    display: inline-block;
    background: #d8f3dc;
    color: #2d6a4f;
    padding: 3px 12px;
    border-radius: 12px;
    font-size: 0.8rem;
    margin-bottom: 12px;
}

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

.detail-info p {
    font-size: 0.9rem;
    color: #555;
    margin-bottom: 4px;
}

.detail-info p strong {
    color: #333;
}

.detail-produits h3 {
    font-size: 1rem;
    color: #2d6a4f;
    margin-bottom: 8px;
    border-bottom: 1px solid #eee;
    padding-bottom: 4px;
}

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

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

.produit-item .produit-prix {
    color: #40916c;
    font-weight: 600;
}

.leaflet-popup-content {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.9rem;
    line-height: 1.4;
}

.leaflet-popup-content .popup-nom {
    font-weight: 700;
    color: #2d6a4f;
    font-size: 1rem;
}

.leaflet-popup-content .popup-commune {
    color: #666;
    font-size: 0.85rem;
}

.leaflet-popup-content .popup-type {
    display: inline-block;
    background: #d8f3dc;
    color: #2d6a4f;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    margin-top: 4px;
}

.leaflet-popup-content .popup-btn {
    display: block;
    margin-top: 8px;
    padding: 6px 12px;
    background: #2d6a4f;
    color: white;
    text-align: center;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.85rem;
    cursor: pointer;
    border: none;
    width: 100%;
}

.leaflet-popup-content .popup-btn:hover {
    background: #1b4332;
}

.detail-desc {
    font-style: italic;
    color: #666;
    margin-top: 6px;
    line-height: 1.5;
}

.detail-link {
    color: #2d6a4f;
    text-decoration: none;
    font-weight: 500;
}

.detail-link:hover {
    text-decoration: underline;
}

.detail-actions {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
}

.itinerary-wrapper {
    position: relative;
}

.btn-itinerary {
    padding: 10px 20px;
    background: #2d6a4f;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
    font-weight: 600;
}

.btn-itinerary:hover {
    background: #1b4332;
}

.itinerary-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    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: #333;
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.15s;
}

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

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

.produit-cat {
    color: #999;
    font-size: 0.75rem;
    font-weight: 400;
}

@media (max-width: 768px) {
    #filter-bar {
        padding: 8px 12px;
    }
    .filter-row {
        flex-direction: column;
        gap: 8px;
    }
    #app {
        flex-direction: column;
        height: calc(100vh - 200px);
    }
    #sidebar {
        width: 100%;
        min-width: 100%;
        flex: 0 0 40%;
        height: auto;
    }
    #map {
        flex: 1;
        height: auto;
        min-height: 0;
    }
    .modal-content {
        width: 95%;
        max-height: 85vh;
        padding: 16px;
    }
    .itinerary-menu {
        right: auto;
        left: 0;
    }
}
