/* ============================================================================
   CATALOG PAGE - mobilier.africa
   ============================================================================ */

/* Catalog Header */
.catalog-header {
    padding-top: calc(var(--header-height) + var(--top-bar-height) + var(--spacing-md));
    padding-bottom: var(--spacing-sm);
}

/* Hero Search */
.catalog-search-hero {
    max-width: 480px;
    margin: var(--spacing-sm) auto 0;
    position: relative;
}

.catalog-search-hero__icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--color-text-muted);
    pointer-events: none;
}

.catalog-search-hero__input {
    width: 100%;
    padding: 10px 16px 10px 42px;
    border: 1px solid var(--border-color);
    border-radius: 100px;
    background: var(--color-bg-secondary);
    font-size: 0.95rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.catalog-search-hero__input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(58, 58, 60, 0.08);
}

/* Catalog Layout: Sidebar + Main */
.catalog-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: var(--spacing-xl);
    align-items: start;
}

/* Sidebar */
.catalog-sidebar {
    position: sticky;
    top: calc(var(--header-height) + var(--top-bar-height) + var(--spacing-md));
    will-change: transform;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    background: var(--color-bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-sm) var(--spacing-sm);
    box-shadow: var(--shadow-sm);
}

.catalog-sidebar__title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    padding: 0 6px;
}

/* Shared filter button styles */
.categories-buttons,
.budget-buttons {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sort-buttons {
    display: flex;
    flex-direction: row;
    gap: var(--spacing-xs);
}

.category-btn,
.budget-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 5px 8px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
    line-height: 1.3;
}

.category-btn:hover,
.budget-btn:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--color-text-primary);
}

.category-btn.active,
.budget-btn.active {
    background: var(--color-bg-dark);
    color: var(--color-text-light);
    font-weight: 600;
}

/* Sidebar divider */
.catalog-sidebar__divider {
    height: 1px;
    background: var(--border-color);
    margin: 2px 0;
}

/* Main content */
.catalog-main {
    min-width: 0;
}

/* Toolbar (sort bar + result count above grid) */
.catalog-toolbar {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.catalog-toolbar__count {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--color-text-primary);
    white-space: nowrap;
}

.catalog-toolbar__separator {
    width: 1px;
    height: 16px;
    background: var(--border-color);
    flex-shrink: 0;
}

.catalog-toolbar__label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.catalog-toolbar .sort-buttons {
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
}

.catalog-toolbar .sort-btn {
    width: auto;
    padding: 5px 14px;
    font-size: 0.78rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
    border-radius: 100px;
    background: var(--color-bg-secondary);
    cursor: pointer;
    color: var(--color-text-secondary);
    transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.catalog-toolbar .sort-btn:hover {
    border-color: var(--color-text-muted);
}

.catalog-toolbar .sort-btn.active {
    background: var(--color-bg-dark);
    color: var(--color-text-light);
    border-color: var(--color-bg-dark);
}

/* Product Grid */
.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--spacing-md);
}

/* Catalog empty state */
.catalog-empty-state {
    text-align: center;
    padding: var(--spacing-2xl) var(--spacing-md);
}

.catalog-empty-state__text {
    font-size: 0.95rem;
    color: var(--color-text-muted);
}

/* ============================================================================
   PRODUCT CARD STYLES
   ============================================================================ */
.product-card {
    background: var(--color-bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    /* CSS containment: tells browser each card is isolated — avoids global reflows */
    contain: layout style paint;
    /* Skip rendering off-screen cards — major perf win on large catalogs */
    content-visibility: auto;
    contain-intrinsic-size: auto 360px;
}

/* Hide for filtered-out cards */
.product-card.card-hidden {
    display: none;
}

.product-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.product-image-container {
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: var(--color-bg-primary);
}

.product-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
}

.product-image-placeholder svg {
    width: 64px;
    height: 64px;
    opacity: 0.3;
}

.product-badge {
    position: absolute;
    top: var(--spacing-sm);
    left: var(--spacing-sm);
    color: #fff;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.product-badge.badge-rental {
    background: #059669;
}

.product-badge.badge-purchase {
    background: #2563eb;
}

