/**
 * Styles frontend pour WP Company Map
 */

/* Variables */
:root {
    --wpcm-primary: #2271b1;
    --wpcm-primary-hover: #135e96;
    --wpcm-text: #1d2327;
    --wpcm-text-light: #646970;
    --wpcm-border: #c3c4c7;
    --wpcm-bg: #ffffff;
    --wpcm-bg-light: #f6f7f7;
    --wpcm-radius: 6px;
    --wpcm-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

/* Container principal */
.wpcm-container {
    position: relative;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--wpcm-text);
}

.wpcm-container *,
.wpcm-container *::before,
.wpcm-container *::after {
    box-sizing: border-box;
}

/* Layout avec filtres */
.wpcm-main-wrapper {
    display: flex;
    gap: 0;
}

.wpcm-has-filters.wpcm-filters-left .wpcm-main-wrapper {
    flex-direction: row;
}

.wpcm-has-filters.wpcm-filters-right .wpcm-main-wrapper {
    flex-direction: row-reverse;
}

.wpcm-has-filters.wpcm-filters-top {
    display: flex;
    flex-direction: column;
}

/* Map wrapper */
.wpcm-map-wrapper {
    flex: 1;
    position: relative;
    min-width: 0; /* Pour éviter les débordements en flex */
}

/*
 * La hauteur est définie sur le wrapper (.wpcm-map-wrapper) via style inline.
 * .wpcm-map prend 100% de la hauteur du wrapper.
 */
.wpcm-map {
    width: 100%;
    height: 100%;
    z-index: 1;
    border-radius: var(--wpcm-radius);
    overflow: hidden;
}

/* Loading indicator */
.wpcm-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px 30px;
    background: var(--wpcm-bg);
    border-radius: var(--wpcm-radius);
    box-shadow: var(--wpcm-shadow);
    z-index: 1000;
}

.wpcm-loading.hidden {
    display: none;
}

.wpcm-loading-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid var(--wpcm-bg-light);
    border-top-color: var(--wpcm-primary);
    border-radius: 50%;
    animation: wpcm-spin 0.8s linear infinite;
}

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

/* Results count */
.wpcm-results-count {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--wpcm-bg);
    padding: 8px 15px;
    border-radius: var(--wpcm-radius);
    box-shadow: var(--wpcm-shadow);
    z-index: 1000;
    font-size: 13px;
}

.wpcm-count-value {
    font-weight: 600;
    color: var(--wpcm-primary);
}

/* Filters Panel - Sidebar */
.wpcm-filters-sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--wpcm-bg);
    border: 1px solid var(--wpcm-border);
    border-radius: var(--wpcm-radius);
    overflow: hidden;
    transition: width 0.3s ease, min-width 0.3s ease;
}

.wpcm-filters-sidebar.collapsed {
    width: 50px;
    min-width: 50px;
}

.wpcm-filters-sidebar.collapsed .wpcm-filters-content {
    display: none;
}

.wpcm-filters-sidebar.collapsed .wpcm-filters-toggle .dashicons {
    transform: rotate(180deg);
}

.wpcm-filters-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    background: var(--wpcm-bg-light);
    border-bottom: 1px solid var(--wpcm-border);
}

.wpcm-filters-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.wpcm-filters-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    color: var(--wpcm-text-light);
    transition: color 0.2s;
}

.wpcm-filters-toggle:hover {
    color: var(--wpcm-text);
}

.wpcm-filters-content {
    padding: 15px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

/* Filters Panel - Horizontal */
.wpcm-filters-horizontal {
    background: var(--wpcm-bg);
    border: 1px solid var(--wpcm-border);
    border-radius: var(--wpcm-radius);
    margin-bottom: 15px;
}

.wpcm-filters-horizontal .wpcm-filters-content {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-end;
    padding: 15px;
    max-height: none;
}

.wpcm-filters-horizontal .wpcm-filter-group {
    margin-bottom: 0;
    min-width: 180px;
    flex: 1;
}

.wpcm-filters-horizontal .wpcm-search-group {
    min-width: 250px;
    flex: 2;
}

.wpcm-filters-horizontal .wpcm-filter-actions {
    margin-top: 0;
}

/* Filter Groups */
.wpcm-filter-group {
    margin-bottom: 15px;
}

.wpcm-filter-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    font-size: 13px;
    color: var(--wpcm-text);
}

/* Search input */
.wpcm-search-wrapper {
    position: relative;
}

.wpcm-search-input {
    width: 100%;
    padding: 10px 35px 10px 12px;
    border: 1px solid var(--wpcm-border);
    border-radius: var(--wpcm-radius);
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.wpcm-search-input:focus {
    outline: none;
    border-color: var(--wpcm-primary);
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.2);
}

.wpcm-search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 3px;
    color: var(--wpcm-text-light);
    display: none;
}

.wpcm-search-input:not(:placeholder-shown) + .wpcm-search-clear {
    display: block;
}

/* Select filter */
.wpcm-filter-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--wpcm-border);
    border-radius: var(--wpcm-radius);
    font-size: 14px;
    background: var(--wpcm-bg);
    cursor: pointer;
}

.wpcm-filter-select:focus {
    outline: none;
    border-color: var(--wpcm-primary);
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.2);
}

/* Filter input */
.wpcm-filter-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--wpcm-border);
    border-radius: var(--wpcm-radius);
    font-size: 14px;
}

.wpcm-filter-input:focus {
    outline: none;
    border-color: var(--wpcm-primary);
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.2);
}

/* Checkbox filters */
.wpcm-filter-checkboxes {
    max-height: 200px;
    overflow-y: auto;
    padding: 5px 0;
}

.wpcm-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    cursor: pointer;
    font-weight: normal;
}

