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

:root {
    --primary-color: #2563eb;
    --secondary-color: #3b82f6;
    --background: #f8fafc;
    --card-background: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 2rem;
    text-align: center;
    box-shadow: var(--shadow);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.stats {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    font-size: 1.1rem;
    transition: opacity 0.2s ease;
}

.stats select {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    outline: none;
}

.stats select option {
    color: var(--text-primary);
}

.separator {
    opacity: 0.5;
}

/* Onglets */
.tabs {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    padding: 1rem 2rem;
    display: flex;
    gap: 1rem;
    justify-content: center;
    box-shadow: var(--shadow);
}

.tab-btn {
    padding: 1rem 2.5rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 12px;
    transition: all 0.3s;
    position: relative;
    backdrop-filter: blur(10px);
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.tab-btn.active {
    background: white;
    color: var(--primary-color);
    border-color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: scale(1.05);
}

/* Contenu des onglets */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Carte */
#map {
    height: calc(100vh - 350px);
    min-height: 500px;
    width: 100%;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

#map-view {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 2rem;
}

.filters {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 2rem;
}

.filters-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.filters input,
.filters select,
.filters button {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s;
}

.filters-row input {
    flex: 1;
    min-width: 250px;
}

.filters input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.filters select {
    cursor: pointer;
    background: white;
}

.toggle-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 500;
    white-space: nowrap;
}

.toggle-btn:hover {
    background: var(--secondary-color);
}

.advanced-filters {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-group label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.range-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

.range-inputs input {
    flex: 1;
    min-width: 0;
    padding: 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
}

.range-inputs span {
    color: var(--text-secondary);
    font-weight: 500;
}

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

.filters button {
    background: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 600;
}

.filters button:hover {
    background: var(--secondary-color);
    transform: translateY(-1px);
}

.loading {
    text-align: center;
    padding: 4rem 2rem;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: spin 1s linear infinite;
}

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

.error {
    text-align: center;
    padding: 2rem;
    color: #dc2626;
    font-size: 1.2rem;
}

.annonces-grid {
    max-width: 1400px;
    margin: 0 auto 4rem;
    padding: 0 2rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 2rem;
    opacity: 1;
    transition: opacity 0.2s ease;
}

.annonce-card {
    background: var(--card-background);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all 0.3s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.annonce-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

.annonce-image {
    width: 100%;
    height: 240px;
    object-fit: cover;
    background: var(--border-color);
}

.annonce-content {
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.annonce-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--text-primary);
}

.annonce-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.annonce-info-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.annonce-price {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-top: auto;
}

.annonce-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.tag {
    background: var(--background);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: var(--card-background);
    margin: 2rem auto;
    padding: 0;
    border-radius: 12px;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: slideIn 0.3s;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close {
    position: sticky;
    top: 0;
    right: 0;
    float: right;
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 1rem;
    z-index: 1;
    background: var(--card-background);
}

.close:hover {
    color: var(--text-primary);
}

#modal-body {
    padding: 2rem;
}

.modal-images {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.modal-image {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.3s;
}

.modal-image:hover {
    transform: scale(1.05);
}

.modal-section {
    margin-bottom: 2rem;
}

.modal-section h3 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.modal-description {
    line-height: 1.8;
    color: var(--text-secondary);
    white-space: pre-wrap;
}

.modal-link {
    display: inline-block;
    background: var(--primary-color);
    color: white;
    padding: 1rem 2rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    margin-top: 1rem;
    transition: all 0.3s;
}

.modal-link:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
}

/* Responsive */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.8rem;
    }

    .annonces-grid {
        grid-template-columns: 1fr;
        padding: 0 1rem;
    }

    .filters {
        padding: 0 1rem;
    }

    .filters input {
        min-width: 100%;
    }

    .advanced-filters {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .range-inputs {
        flex-wrap: nowrap;
    }

    .range-inputs input {
        min-width: 0;
        flex: 1;
    }

    .modal-content {
        margin: 1rem;
        max-width: calc(100% - 2rem);
    }

    .tabs {
        flex-wrap: wrap;
        padding: 1rem;
    }

    .tab-btn {
        flex: 1;
        min-width: 120px;
        padding: 0.8rem 1.5rem;
        font-size: 1rem;
    }
}

@media (max-width: 1200px) and (min-width: 769px) {
    .advanced-filters {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Marqueurs de carte personnalisés */
.price-marker {
    background: white;
    border: 2px solid var(--primary-color);
    border-radius: 20px;
    padding: 0.4rem 0.8rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.3s;
}

.price-marker:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.1);
    z-index: 1000 !important;
}

.price-marker.selected {
    background: var(--primary-color);
    color: white;
    border-width: 3px;
    transform: scale(1.15);
}

/* Popup de carte personnalisée */
.leaflet-popup-content-wrapper {
    border-radius: 12px;
    box-shadow: var(--shadow-hover);
}

.leaflet-popup-content {
    margin: 0;
    min-width: 250px;
}

.map-popup-card {
    padding: 0;
}

.map-popup-image {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 8px 8px 0 0;
}

.map-popup-content {
    padding: 1rem;
}

.map-popup-title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.map-popup-location {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.map-popup-info {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.map-popup-price {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.75rem;
}

.map-popup-btn {
    display: block;
    width: 100%;
    padding: 0.6rem;
    background: var(--primary-color);
    color: white;
    text-align: center;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s;
    border: none;
    cursor: pointer;
}

.map-popup-btn:hover {
    background: var(--secondary-color);
}

/* Clusters de marqueurs */
.custom-cluster-icon {
    background: transparent;
    border: none;
}

.cluster-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    font-size: 0.9rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    border: 3px solid white;
}

.cluster-small {
    background: var(--primary-color);
}

.cluster-medium {
    background: #f59e0b;
    width: 50px;
    height: 50px;
    font-size: 1rem;
}

.cluster-large {
    background: #ef4444;
    width: 60px;
    height: 60px;
    font-size: 1.1rem;
}
