/* Category Product Widget Styles */

/* Mobile Filter Button - Hidden on desktop */
.cp-mobile-filter-btn {
    display: none;
}

/* Toolbar */
.cp-toolbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    padding: 10px 0;
}

/* Compare Toggle Switch */
.cp-compare-switch {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cp-switch-label {
    font-size: 14px;
    color: #333;
}

.cp-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.cp-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.cp-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 26px;
}

.cp-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.cp-switch input:checked + .cp-slider {
    background-color: #e67e22;
}

.cp-switch input:checked + .cp-slider:before {
    transform: translateX(24px);
}

/* View Switch */
.cp-view-switch {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cp-view-label {
    font-size: 14px;
    color: #333;
}

.cp-view-btn {
    width: 36px;
    height: 36px;
    border: 1px solid #ddd;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    transition: all 0.3s;
}

.cp-view-btn:hover,
.cp-view-btn.active {
    border-color: #333;
    color: #333;
    background: transparent;
}

/* Products Container - Grid View */
.cp-products-container {
    display: grid;
    gap: 20px;
}

.cp-products-container.cp-view-grid {
    grid-template-columns: repeat(4, 1fr);
}

.cp-products-container.cp-view-list {
    grid-template-columns: 1fr;
}

/* Product Card - Grid View */
.cp-product-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    padding: 15px;
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.3s ease;
}

.cp-product-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* Compare Checkbox */
.cp-compare-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    cursor: pointer;
    user-select: none;
}

.cp-compare-input {
    width: 14px;
    height: 14px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid #c3c3c3;
    background: transparent;
    position: relative;
    border-radius: 2px;
}

.cp-compare-input:checked {
    background: #333;
    border-color: #333;
}

.cp-compare-input:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 4px;
    height: 8px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.cp-compare-text {
    font-size: 16px;
    color: #4d4d4d;
    font-weight: 400;
    transition: color 0.2s;
}

.cp-compare-input:checked + .cp-compare-text {
    color: #333;
    font-weight: 700;
}

/* Product Content Wrapper */
.cp-product-content {
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* Product Image */
.cp-product-image {
    width: 100%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
}

.cp-product-image img {
    width: 100%;
    height: auto;
    object-fit: contain;
    max-height: 250px;
}

/* Product Info */
.cp-product-info {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.cp-product-title {
    font-size: 14px;
    font-weight: 400;
    color: #333;
    margin: 0 0 10px 0;
    line-height: 1.4;
}

.cp-product-title a {
    color: inherit;
    text-decoration: none;
}

.cp-product-title a:hover {
    color: #e67e22;
}

/* Product Description - Hidden in Grid, Shown in List */
.cp-view-grid .cp-product-desc,
.cp-view-grid .cp-view-details {
    display: none;
}

.cp-product-desc {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
    margin-bottom: 15px;
}

.cp-view-details {
    font-size: 14px;
    color: #333;
    text-decoration: underline;
    margin-bottom: 15px;
    display: inline-block;
}

.cp-view-details:hover {
    color: #e67e22;
}

/* Inquiry Button */
.cp-inquiry-btn {
    background-color: #e67e22;
    color: #fff;
    border: none;
    padding: 12px 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    text-align: center;
    width: 100%;
    margin-top: auto;
}

.cp-inquiry-btn:hover {
    background-color: #d35400;
}

/* List View Styles */
.cp-view-list .cp-product-card {
    display: flex;
    flex-direction: column;
    padding: 20px;
    position: relative;
}

.cp-view-list .cp-compare-checkbox {
    width: 100%;
    margin-bottom: 0;
}

.cp-view-list .cp-product-content {
    display: flex;
    flex-direction: row;
    gap: 30px;
    margin-top: 20px;
}

.cp-view-list .cp-product-image {
    width: 300px;
    min-width: 300px;
    margin-bottom: 0;
    border: 1px solid #eee;
}

.cp-view-list .cp-product-image img {
    width: 100%;
    height: auto;
    object-fit: contain;
}

.cp-view-list .cp-product-info {
    flex: 1;
    padding-top: 0;
}

.cp-view-list .cp-product-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 15px;
}

.cp-view-list .cp-product-desc {
    display: block;
}

.cp-view-list .cp-view-details {
    display: inline-block;
}

.cp-view-list .cp-inquiry-btn {
    width: auto;
    max-width: 300px;
}

/* Responsive - Tablet */
@media (max-width: 1024px) {
    .cp-products-container.cp-view-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .cp-view-list .cp-product-image {
        width: 250px;
        min-width: 250px;
    }
}

/* Responsive - Mobile */
@media (max-width: 767px) {
    .cp-toolbar {
        flex-wrap: wrap;
        justify-content: space-between;
    }
    
    .cp-products-container.cp-view-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .cp-view-list .cp-product-card {
        flex-direction: column;
    
    
    .cp-view-list .cp-compare-checkbox {
        position: static;
        margin-bottom: 10px;
    }
    
    .cp-view-list .cp-product-image {
        width: 100%;
        min-width: auto;
    }
    
    .cp-view-list .cp-inquiry-btn {
        width: 100%;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .cp-products-container.cp-view-grid {
        grid-template-columns: 1fr;
    }
}

/* Loading State */
.cp-products-wrapper.loading {
    position: relative;
    pointer-events: none;
}

.cp-products-wrapper.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    z-index: 10;
}

.cp-products-wrapper.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid #ddd;
    border-top-color: #e67e22;
    border-radius: 50%;
    z-index: 11;
    animation: cp-spin 0.8s linear infinite;
}

@keyframes cp-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Disable WooCommerce/Theme animations for filtered products */
.cp-products-container .cp-product-card {
    animation: none !important;
    transition: box-shadow 0.3s ease !important;
    opacity: 1 !important;
    transform: none !important;
}

.cp-products-container .cp-product-card.wd-animation-ready,
.cp-products-container .cp-product-card.wd-animated {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
}

/* No Products Message */
.cp-no-products {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-size: 16px;
    grid-column: 1 / -1;
}

/* Pagination */
.cp-pagination {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 30px;
}

a.cp-page-nav,
span.cp-page-nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent !important;
    border: none !important;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    color: #333;
}