.wpcm-checkbox-label:hover {
    color: var(--wpcm-primary);
}

.wpcm-show-more {
    background: none;
    border: none;
    color: var(--wpcm-primary);
    cursor: pointer;
    padding: 5px 0;
    font-size: 13px;
}

/* Filter actions */
.wpcm-filter-actions {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--wpcm-border);
}

.wpcm-reset-filters {
    display: flex;
    align-items: center;
    gap: 5px;
    width: 100%;
    padding: 10px;
    background: var(--wpcm-bg-light);
    border: 1px solid var(--wpcm-border);
    border-radius: var(--wpcm-radius);
    cursor: pointer;
    font-size: 13px;
    color: var(--wpcm-text);
    transition: background 0.2s;
    justify-content: center;
}

.wpcm-reset-filters:hover {
    background: #e9e9e9;
}

.wpcm-reset-filters .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* Legend */
.wpcm-legend {
    position: absolute;
    bottom: 20px;
    left: 10px;
    background: var(--wpcm-bg);
    border-radius: var(--wpcm-radius);
    box-shadow: var(--wpcm-shadow);
    max-width: 250px;
    max-height: 300px;
    z-index: 1000;
    overflow: hidden;
}

.wpcm-legend-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--wpcm-bg-light);
    border-bottom: 1px solid var(--wpcm-border);
    font-weight: 600;
    font-size: 13px;
}

.wpcm-legend-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    color: var(--wpcm-text-light);
}

.wpcm-legend-toggle[aria-expanded="false"] .dashicons {
    transform: rotate(180deg);
}

.wpcm-legend-content {
    padding: 10px 12px;
    max-height: 200px;
    overflow-y: auto;
}

.wpcm-legend-content.collapsed {
    display: none;
}

.wpcm-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 12px;
}

.wpcm-legend-marker {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
}

.wpcm-legend-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Popup / Infobulle */
.wpcm-popup {
    min-width: 250px;
    max-width: 350px;
}

.wpcm-popup-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 10px 0;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--wpcm-border);
    color: var(--wpcm-text);
}

.wpcm-popup-field {
    margin-bottom: 8px;
    font-size: 13px;
}

.wpcm-popup-label {
    font-weight: 500;
    color: var(--wpcm-text-light);
}

.wpcm-popup-value {
    color: var(--wpcm-text);
}

.wpcm-popup-value a {
    color: var(--wpcm-primary);
    text-decoration: none;
}

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

.wpcm-popup-description {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--wpcm-border);
    font-size: 12px;
    color: var(--wpcm-text-light);
    line-height: 1.6;
}

/* Leaflet overrides */
.wpcm-container .leaflet-popup-content-wrapper {
    border-radius: var(--wpcm-radius);
    box-shadow: var(--wpcm-shadow);
}

.wpcm-container .leaflet-popup-content {
    margin: 15px;
}

.wpcm-container .leaflet-popup-close-button {
    color: var(--wpcm-text-light);
}

.wpcm-container .leaflet-popup-close-button:hover {
    color: var(--wpcm-text);
}

/* Cluster markers */
.wpcm-container .marker-cluster {
    background-clip: padding-box;
}

.wpcm-container .marker-cluster div {
    width: 36px;
    height: 36px;
    margin-left: 5px;
    margin-top: 5px;
    text-align: center;
    border-radius: 18px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wpcm-container .marker-cluster-small {
    background-color: rgba(181, 226, 140, 0.6);
}

.wpcm-container .marker-cluster-small div {
    background-color: rgba(110, 204, 57, 0.8);
    color: #fff;
}

.wpcm-container .marker-cluster-medium {
    background-color: rgba(241, 211, 87, 0.6);
}

.wpcm-container .marker-cluster-medium div {
    background-color: rgba(240, 194, 12, 0.8);
    color: #fff;
}

.wpcm-container .marker-cluster-large {
    background-color: rgba(253, 156, 115, 0.6);
}

.wpcm-container .marker-cluster-large div {
    background-color: rgba(241, 128, 23, 0.8);
    color: #fff;
}

/* Custom markers */
.wpcm-custom-marker {
    width: 30px !important;
    height: 30px !important;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.wpcm-custom-marker .wpcm-marker-icon {
    transform: rotate(45deg);
    font-size: 14px;
    color: #fff;
}

/* Responsive */
@media (max-width: 768px) {
    .wpcm-main-wrapper {
        flex-direction: column;
    }

    .wpcm-filters-sidebar {
        width: 100%;
        min-width: 100%;
        order: -1;
        margin-bottom: 15px;
    }

    .wpcm-filters-sidebar.collapsed {
        width: 100%;
        min-width: 100%;
    }

    .wpcm-filters-content {
        max-height: 300px;
    }

    .wpcm-legend {
        max-width: 200px;
        font-size: 12px;
    }

    .wpcm-results-count {
        font-size: 12px;
        padding: 6px 10px;
    }

    .wpcm-popup {
        min-width: 200px;
        max-width: 280px;
    }
}

/* Mobile toggle button */
.wpcm-mobile-filter-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: var(--wpcm-primary);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    box-shadow: var(--wpcm-shadow);
    z-index: 1001;
}

@media (max-width: 768px) {
    .wpcm-mobile-filter-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .wpcm-filters-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        min-width: 100%;
        margin: 0;
        border-radius: 0;
        z-index: 1002;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .wpcm-filters-sidebar.mobile-open {
        transform: translateX(0);
    }

    .wpcm-filters-content {
        max-height: calc(100vh - 60px);
    }
}

/* Animations */
.wpcm-fade-in {
    animation: wpcm-fade-in 0.3s ease;
}

@keyframes wpcm-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

