/* ===== Search Layer - Fullscreen overlay ===== */
.search-layer {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    background: #fff;
    flex-direction: column;
    overflow: hidden;
}
.search-layer.open {
    display: flex;
}
body.search-layer-open {
    overflow: hidden;
}

/* --- Header --- */
.search-layer-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 12px 24px;
    flex-shrink: 0;
}
.search-layer-header img{
    height: 35px;
    width: auto;
    flex-shrink: 0;
}
.search-layer-logo {
    height: 36px;
    width: auto;
    flex-shrink: 0;
}
.search-layer-inputs{
    flex: 1;
    position: relative;
    display: flex;
    align-items: start;
    flex-direction: column;
}
.search-layer-input-wrapper{
    flex: 1;
    width: 100%;
    position: relative;
    display: flex;
    align-items: center;    
}
.search-layer-input-wrapper svg {
    position: absolute;
    left: 0px;
    color: #999;
    pointer-events: none;
}
#searchLayerInput {
    width: 100%;
    padding: 12px 16px 12px 24px;
    border: none;
    font-size: 18px;
    outline: none;
    background: transparent;
    color: #333;
    border-bottom: 2px solid #FF6B35;
}
#searchLayerInput::placeholder {
    color: #aaa;
}
.search-layer-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    margin-top: 10px;
    margin-bottom: auto;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: color 0.2s;
}
.search-layer-close:hover {
    color: #333;
}
.search-layer-close svg {
    width: 24px;
    height: 24px;
}

/* --- Recent searches bar --- */
.search-layer-recent {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 24px 10px 0;
    flex-shrink: 0;
    overflow-x: auto;
}
.sl-recent-label {
    font-weight: 600;
    font-size: 13px;
    color: #333;
    white-space: nowrap;
}
.sl-recent-list {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
    min-width: 0;
}
.sl-recent-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 13px;
    color: #333;
    background: #fff;
    white-space: nowrap;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.sl-recent-chip:hover {
    border-color: #FF6B35;
    background: #FFF5F0;
}
.sl-recent-remove {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    color: #999;
    padding: 0 0 0 2px;
    display: flex;
    align-items: center;
}
.sl-recent-remove:hover {
    color: #FF6B35;
}
.sl-recent-clear {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    color: #FF6B35;
    white-space: nowrap;
    padding: 0;
    font-weight: 500;
}
.sl-recent-clear:hover {
    text-decoration: underline;
}

/* --- Tabs bar (full width, between header and body) --- */
.search-layer-tabs-bar {
    display: none;
    align-items: center;
    gap: 24px;
    padding: 0 48px;
    border-bottom: 2px solid #eee;
    flex-shrink: 0;
    background: #fff;
}
.search-layer-tabs-bar.active {
    display: flex;
}

/* --- Body --- */
.search-layer-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px 0px;
}

/* === Initial State === */
.search-layer-initial {
    display: flex;
    gap: 40px;
    padding: 0 48px;
    max-width: 100%;
    margin: 0 auto;
}
.search-layer-popular {
    flex: 0 0 250px;
}
.search-layer-popular h3,
.search-layer-recommended h3 {
    font-size: 15px;
    font-weight: 700;
    color: #333;
    margin-bottom: 16px;
    letter-spacing: 0.5px;
}
.search-layer-popular ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.search-layer-popular li {
    padding: 8px 0;
    cursor: pointer;
    color: #333;
    font-size: 14px;
    transition: color 0.2s;
}
.search-layer-popular li:hover {
    color: #FF6B35;
}
.search-layer-recommended {
    flex: 1;
    min-width: 0;
}
.search-layer-carousel {
    position: relative;
}
.sl-carousel-track {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -ms-overflow-style: none;
    scrollbar-width: none;
    padding: 0 4px;
}
.sl-carousel-track::-webkit-scrollbar {
    display: none;
}
.sl-carousel-slide {
    flex: 0 0 calc((100% - 80px) / 6);
    scroll-snap-align: start;
    min-width: 0;
}
.sl-carousel-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    z-index: 2;
    background: #fff;
    border: none;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
    transition: box-shadow 0.2s, opacity 0.2s;
}
.sl-carousel-arrow:hover {
    box-shadow: 0 2px 12px rgba(0,0,0,0.18);
}
.sl-carousel-arrow:disabled {
    opacity: 0.3;
    cursor: default;
}
.sl-carousel-prev { left: -12px; }
.sl-carousel-next { right: -12px; }