.product-category-tag {
    position: absolute;
    bottom: var(--spacing-sm);
    left: var(--spacing-sm);
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Stock availability label */
.product-stock-label {
    position: absolute;
    top: var(--spacing-sm);
    right: var(--spacing-sm);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    background: rgba(34, 197, 94, 0.15);
    color: #16a34a;
}

.product-stock-label.stock-limited {
    background: rgba(245, 158, 11, 0.18);
    color: #d97706;
    animation: pulse-limited 2s ease-in-out infinite;
}

@keyframes pulse-limited {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.product-content {
    padding: var(--spacing-md);
}

.product-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text-primary);
    margin-bottom: var(--spacing-xs);
    line-height: 1.3;
}

.product-availability {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--color-success);
    margin-bottom: var(--spacing-sm);
}

.product-availability::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--color-success);
    border-radius: 50%;
}

.product-price {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--color-text-primary);
    margin-bottom: var(--spacing-sm);
}

.product-price-unit {
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--color-text-muted);
}


/* Product Card Link */
.product-card__link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.product-card__actions {
    padding: 0 var(--spacing-md) var(--spacing-md);
}

.btn-add-to-cart {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--color-bg-dark);
    color: var(--color-text-light);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.btn-add-to-cart svg {
    flex-shrink: 0;
}

.btn-add-to-cart:hover {
    background: var(--color-accent-hover);
}

.btn-add-to-cart.added {
    background: var(--color-success);
}

/* Quantity Stepper */
.qty-stepper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: var(--color-bg-dark);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.qty-stepper__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    color: var(--color-text-light);
    cursor: pointer;
    transition: background var(--transition-fast);
    flex-shrink: 0;
}

.qty-stepper__btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.qty-stepper__btn:active {
    background: rgba(255, 255, 255, 0.25);
}

.qty-stepper__btn svg {
    flex-shrink: 0;
}

.qty-stepper__value {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--color-text-light);
    min-width: 28px;
    text-align: center;
    user-select: none;
}

/* Load More */
.catalog-load-more {
    text-align: center;
    margin-top: var(--spacing-xl);
}

@media (max-width: 1024px) {
    .catalog-layout {
        grid-template-columns: 200px 1fr;
        gap: var(--spacing-md);
    }
}

