/* categories.php - Categories Page */
:root {
    --primary-blue: #f57c00;
    --border-color: #e9ecef;
    --text-dark: #333;
    --text-muted: #6c757d;
    --success-green: #28a745;
    --danger-red: #dc3545;
    --warning-yellow: #ffc107;
}

.categories-page {
    padding: 24px 20px 60px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.categories-row {
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
}

.categories-row > [class*="col-"] {
    box-sizing: border-box;
}

/* Sidebar - same design as list_of_product */
.sidebar-filters {
    padding-right: 24px;
    position: sticky;
    top: 100px;
}

.sidebar-filters-inner {
    background: linear-gradient(180deg, #ffffff 0%, #fff8e1 100%);
    border: 1px solid #ffe0b2;
    border-radius: 14px;
    padding: 18px 0;
    box-shadow: 0 2px 8px rgba(245, 124, 0, 0.06);
    animation: categoriesSidebarFadeIn 0.3s ease;
}

@keyframes categoriesSidebarFadeIn {
    from { opacity: 0; transform: translateX(-6px); }
    to { opacity: 1; transform: translateX(0); }
}

.filter-section {
    margin-bottom: 20px;
    padding: 12px 16px 16px;
    border-bottom: 1px solid #ffe0b2;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 10px;
    margin-left: 8px;
    margin-right: 8px;
    transition: background 0.25s ease, box-shadow 0.25s ease;
}

.filter-section:hover {
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 6px rgba(245, 124, 0, 0.08);
}

.filter-section:last-child {
    border-bottom: none;
}

.filter-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid #ffe0b2;
}

/* Categories List - design Catégories (collapse/expand on hover, animation like header) */
.category-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.category-item {
    margin-bottom: 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.category-item:last-child {
    border-bottom: none;
}

.cat-sidebar-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.cat-sidebar-list {
    padding: 0;
}

.cat-sidebar-item {
    position: relative;
}

.cat-sidebar-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px 12px 16px;
    color: var(--text-dark);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: background 0.25s ease, color 0.2s ease, border-color 0.25s ease;
}

.cat-sidebar-link:hover,
.cat-sidebar-item.active .cat-sidebar-link {
    background: rgba(255, 243, 224, 0.95);
    color: #e65100;
    border-left-color: var(--primary-blue);
}

.cat-sidebar-link-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.cat-sidebar-icon-folder {
    flex-shrink: 0;
    width: 0.9rem;
    height: 0.9rem;
    color: var(--primary-blue);
    display: inline-block;
}

.cat-sidebar-icon-folder path,
.cat-sidebar-icon-folder rect {
    fill: currentColor;
}

.cat-sidebar-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cat-sidebar-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    background: var(--primary-blue);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 50%;
    flex-shrink: 0;
}

.cat-sidebar-chevron {
    color: var(--primary-blue);
    flex-shrink: 0;
    width: 0.75rem;
    height: 0.75rem;
    display: inline-block;
    transition: transform 0.3s ease-out;
}

.cat-sidebar-chevron polyline,
.cat-sidebar-chevron path {
    stroke: currentColor;
}

.cat-sidebar-item:hover .cat-sidebar-chevron {
    transform: rotate(180deg);
}

/* Animation like header dropdown (headerDropdownSlide): smooth slide + fade */
.subcategory-list.cat-sidebar-sublist {
    list-style: none;
    padding: 0 0 4px 0;
    margin: 0 0 0 12px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-10px);
    transition: max-height 0.35s ease-out, opacity 0.3s ease-out, transform 0.3s ease-out;
}

.cat-sidebar-item:hover .cat-sidebar-sublist,
.cat-sidebar-item.cat-sidebar-expanded .cat-sidebar-sublist {
    max-height: 320px;
    opacity: 1;
    transform: translateY(0);
    animation: categorySublistSlide 0.3s ease-out;
}

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

.cat-sidebar-sublist li {
    margin-bottom: 2px;
}

.cat-sidebar-sublink {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px 8px 10px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s ease, background 0.2s ease;
}

.cat-sidebar-sublink:hover,
.cat-sidebar-sublist li.active .cat-sidebar-sublink {
    color: var(--primary-blue);
    background: rgba(255, 245, 235, 0.5);
}

.cat-sidebar-subicon {
    color: var(--primary-blue);
    flex-shrink: 0;
    width: 0.7rem;
    height: 0.7rem;
    display: inline-block;
}

.cat-sidebar-subicon polyline,
.cat-sidebar-subicon path {
    stroke: currentColor;
}

/* Legacy class names kept for compatibility */
.category-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    color: var(--text-dark);
    text-decoration: none;
    transition: background 0.25s ease, color 0.2s, padding-left 0.2s, transform 0.2s ease;
}

.subcategory-list {
    list-style: none;
    padding: 0;
    margin: 10px 0 0 20px;
}

/* Price Range */
.price-range-container {
    padding: 10px 0;
}

.price-slider-wrapper {
    position: relative;
    height: 40px;
    margin-bottom: 15px;
}

.price-slider {
    position: absolute;
    width: 100%;
    height: 6px;
    background: #ddd;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

.price-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary-blue);
    border-radius: 50%;
    cursor: pointer;
}

