/* ============================================
   PUBLIC PRODUCTS - Storefront Product Listing
   ============================================ */

.products-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.products-search-form {
    flex: 1;
    max-width: 700px;
}

.search-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-input-group {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    padding: 4px 8px 4px 12px;
}

.search-input-group svg {
    color: var(--gray-400);
    flex-shrink: 0;
}

.search-input-group .form-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px;
    min-width: 280px;
}

.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
    z-index: 60;
    display: none;
    max-height: 320px;
    overflow: auto;
    border-radius: 6px;
    margin-top: 4px;
}

.suggest-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    text-decoration: none;
    color: #111827;
}

.suggest-item:hover {
    background: #f3f4f6;
}

.suggest-thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    background: #f3f4f6;
    flex-shrink: 0;
}

.suggest-thumb.placeholder {
    display: inline-block;
}

.suggest-text {
    flex: 1;
    font-size: 14px;
}

.category-dropdown {
    position: relative;
}

.category-panel {
    position: absolute;
    top: 110%;
    left: 0;
    min-width: 220px;
    background: white;
    border: 1px solid #e5e7eb;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
    padding: 8px;
    border-radius: 6px;
    display: none;
    z-index: 70;
}

.category-panel.open {
    display: block;
}

.category-panel .form-input-sm {
    width: 100%;
    margin-bottom: 8px;
    padding: 6px 10px;
    font-size: 13px;
}

.category-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 200px;
    overflow: auto;
}

.category-list li {
    padding: 8px 10px;
    cursor: pointer;
    border-radius: 4px;
}

.category-list li:hover {
    background: #f3f4f6;
}

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

.product-card {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    transform: translateY(-4px);
}

.product-card-image {
    position: relative;
    aspect-ratio: 1 / 1 !important;
    height: auto !important;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8eb 100%);
    overflow: hidden;
}

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

.product-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

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

.product-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-400);
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8eb 100%);
}

.product-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-featured {
    background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
    color: white;
}

.product-save-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
    color: var(--gray-500);
}

.product-save-btn:hover {
    background: #fff1f2;
    color: #ef4444;
    transform: scale(1.1);
}

.product-save-btn.saved {
    background: #ef4444;
    color: white;
}

.product-save-btn.saved svg {
    fill: white;
}

.product-card-body {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
    flex: 1;
}

.product-category {
    font-size: 12px;
    color: var(--primary-600);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.product-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 6px 0;
    color: var(--gray-900);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.product-seller {
    font-size: 13px;
    color: var(--gray-500);
    margin: 0;
}

.product-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-100);
    gap: 12px;
}

.product-price-rating {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.product-price {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.2;
}

.product-rating {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #f59e0b;
    font-size: 13px;
    font-weight: 500;
}

.btn-add-cart {
    width: 44px;
    height: 44px;
    min-width: 44px;
    max-width: 44px;
    border-radius: 10px;
    background: var(--primary-600);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-add-cart:hover {
    background: var(--primary-700);
    transform: scale(1.08);
}

.btn-add-cart:active {
    transform: scale(0.95);
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 40px;
    padding: 20px 0;
}

.pagination-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: white;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    color: var(--gray-700);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}

.pagination-btn:hover:not(.disabled) {
    background: var(--gray-50);
    border-color: var(--primary-500);
    color: var(--primary-600);
}

.pagination-btn.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.pagination-info {
    color: var(--gray-500);
    font-size: 14px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: white;
    border-radius: 12px;
}

.empty-state-icon {
    color: var(--gray-300);
    margin-bottom: 20px;
}

.empty-state-title {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
}

.empty-state-description {
    color: var(--gray-500);
    max-width: 400px;
    margin: 0 auto 20px;
}

/* ─── Mobile: Hide duplicate header search on products page ─── */
@media (max-width: 768px) {
    /* On the products page, the inline search toolbar replaces the header search,
       so hide the header bar to avoid the double-search + hidden subtitle issue. */
    body:has(.products-toolbar) .storefront-search {
        display: none;
    }

    /* Ensure page header text is fully visible below the (now shorter) fixed header */
    body:has(.products-toolbar) .storefront-page-header {
        padding-top: var(--space-4);
        padding-bottom: var(--space-4);
    }

    .storefront-page-subtitle {
        margin-top: 4px;
    }

    /* Search toolbar stacks cleanly */
    .products-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        margin-bottom: 20px;
    }

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

    /* Search row: input + button side-by-side */
    .search-row {
        flex-direction: column;
        gap: 10px;
    }

    .search-left {
        display: flex;
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }

    /* Override responsive.css flex-wrap: wrap that breaks the inline layout */
    .search-input-group {
        display: flex !important;
        flex-wrap: nowrap !important;
        width: 100%;
        padding: 4px 4px 4px 12px;
        align-items: center;
    }

    .search-input-group .form-input {
        min-width: 0 !important;
        flex: 1 1 0% !important;
        font-size: 15px;
        padding: 10px 8px;
        width: auto !important;
        padding-right: 8px !important;
    }

    /* Override responsive.css .products-toolbar .btn { width: 100% } */
    .search-input-group .btn,
    .search-input-group .btn.btn-primary {
        flex-shrink: 0 !important;
        flex-grow: 0 !important;
        width: auto !important;
        position: static !important;
        transform: none !important;
        padding: 10px 20px;
        border-radius: 6px;
        font-size: 14px;
        font-weight: 600;
        white-space: nowrap;
        height: auto !important;
    }

    /* Category dropdown full-width */
    .category-dropdown {
        width: 100%;
    }

    .category-dropdown .btn {
        width: 100%;
        justify-content: space-between;
        text-align: left;
    }

    .category-panel {
        left: 0;
        right: 0;
        min-width: auto;
        width: 100%;
    }


}


@media (max-width: 640px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 12px;
    }

    .product-card-image {
        height: auto !important;
    }

    .product-card-body {
        padding: 12px;
    }

    .product-category {
        font-size: 10px;
        margin-bottom: 4px;
    }

    .product-title {
        font-size: 14px;
        margin-bottom: 4px;
    }

    .product-seller {
        font-size: 12px;
    }

    .product-card-footer {
        margin-top: 10px;
        padding-top: 10px;
        gap: 8px;
    }

    .product-price {
        font-size: 16px;
    }

    .btn-add-cart {
        width: 38px;
        height: 38px;
        min-width: 38px;
        max-width: 38px;
        border-radius: 8px;
    }

    .btn-add-cart svg {
        width: 16px;
        height: 16px;
    }

    .product-save-btn {
        width: 34px;
        height: 34px;
    }

    .product-save-btn svg {
        width: 16px;
        height: 16px;
    }

    .product-badge {
        padding: 4px 8px;
        font-size: 10px;
        top: 8px;
        left: 8px;
    }

    /* Pagination compact on mobile */
    .pagination {
        gap: 8px;
        margin-top: 24px;
        padding: 16px 0;
    }

    .pagination-btn {
        padding: 8px 14px;
        font-size: 13px;
    }
}

@media (max-width: 380px) {
    .products-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .product-card-image {
        height: auto !important;
    }

    .product-card-body {
        padding: 10px;
    }

    .product-title {
        font-size: 13px;
        -webkit-line-clamp: 1;
        line-clamp: 1;
    }

    .product-price {
        font-size: 14px;
    }
}