/* === MOBILE (max 768px) === */
@media (max-width: 768px) {
    /* Header compact */
    .catalog-header {
        padding-top: calc(var(--header-height) + var(--spacing-xs));
        padding-bottom: 0;
    }

    .catalog-header .section-header {
        margin-bottom: var(--spacing-xs);
    }

    .catalog-header .section-title {
        font-size: 1.2rem;
        margin-bottom: 2px;
    }

    .catalog-header .section-subtitle {
        font-size: 0.8rem;
    }

    /* Search full-width, compact */
    .catalog-search-hero {
        max-width: 100%;
        margin-top: 0;
    }

    .catalog-search-hero__input {
        padding: 8px 14px 8px 36px;
        font-size: 16px; /* prevent iOS zoom */
        border-radius: var(--radius-sm);
    }

    .catalog-search-hero__icon {
        left: 12px;
        width: 16px;
        height: 16px;
    }

    /* Single column layout */
    .catalog-layout {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    /* Sidebar → sticky horizontal scroll chips */
    .catalog-sidebar {
        position: sticky;
        top: var(--header-height);
        z-index: 50;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        overflow-x: auto;
        gap: 0;
        padding: 6px 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
        box-shadow: 0 1px 3px rgba(0,0,0,0.08);
        scrollbar-width: none;
    }

    .catalog-sidebar::-webkit-scrollbar {
        height: 0;
    }

    /* Fade hint pour indiquer le scroll horizontal */
    .catalog-sidebar {
        -webkit-mask-image: linear-gradient(to right, #000 90%, transparent 100%);
        mask-image: linear-gradient(to right, #000 90%, transparent 100%);
    }

    .catalog-sidebar__title {
        display: none;
    }

    .catalog-sidebar__divider {
        width: 1px;
        height: 20px;
        flex-shrink: 0;
        background: var(--border-color);
        margin: 0 4px;
        display: block;
    }

    .categories-buttons,
    .budget-buttons {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        flex-shrink: 0;
        gap: 4px;
    }

    .category-btn,
    .budget-btn {
        width: auto;
        flex-shrink: 0;
        white-space: nowrap;
        padding: 5px 10px;
        font-size: 0.72rem;
        border-radius: 100px;
        min-height: 28px;
        line-height: 1;
        border: 1px solid var(--border-color);
        text-align: center;
    }

    .category-btn.active,
    .budget-btn.active {
        border-color: var(--color-bg-dark);
    }

    /* Toolbar compact — single line */
    .catalog-toolbar {
        flex-wrap: nowrap;
        gap: 6px;
        overflow-x: auto;
        margin-bottom: 8px;
        scrollbar-width: none;
    }

    .catalog-toolbar::-webkit-scrollbar {
        display: none;
    }

    .catalog-toolbar__separator,
    .catalog-toolbar__label {
        display: none;
    }

    .catalog-toolbar__count {
        flex-shrink: 0;
        font-size: 0.72rem;
    }

    .catalog-toolbar .sort-buttons {
        flex-wrap: nowrap;
    }

    .catalog-toolbar .sort-btn {
        flex-shrink: 0;
        white-space: nowrap;
        font-size: 0.7rem;
        padding: 4px 10px;
        min-height: 28px;
    }

    /* Product grid — 2-col compact */
    .catalog-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .product-card {
        border-radius: var(--radius-sm);
    }

    .product-card:hover {
        transform: none;
        box-shadow: none;
    }

    .product-image-container {
        aspect-ratio: 4 / 5;
    }

    .product-content {
        padding: 8px;
    }

    .product-name {
        font-size: 0.8rem;
        line-height: 1.25;
        margin-bottom: 2px;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .product-availability {
        font-size: 0.65rem;
        margin-bottom: 3px;
    }

    .product-availability::before {
        width: 5px;
        height: 5px;
    }

    .product-price {
        font-size: 0.88rem;
        margin-bottom: 4px;
    }

    .product-price-unit {
        font-size: 0.62rem;
    }

    .product-category-tag {
        font-size: 0.58rem;
        padding: 2px 6px;
    }

    .product-badge {
        padding: 3px 7px;
        font-size: 0.6rem;
        top: 6px;
        left: 6px;
    }

    .product-stock-label {
        padding: 2px 6px;
        font-size: 0.58rem;
        top: 6px;
        right: 6px;
    }

    /* Add-to-cart: icon only */
    .product-card__actions {
        padding: 0 8px 8px;
    }

    .btn-add-to-cart {
        padding: 7px;
        font-size: 0.8rem;
        gap: 4px;
        min-height: 34px;
        border-radius: var(--radius-sm);
    }

    .btn-add-to-cart span {
        display: none;
    }

    .btn-add-to-cart svg {
        width: 16px;
        height: 16px;
        flex-shrink: 0;
    }

    /* Qty stepper compact */
    .qty-stepper {
        border-radius: var(--radius-sm);
        min-height: 34px;
    }

    .qty-stepper__btn {
        width: 34px;
        height: 34px;
    }

    .qty-stepper__btn svg {
        width: 14px;
        height: 14px;
    }

    .qty-stepper__value {
        font-size: 0.85rem;
        min-width: 22px;
    }
}

/* === SMALL MOBILE (max 480px) === */
@media (max-width: 480px) {
    .catalog-header .section-title {
        font-size: 1.1rem;
    }

    /* Stay 2-col for density */
    .catalog-grid {
        gap: 6px;
    }

    .product-name {
        font-size: 0.75rem;
    }

    .product-price {
        font-size: 0.82rem;
    }

    .product-availability {
        display: none;
    }

    .product-badge {
        display: none;
    }

    .product-category-tag {
        display: none;
    }

    .product-stock-label {
        padding: 2px 5px;
        font-size: 0.55rem;
        top: 4px;
        right: 4px;
    }

    .product-content {
        padding: 6px;
    }

    .product-card__actions {
        padding: 0 6px 6px;
    }
}