.price-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--primary-blue);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.price-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.price-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
}

.btn-apply-filter {
    width: 100%;
    padding: 10px;
    background: var(--primary-blue);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-apply-filter:hover {
    background: #e65100;
    transform: translateY(-1px);
}

/* Brand Filters */
.brand-filters {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.brand-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.brand-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Color Filters */
.color-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.color-swatch-filter {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s;
}

.color-swatch-filter:hover {
    transform: scale(1.1);
}

.color-swatch-filter.active {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 2px rgba(245, 124, 0, 0.2);
}

/* Products Section */
.products-section {
    padding-left: 30px;
    min-width: 0; /* allow grid to shrink inside flex column */
    max-width: 100%;
}

.products-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.search-products {
    display: flex;
    flex: 1;
    min-width: 250px;
    max-width: 400px;
}

.search-input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 6px 0 0 6px;
    outline: none;
}

.search-btn {
    padding: 10px 20px;
    background: var(--primary-blue);
    color: #fff;
    border: none;
    border-radius: 0 6px 6px 0;
    cursor: pointer;
}

.search-btn:hover {
    background: linear-gradient(135deg, #e65100 0%, #f57c00 100%);
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(245, 124, 0, 0.35);
}

.search-btn:active {
    transform: scale(0.98);
}

.search-products {
    position: relative;
}

.search-suggestions-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 2px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    max-height: 280px;
    overflow-y: auto;
    z-index: 1000;
}

.search-suggestions-dropdown[hidden] {
    display: none !important;
}

.search-suggestion-item {
    display: block;
    padding: 10px 14px;
    color: var(--text-dark);
    text-decoration: none;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    transition: background 0.2s;
}

.search-suggestion-item:last-child {
    border-bottom: none;
}

.search-suggestion-item:hover {
    background: rgba(255, 245, 235, 0.7);
    color: #e65100;
}

.search-suggestion-empty {
    color: var(--text-muted);
    cursor: default;
}

/* Suggestions avec image: 20 premiers caractères + prix en-dessous du nom */
.search-suggestion-item-with-img {
    padding: 10px 12px !important;
}
.search-suggestion-item-img-wrap {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    border-radius: 8px;
    overflow: hidden;
}
.search-suggestion-item-img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}
.search-suggestion-item-body { min-width: 0; }
.search-suggestion-item-name {
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25;
    display: block;
}
.search-suggestion-item-price {
    font-size: 0.8rem;
    margin-top: 2px;
    display: block;
}

.control-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.control-select {
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    outline: none;
    cursor: pointer;
}

.view-toggle {
    display: flex;
    gap: 5px;
}

.view-btn {
    padding: 10px 15px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.3s;
}

.view-btn.active {
    background: var(--primary-blue);
    color: #fff;
    border-color: var(--primary-blue);
}

/* Active Filters */
.active-filters {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.active-filters-label {
    font-weight: 600;
    color: var(--text-dark);
}

.filter-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--primary-blue);
    color: #fff;
    border-radius: 20px;
    font-size: 0.85rem;
}

.filter-tag i {
    cursor: pointer;
    font-size: 0.75rem;
}

.clear-all {
    color: var(--primary-blue);
    text-decoration: none;
    font-weight: 500;
}

.clear-all:hover {
    text-decoration: underline;
}

/* Products Grid - same as list_of_product (smaller cards); align-items: start = cartes à la hauteur du contenu (pas d'espace en bas) */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(152px, 1fr));
    gap: 14px;
    align-items: start;
    transition: opacity 0.25s ease-out;
}

.products-grid.list-view {
    grid-template-columns: 1fr;
}

.product-card {
    position: relative;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.2s;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
    border-color: rgba(245, 124, 0, 0.3);
}

