/**
 * Category / Search Results Page Styles
 * Designed for Cartzilla Bootstrap 5 theme
 * Matches search dropdown design quality
 */

/* ========================
   Product Card
   ======================== */

.product-card {
    transition: all 0.2s ease;
    will-change: transform, box-shadow;
    /* border: 1px solid transparent !important; */
}

.product-card:hover {
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.12) !important;
    transform: translateY(-4px);
    border-color: var(--bs-border-color) !important;
}

.product-card .card-body {
    background: #f8f9fa;
}

.product-card-img {
    aspect-ratio: 1 / 1;
    object-fit: contain;
    padding: 1rem;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: #f8f9fa;
    width: 100%;
    height: auto;
}

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

.product-card .card-footer {
    background: #fff;
}

.product-card-title {
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.8em;
    font-weight: 500;
}

.product-card-title a {
    transition: color 0.15s ease;
}

.product-card-title a:hover {
    color: var(--bs-primary) !important;
}

.product-card-price {
    font-size: 0.9375rem;
}

.product-card .badge {
    font-size: 0.6875rem;
    font-weight: 700;
    padding: 0.35em 0.65em;
    border-radius: 0.25rem;
}

/* ========================
   Page Header
   ======================== */

.cp-page-header h1 {
    font-weight: 600;
    color: var(--bs-body-color);
}

.cp-page-header .text-body-secondary {
    font-size: 0.9375rem;
}

/* ========================
   Subcategory Pills
   ======================== */

.cp-subcategories {
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--bs-border-color);
}

.cp-subcategories .btn {
    font-size: 0.8125rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.cp-subcategories .btn:hover {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    color: #fff;
    transform: translateY(-1px);
}

.cp-subcategories .btn .badge {
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.25em 0.5em;
}

/* ========================
   Filter Sidebar
   ======================== */

.cp-sidebar {
    /* No max-height or overflow - let sidebar flow naturally with content */
}

.cp-filters .accordion-item {
    background: transparent;
    margin-bottom: 1rem;
}

.cp-filters .accordion-button {
    background: transparent;
    color: var(--bs-body-color);
    font-size: 0.875rem;
    padding: 0.5rem 0;
    border: none;
    box-shadow: none !important;
}

.cp-filters .accordion-button:not(.collapsed) {
    background: transparent;
    color: var(--bs-body-color);
}

.cp-filters .accordion-button::after {
    background-size: 1.125rem;
    width: 1.125rem;
    height: 1.125rem;
}

.cp-filters .accordion-body {
    padding: 0.5rem 0 1rem 0;
}

/* Filter list scrolling */
.cp-filter-list {
    scrollbar-width: thin;
    scrollbar-color: var(--bs-border-color) transparent;
}

.cp-filter-list::-webkit-scrollbar {
    width: 4px;
}

.cp-filter-list::-webkit-scrollbar-track {
    background: transparent;
}

.cp-filter-list::-webkit-scrollbar-thumb {
    background: var(--bs-border-color);
    border-radius: 2px;
}

.cp-filter-list .form-check {
    padding-left: 1.75rem;
}

.cp-filter-list .form-check-label {
    cursor: pointer;
    user-select: none;
    transition: color 0.15s ease;
    font-size: 0.875rem;
}

.cp-filter-list .form-check-label:hover {
    color: var(--bs-primary);
}

.cp-filter-list .form-check-input {
    margin-top: 0.25em;
}

/* Filter search input */
.cp-filter-search input {
    border-radius: 0.375rem;
    font-size: 0.8125rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.cp-filter-search input:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.15);
}

/* Price inputs */
.cp-filter-price {
    font-size: 0.8125rem;
}

.cp-filter-price:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.15);
}

/* Price slider */
.cp-price-slider {
    cursor: pointer;
}

.cp-price-slider::-webkit-slider-thumb {
    background: var(--bs-primary);
    transition: transform 0.15s ease;
}

.cp-price-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.cp-price-slider::-moz-range-thumb {
    background: var(--bs-primary);
    transition: transform 0.15s ease;
}

.cp-price-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
}

/* Toggle switches */
.form-check-input.cp-filter-toggle {
    cursor: pointer;
}

.form-check-label {
    cursor: pointer;
    user-select: none;
}

/* Clear filters button */
#cp-clear-filters {
    transition: all 0.15s ease;
}

#cp-clear-filters:hover {
    background-color: var(--bs-secondary);
    border-color: var(--bs-secondary);
    color: #fff;
    transform: translateY(-1px);
}

/* ========================
   Sort Bar & Controls
   ======================== */

.cp-mobile-controls {
    position: sticky;
    top: 0;
    z-index: 1020;
    background: var(--bs-body-bg);
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    margin-left: -0.75rem;
    margin-right: -0.75rem;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

.cp-mobile-controls .btn {
    font-size: 0.875rem;
    font-weight: 500;
}

#cp-sort-select {
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#cp-sort-select:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.15);
}

/* View toggle buttons */
.cp-view-toggle {
    transition: all 0.15s ease;
}

.cp-view-toggle.active {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    color: #fff;
}

.cp-view-toggle:not(.active):hover {
    background-color: var(--bs-light);
}

/* ========================
   Loading & Transitions
   ======================== */

#cp-products-grid {
    transition: opacity 0.3s ease;
}

#cp-products-grid.loading {
    opacity: 0.5;
    pointer-events: none;
}

/* Skeleton placeholder shimmer */
.placeholder-glow .placeholder {
    display: block;
    animation: placeholder-glow 2s ease-in-out infinite;
}

@keyframes placeholder-glow {
    50% {
        opacity: 0.4;
    }
}

/* ========================
   No Results
   ======================== */