/* === Search Results === */
.search-layer-results {
    display: flex;
    gap: 24px;
    padding: 0 48px;
    max-width: 100%;
    margin: 0 auto;
}

/* Filters sidebar */
.search-layer-filters {
    flex: 0 0 280px;
    max-height: calc(100vh - 160px);
    overflow-y: auto;
    padding-right: 16px;
}
.search-layer-filters:empty {
    display: none;
}

/* Filter group */
.sl-filter-group {
    margin-bottom: 8px;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
}
.sl-filter-group:last-child {
    border-bottom: none;
}
.sl-filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
}
.sl-filter-header h4 {
    font-size: 15px;
    font-weight: 700;
    color: #333;
    margin: 0;
    text-transform: capitalize;
}
.sl-filter-chevron {
    width: 20px;
    height: 20px;
    color: #888;
    transition: transform 0.2s;
    flex-shrink: 0;
}
.sl-filter-group.collapsed .sl-filter-chevron {
    transform: rotate(-90deg);
}
.sl-filter-body {
    overflow: hidden;
}
.sl-filter-group.collapsed .sl-filter-body {
    display: none;
}

/* Search input inside filter */
.sl-filter-search {
    width: 100%;
    padding: 8px 10px 8px 32px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    color: #333;
    outline: none;
    margin-bottom: 8px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") 10px center no-repeat;
}
.sl-filter-search:focus {
    border-color: #FF6B35;
}

/* Checkbox list */
.sl-filter-group ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.sl-filter-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 13px;
    color: #444;
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
}
.sl-filter-item:hover {
    color: #FF6B35;
}
.sl-filter-checkbox {
    width: 16px;
    height: 16px;
    border: 2px solid #ccc;
    border-radius: 3px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    background: #fff;
}
.sl-filter-item.active .sl-filter-checkbox {
    background: #FF6B35;
    border-color: #FF6B35;
}
.sl-filter-item.active .sl-filter-checkbox::after {
    content: '';
    width: 8px;
    height: 5px;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(-45deg);
    margin-top: -2px;
}
.sl-filter-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sl-filter-count {
    font-size: 12px;
    color: #999;
    flex-shrink: 0;
}

/* Voir plus / moins */
.sl-filter-toggle {
    display: block;
    font-size: 12px;
    color: #888;
    margin-top: 4px;
    padding: 4px 0;
    cursor: pointer;
    user-select: none;
}
.sl-filter-toggle:hover {
    color: #FF6B35;
}
.sl-filter-info {
    font-size: 11px;
    color: #aaa;
    margin-top: 2px;
}

/* Content area */
.search-layer-content {
    flex: 1;
    min-width: 0;
}

/* Tabs (inside tabs-bar) */
.search-layer-tabs {
    display: flex;
    gap: 0;
    list-style: none;
    padding: 0;
    margin: 0;
}
.search-layer-tabs li {
    padding: 12px 10px;
    font-size: 16px;
    font-weight: 600;
    color: #888;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
    user-select: none;
    white-space: nowrap;
}
.search-layer-tabs li:hover {
    color: #555;
}
.search-layer-tabs li.active {
    color: #555;
    border-bottom-color: #FF6B35;
}
.search-layer-tabs li span {
    font-weight: 400;
    font-size: 16px;
    color: #aaa;
    margin-left: 4px;
}
.search-layer-tabs li:hover span,
.search-layer-tabs li.active span{
    color: #555;
}

/* Product/Model grid */
.search-layer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(calc(100% / 7), 1fr));
    gap: 16px;
}

/* Product card */
.sl-card {
    display: flex;
    flex-direction: column;
    border: 1px solid #eee;
    border-radius: 12px;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
    text-decoration: none;
    color: inherit;
}
.sl-card:hover {
    border-color: #FF6B35;
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.1);
    text-decoration: none;
    color: inherit;
}
.sl-card-img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: contain;
    background: #fafafa;
    padding: 8px;
}
.sl-card-body {
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}
.sl-card-title {
    font-size: 13px;
    font-weight: 500;
    color: #333;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.sl-card-price {
    font-size: 15px;
    font-weight: 700;
    color: #FF6B35;
    margin-top: auto;
}
.sl-card-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: #FF6B35;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
}

/* Loading state */
.search-layer-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #999;
    font-size: 14px;
    gap: 8px;
}
.search-layer-loading::before {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #eee;
    border-top-color: #FF6B35;
    border-radius: 50%;
    animation: slSpin 0.6s linear infinite;
}
@keyframes slSpin {
    to { transform: rotate(360deg); }
}