a.cp-page-nav:hover,
span.cp-page-nav:hover {
    color: #000;
    background: transparent !important;
}

.cp-page-nav.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.cp-page-nav svg,
.cp-page-nav .e-font-icon-svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.cp-page-numbers {
    display: flex;
    align-items: center;
    gap: 8px;
}

a.cp-page-number,
span.cp-page-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    font-size: 14px;
    color: #666;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
}

a.cp-page-number:hover {
    color: #333;
    border-color: #333;
}

span.cp-page-number.active {
    color: #fff !important;
    background: #000 !important;
    border-color: #000 !important;
    cursor: default;
}

/* Hide products based on pagination */
.cp-product-card.cp-hidden {
    display: none !important;
}

/* Page transition animation */
.cp-products-container {
    transition: opacity 0.2s ease;
}

.cp-products-container.cp-page-transition {
    opacity: 0;
}

/* Mobile Styles */
@media (max-width: 767px) {
    /* Hide original filter widget on mobile */
    .pf-container {
        display: none !important;
    }
    
    /* Mobile Filter Button */
    .cp-mobile-filter-btn {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        padding: 8px 0;
        font-size: 14px;
        color: #333;
        cursor: pointer;
        border: none;
        background: transparent;
    }
    
    .cp-mobile-filter-btn svg {
        width: 18px;
        height: 18px;
    }
    
    /* Mobile Toolbar Layout */
    .cp-products-wrapper {
        position: relative;
    }
    
    .cp-products-wrapper > .cp-mobile-filter-btn {
        position: absolute;
        left: 0;
        top: 10px;
    }
    
    .cp-toolbar {
        justify-content: flex-end;
        padding: 10px 0;
        border-bottom: 1px solid #eee;
    }
    
    /* Hide compare switch on mobile */
    .cp-toolbar .cp-compare-switch {
        display: none;
    }
    
    .cp-toolbar .cp-view-label {
        display: none;
    }
    
    /* Mobile Grid - 2 columns */
    .cp-products-container.cp-view-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .cp-product-card {
        padding: 10px;
    }
    
    /* Hide short description and view details on mobile */
    .cp-product-desc,
    .cp-view-details {
        display: none !important;
    }
    
    /* Mobile list view - horizontal with vertical center */
    .cp-view-list .cp-product-content {
        display: flex;
        flex-direction: row !important;
        align-items: center;
        gap: 10px;
    }
    
    .cp-view-list .cp-product-image {
        flex-shrink: 0;
        margin-bottom: 0 !important;
    }
    
    .cp-view-list .cp-product-info {
        flex: 1;
        gap: 8px !important;
    }
    
    .cp-view-list .cp-product-title {
        margin-bottom: 8px !important;
        font-size: 13px !important;
    }
    
    .cp-view-list .cp-inquiry-btn {
        margin-top: 0 !important;
        padding: 8px 12px !important;
        font-size: 12px !important;
    }
    
    /* Mobile Filter Sidebar - From Left */
    .cp-filter-sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 70%;
        height: 100%;
        background: #fff;
        z-index: 9999;
        transition: left 0.3s ease;
        overflow-y: auto;
        box-shadow: 5px 0 15px rgba(0,0,0,0.1);
    }
    
    .cp-filter-sidebar.active {
        left: 0;
    }
    
    .cp-filter-sidebar-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 15px;
        border-bottom: 1px solid #eee;
    }
    
    .cp-filter-sidebar-title {
        font-size: 18px;
        font-weight: 600;
    }
    
    .cp-filter-sidebar-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        cursor: pointer;
        font-size: 24px;
    }
    
    .cp-filter-sidebar-content {
        padding: 15px;
    }
    
    .cp-filter-sidebar-content .pf-container {
        display: block !important;
    }
    
    /* Filter Overlay */
    .cp-filter-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 9998;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }
    
    .cp-filter-overlay.active {
        opacity: 1;
        visibility: visible;
    }
}