#cp-no-results {
    min-height: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#cp-no-results.d-none {
    display: none !important;
}

#cp-no-results i {
    opacity: 0.3;
}

#cp-no-results h4 {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

#cp-no-results p {
    max-width: 400px;
    text-align: center;
}

#cp-no-results .btn {
    margin-top: 1rem;
}

/* ========================
   Pagination
   ======================== */

.pagination {
    flex-wrap: wrap;
    gap: 0.25rem;
}

.pagination .page-link {
    border-radius: 0.375rem;
    margin: 0;
    min-width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s ease;
    border: 1px solid var(--bs-border-color);
    color: var(--bs-body-color);
}

.pagination .page-link:hover:not(.disabled) {
    background-color: var(--bs-light);
    border-color: var(--bs-border-color);
    color: var(--bs-primary);
    transform: translateY(-1px);
}

.pagination .page-item.active .page-link {
    font-weight: 700;
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    box-shadow: 0 0.125rem 0.5rem rgba(var(--bs-primary-rgb), 0.3);
}

.pagination .page-item.disabled .page-link {
    background-color: transparent;
    border-color: transparent;
    cursor: default;
}

/* ========================
   Offcanvas (Mobile Filters)
   ======================== */

.offcanvas-footer {
    background: var(--bs-body-bg);
    box-shadow: 0 -0.125rem 0.5rem rgba(0, 0, 0, 0.05);
}

.offcanvas-footer .btn {
    font-weight: 600;
    padding: 0.75rem 1.5rem;
}

#cp-filter-offcanvas {
    width: 85vw;
    max-width: 380px;
}

#cp-filter-offcanvas .offcanvas-header {
    padding: 1rem 1.25rem;
}

#cp-filter-offcanvas .offcanvas-body {
    padding: 1rem 1.25rem;
}

#cp-filter-offcanvas .cp-filters {
    padding-bottom: 0;
}

/* ========================
   List View (Desktop)
   ======================== */

@media (min-width: 768px) {
    .row-cols-1 .col {
        display: flex;
    }

    .row-cols-1 .product-card {
        flex-direction: row;
        align-items: stretch;
    }

    .row-cols-1 .product-card .card-body {
        max-width: 220px;
        min-width: 220px;
        flex-shrink: 0;
    }

    .row-cols-1 .product-card-img {
        height: 200px;
        width: 200px;
        padding: 1.25rem;
    }

    .row-cols-1 .product-card .card-footer {
        display: flex;
        flex-direction: column;
        justify-content: center;
        flex: 1;
        padding: 1.25rem !important;
    }

    .row-cols-1 .product-card-title {
        -webkit-line-clamp: 3;
        min-height: 4.2em;
        font-size: 1rem !important;
        margin-bottom: 0.75rem !important;
    }

    .row-cols-1 .product-card-price {
        font-size: 1.125rem;
    }
}

/* ========================
   Dark Mode
   ======================== */

[data-bs-theme="dark"] .product-card .card-body,
[data-bs-theme="dark"] .product-card-img {
    background: #2d2d2d;
}

[data-bs-theme="dark"] .product-card .card-footer {
    background: #1f1f1f;
}

[data-bs-theme="dark"] .product-card:hover {
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.4) !important;
    border-color: #3d3d3d !important;
}

[data-bs-theme="dark"] .cp-mobile-controls {
    background: #1f1f1f;
}

[data-bs-theme="dark"] .cp-subcategories {
    border-bottom-color: #2d2d2d;
}

[data-bs-theme="dark"] .pagination .page-link {
    background-color: #2d2d2d;
    border-color: #3d3d3d;
    color: #e9ecef;
}

[data-bs-theme="dark"] .pagination .page-link:hover:not(.disabled) {
    background-color: #3d3d3d;
    border-color: #4d4d4d;
}

[data-bs-theme="dark"] .pagination .page-item.active .page-link {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
}

[data-bs-theme="dark"] .offcanvas-footer {
    background: #1f1f1f;
    box-shadow: 0 -0.125rem 0.5rem rgba(0, 0, 0, 0.3);
}

/* ========================
   Responsive
   ======================== */

@media (max-width: 767.98px) {
    .product-card-img {
        padding: 0.75rem;
    }

    .product-card .card-footer {
        padding: 0.625rem 0.75rem 0.875rem !important;
    }

    .product-card-title {
        font-size: 0.8125rem !important;
        min-height: 2.4em;
    }

    .product-card-price {
        font-size: 0.8125rem;
    }

    .product-card .badge {
        font-size: 0.625rem;
        padding: 0.3em 0.5em;
    }

    /* List view on mobile stays as grid */
    .row-cols-1 .product-card {
        flex-direction: column;
    }

    .row-cols-1 .product-card .card-body {
        max-width: none;
        min-width: auto;
    }

    .row-cols-1 .product-card-img {
        height: auto;
        width: 100%;
    }

    /* Pagination mobile adjustments */
    .pagination .page-link {
        min-width: 36px;
        height: 36px;
        font-size: 0.8125rem;
    }
}

@media (min-width: 768px) and (max-width: 991.98px) {
    .product-card-img {
        padding: 0.75rem;
    }

    .product-card .card-footer {
        padding: 0.75rem !important;
    }
}

/* ========================
   Print
   ======================== */

@media print {
    .cp-sidebar,
    .cp-mobile-controls,
    #cp-pagination-container,
    .offcanvas,
    .cp-subcategories,
    .breadcrumb {
        display: none !important;
    }

    #cp-products-grid {
        opacity: 1 !important;
    }

    .product-card {
        page-break-inside: avoid;
        box-shadow: none !important;
        border: 1px solid #dee2e6 !important;
    }
}