/* Empty state */
.search-layer-empty {
    text-align: center;
    padding: 60px 20px;
    color: #888;
}
.search-layer-empty svg {
    width: 48px;
    height: 48px;
    color: #ccc;
    margin-bottom: 12px;
}
.search-layer-empty p {
    font-size: 15px;
    margin: 0;
}

/* Toolbar (above grid: result count + sort) */
.search-layer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0 16px;
    margin-bottom: 16px;
}
.search-layer-summary {
    font-size: 14px;
    color: #333;
    white-space: nowrap;
}
.search-layer-summary strong {
    color: #333;
    font-weight: 700;
}
/* Sort dropdown */
.sl-sort {
    position: relative;
    white-space: nowrap;
}
.sl-sort-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    user-select: none;
    font-size: 14px;
    padding: 6px 0;
}
.sl-sort-label {
    color: #888;
}
.sl-sort-value {
    font-weight: 600;
    color: #333;
}
.sl-sort-chevron {
    width: 16px;
    height: 16px;
    color: #666;
    transition: transform 0.2s;
    flex-shrink: 0;
}
.sl-sort.open .sl-sort-chevron {
    transform: rotate(180deg);
}
.sl-sort-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 180px;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    list-style: none;
    padding: 6px 0;
    margin: 4px 0 0;
    z-index: 10;
}
.sl-sort.open .sl-sort-dropdown {
    display: block;
}
.sl-sort-dropdown li {
    padding: 8px 16px;
    font-size: 13px;
    color: #555;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.sl-sort-dropdown li:hover {
    background: #f8f8f8;
    color: #333;
}
.sl-sort-dropdown li.active {
    color: #FF6B35;
    font-weight: 600;
}

/* === Responsive === */

/* -- Tablet (769–1200px) -- */
@media (min-width: 769px) and (max-width: 1200px) {
    .sl-carousel-slide {
        flex: 0 0 calc((100% - 64px) / 5);
    }
    .search-layer-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
}

/* -- Mobile (≤768px) -- */
@media (max-width: 768px) {
    /* Header */
    .search-layer-header {
        padding: 10px 12px;
        gap: 10px;
    }
    .search-layer-header > img {
        display: none;
    }
    #searchLayerInput {
        font-size: 16px;
        padding: 10px 12px 10px 24px;
    }
    .search-layer-close {
        margin-top: 6px;
    }
    .search-layer-close svg {
        width: 20px;
        height: 20px;
    }

    /* Recent searches */
    .search-layer-recent {
        padding: 8px 0;
        gap: 8px;
        flex-wrap: wrap;
    }
    .sl-recent-label {
        font-size: 12px;
        flex: 0 0 100%;
    }
    .sl-recent-list {
        flex-wrap: wrap;
        gap: 6px;
    }
    .sl-recent-chip {
        font-size: 12px;
        padding: 4px 10px;
    }
    .sl-recent-clear {
        font-size: 12px;
    }

    /* Tabs */
    .search-layer-tabs-bar {
        padding: 0 12px;
        gap: 8px;
    }
    .search-layer-tabs li {
        font-size: 14px;
        padding: 10px 8px;
    }
    .search-layer-tabs li span {
        font-size: 14px;
    }

    /* Toolbar */
    .search-layer-toolbar {
        flex-wrap: wrap;
        gap: 8px;
    }

    /* Body */
    .search-layer-body {
        padding: 16px 0;
    }
    .search-layer-initial {
        flex-direction: column;
        gap: 24px;
        padding: 0 12px;
    }
    .search-layer-popular {
        flex: none;
    }
    .search-layer-popular h3,
    .search-layer-recommended h3 {
        font-size: 14px;
    }

    /* Results */
    .search-layer-results {
        flex-direction: column;
        padding: 0 12px;
    }
    .search-layer-filters {
        flex: none;
        max-height: none;
        padding-right: 0;
        padding-bottom: 16px;
        border-bottom: 1px solid #eee;
        margin-bottom: 16px;
    }
    .search-layer-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    /* Carousel */
    .sl-carousel-slide {
        flex: 0 0 calc((100% - 32px) / 3);
    }
    .sl-carousel-arrow {
        display: none;
    }
}

/* -- Small mobile (≤480px) -- */
@media (max-width: 480px) {
    .sl-carousel-slide {
        flex: 0 0 calc((100% - 16px) / 2);
    }
    .search-layer-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .sl-card-body {
        padding: 8px;
    }
    .sl-card-title {
        font-size: 12px;
    }
    .sl-card-price {
        font-size: 13px;
    }
}