.product-badge {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.product-badge.blue {
    background: var(--primary-blue);
    color: #fff;
}

.product-badge.red {
    background: #b12704;
    color: #fff;
}

.product-card .img-wrap {
    background: #f9fafb;
    border-radius: 8px;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    min-height: 120px;
    overflow: hidden;
    transition: background 0.25s ease;
}

.product-card:hover .img-wrap {
    background: #fff5eb;
}

.product-card .img-wrap img {
    max-height: 100px;
    width: auto;
    object-fit: contain;
    transition: transform 0.35s ease;
}

.product-image a {
    display: block;
    height: 100%;
    min-height: inherit;
}

.product-name a {
    color: inherit;
    text-decoration: none;
}

.product-name a:hover {
    color: #e65100;
}

.product-card:hover .img-wrap img {
    transform: scale(1.05);
}

.product-actions {
    margin-top: auto;
    padding-top: 6px;
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.product-action-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #374151;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.product-action-btn:hover {
    border-color: #f57c00;
    color: #f57c00;
    background: #fff5eb;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(245, 124, 0, 0.2);
}

.product-action-btn.add-cart-btn {
    background: linear-gradient(180deg, #ffd54f 0%, #f57c00 100%);
    color: #1a1a1a;
    border-color: transparent;
}

.product-action-btn.add-cart-btn:hover {
    color: #1a1a1a;
    background: linear-gradient(180deg, #ffc107 0%, #e65100 100%);
}

.product-action-btn.whatsapp-btn:hover {
    border-color: #25d366;
    color: #25d366;
    background: rgba(37, 211, 102, 0.08);
}

.product-image {
    width: 100%;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f9fafb;
    padding: 8px;
    border-radius: 8px;
    margin-bottom: 6px;
}

.product-image img {
    max-height: 100px;
    width: auto;
    object-fit: contain;
}

.product-info {
    padding: 0;
}

.product-name {
    font-size: 0.8rem;
    font-weight: 500;
    color: #111827;
    margin: 4px 0 2px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.6em;
}

.product-card:hover .product-name {
    color: #e65100;
}

.product-price {
    margin-bottom: 4px;
}

.product-price-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex-wrap: wrap;
}

.current-price {
    font-size: 1rem;
    font-weight: 700;
    color: #1a1a1a;
}

.old-price {
    font-size: 0.75rem;
    color: #6b7280;
    text-decoration: line-through;
}

.product-rating {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
}

.product-rating i {
    color: #ffc107;
    font-size: 0.75rem;
}

.product-card .product-actions-bottom {
    margin-top: 4px;
}

.rating-value {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.product-colors {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.color-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
}

.btn-add-to-cart {
    width: 100%;
    padding: 6px 10px;
    font-size: 0.8rem;
    background: linear-gradient(180deg, #ffd54f 0%, #f57c00 100%);
    color: #1a1a1a;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 6px rgba(245, 124, 0, 0.25);
}

.btn-add-to-cart:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(245, 124, 0, 0.35);
}

/* List View */
.products-grid.list-view .product-card {
    display: flex;
    flex-direction: row;
}

.products-grid.list-view .product-image,
.products-grid.list-view .img-wrap {
    width: 120px;
    min-height: 100px;
    flex-shrink: 0;
}

.products-grid.list-view .product-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* Mobile / tablette : bouton Filtres (pilule type capture) + tiroir catégories */
.categories-mobile-filtres-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 14px 24px;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: #111;
    background: #fff;
    border: none;
    border-radius: 50rem;
    /* Ombre douce plutôt bas-droite, comme la capture */
    box-shadow: 3px 4px 14px rgba(0, 0, 0, 0.1), 1px 2px 4px rgba(0, 0, 0, 0.06);
    cursor: pointer;
    transition: transform 0.22s ease, box-shadow 0.22s ease;
}
.categories-mobile-filtres-btn:hover {
    box-shadow: 4px 6px 18px rgba(0, 0, 0, 0.12);
    transform: translateY(-1px);
}
.categories-mobile-filtres-btn i {
    font-size: 1.05rem;
    color: #111;
}

.categories-filters-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.48);
    z-index: 1040;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.28s ease, visibility 0.28s ease;
}
.categories-filters-backdrop.is-visible {
    opacity: 1;
    visibility: visible;
}

body.categories-filters-scroll-lock {
    overflow: hidden;
}

@media (min-width: 1200px) {
    .categories-filters-drawer {
        position: static;
        transform: none;
        width: auto;
        height: auto;
        background: transparent;
        box-shadow: none;
    }
    .categories-filters-backdrop {
        display: none !important;
    }
}

/* Responsive : mobile + tablette (< xl) */
@media (max-width: 1199.98px) {
    .categories-main-row {
        position: relative;
    }

    .categories-filters-column {
        position: absolute;
        left: 0;
        top: 0;
        width: 0 !important;
        max-width: 0 !important;
        flex: 0 0 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow: visible;
        z-index: 1050;
    }

    .categories-filters-drawer {
        position: fixed;
        top: 0;
        left: 0;
        width: min(92vw, 400px);
        max-width: 100%;
        height: 100vh;
        height: 100dvh;
        background: linear-gradient(180deg, #ffffff 0%, #fff8f0 100%);
        border-right: 1px solid #ffe0b2;
        box-shadow: 12px 0 40px rgba(0, 0, 0, 0.15);
        transform: translateX(-108%);
        transition: transform 0.34s cubic-bezier(0.32, 0.72, 0, 1);
        z-index: 1055;
        display: flex;
        flex-direction: column;
        pointer-events: none;
    }

    .categories-filters-column.is-open .categories-filters-drawer {
        transform: translateX(0);
        pointer-events: auto;
    }

    .categories-filters-drawer-scroll {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        padding-bottom: max(24px, env(safe-area-inset-bottom));
    }

    .categories-filters-column .sidebar-filters {
        position: static !important;
        top: auto !important;
        padding-right: 0;
        margin-bottom: 0;
    }

    .sidebar-filters {
        padding-right: 0;
        margin-bottom: 0;
    }

    .products-section {
        padding-left: 0;
    }

    .products-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .search-products {
        max-width: 100%;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(152px, 1fr));
        gap: 14px;
    }
}

/* list_of_product.php - CSP: no inline styles */
.list-products-page .list-products-main-row {
    max-width: 100%;
}

.list-products-page .per-page-select-width {
    width: auto;
}
