/* Mobile Filter Toggle Button */
.mobile-filter-toggle {
    display: none;
    width: auto;
    min-width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #0066cc 0%, #004999 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0;
    box-shadow: 0 2px 8px rgba(0, 102, 204, 0.25);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 600;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.mobile-filter-toggle span {
    display: none;
}

.mobile-filter-toggle i {
    font-size: 18px;
}

.mobile-filter-toggle:hover {
    background: linear-gradient(135deg, #0052a3 0%, #003d7a 100%);
    box-shadow: 0 4px 12px rgba(0, 102, 204, 0.35);
}

.mobile-filter-toggle:active {
    transform: scale(0.98);
}

/* Product Grid Topbar - Sticky on Mobile */
.product-grid-topbar {
    position: relative;
    z-index: 100;
}

@media (max-width: 991px) {
    .product-grid-topbar {
        position: sticky;
        top: 120px; /* Account for sticky header height on mobile */
        background: #fff;
        padding: 15px;
        margin: 0 -15px 15px -15px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        z-index: 100;
    }    
    .product-sorting label {
        display: none;
    }
    
    .product-sorting select {
        font-size: 13px;
        padding: 8px;
        height: 38px;
    }
}

@media (max-width: 767px) {
    .product-grid-topbar {
        top: 120px; /* Adjust for header on smaller mobile */
        padding: 12px;
        margin: 0 -12px 15px -12px;
    }
}

/* Filter Backdrop */
.filter-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1040;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.filter-backdrop.active {
    display: block;
    opacity: 1;
}

/* Mobile Filter Close Button */
.mobile-filter-close {
    display: none;
    position: absolute;
    top: 15px;
    right: 15px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    padding: 0;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
}

.mobile-filter-close i {
    font-size: 18px;
    color: #495057;
}

.mobile-filter-close:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

/* Mobile Styles */
@media (max-width: 991px) {
    .mobile-filter-toggle {
        display: flex;
    }
    
    .mobile-filter-close {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .product-sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 85%;
        max-width: 350px;
        height: 100vh;
        background: #fff;
        z-index: 1050;
        overflow-y: auto;
        padding: 60px 20px 30px 20px;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }
    
    .product-sidebar.active {
        left: 0;
    }
    
    body.filter-open {
        overflow: hidden;
    }
}

/* Product Grid Filters - Category Tree */
.category-tree {
    max-height: 400px;
    overflow-y: auto;
}

.category-tree .toggle-children {
    text-decoration: none;
    padding: 0;
    vertical-align: middle;
}

.category-tree .toggle-children i {
    font-size: 12px;
    transition: transform 0.2s;
}

.category-tree .form-check {
    margin-bottom: 0.5rem;
}

.category-tree .form-check-label {
    cursor: pointer;
    transition: all 0.2s;
}

.category-tree .form-check-input:checked + .form-check-label {
    font-weight: 600;
    color: #0d6efd;
}

.category-tree .collapse {
    margin-top: 0.5rem;
}

.category-tree .category-parent {
    padding: 0.25rem 0;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.category-tree .category-parent:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

/* Product List - Category Display */
.product-info .category {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Product List - Title */
.product-info .title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4em;
    height: 2.8em;
}

/* Product List - Price */
.product-info .price {
    min-height: 28px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.product-info .price span {
    white-space: nowrap;
}

/* Price Input Formatting */
.price-input-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
}

.price-input-formatted {
    text-align: right;
    padding-right: 30px !important;
    font-size: 14px;
}

.price-input-formatted::placeholder {
    font-size: 12px;
    color: #adb5bd;
    font-weight: 400;
    opacity: 0.8;
}

.price-input-currency {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    pointer-events: none;
    font-size: 13px;
    font-weight: 500;
}

/* Product Image Container */
.product-image {
    position: relative;
    overflow: hidden;
    background: #f5f5f5;
}

/* Product Images */
.product-image img {
    width: 100%;
    height: 280px;
    display: block;
    object-fit: cover;
}

/* Placeholder Image */
.product-image img.placeholder {
    object-fit: contain;
    padding: 20px;
}

/* Products Grid Layout - Border Separated Grid */
.products-grid-layout {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    /* border: 1px solid #e9ecef; */
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.products-grid-layout.search-page {
    grid-template-columns: repeat(3, 1fr);
}

.products-grid-layout .product-item {
    position: relative;
    border: 1px solid #e9ecef;
    background: #fff;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

.products-grid-layout .product-item:nth-child(3n) {
    /* border-right: none; */
}

.products-grid-layout .product-item:hover {
    z-index: 10;
    box-shadow: 0 8px 24px rgba(0, 102, 204, 0.15);
}

.products-grid-layout .product-image {
    position: relative;
    width: 100%;
    padding-top: 100%;
    overflow: hidden;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    flex-shrink: 0;
    display: block;
}

.products-grid-layout .product-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.products-grid-layout .product-item:hover .product-image img {
    transform: scale(1.08);
}

/* Product Quick Actions */
.products-grid-layout .product-quick-actions {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 15px;
    background: linear-gradient(to top, rgba(189, 184, 184, 0.8), transparent);
    transform: translateY(100%);
    opacity: 0;
    transition: all 0.35s ease;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
}

.products-grid-layout .product-item:hover .product-quick-actions {
    transform: translateY(0);
    opacity: 1;
}

.products-grid-layout .quick-action-btn {
    background: #fff;
    color: #0066cc;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
}

.products-grid-layout .quick-action-btn i {
    font-size: 18px;
    transition: transform 0.3s ease;
}

.products-grid-layout .quick-action-btn:hover {
    background: #0066cc;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 102, 204, 0.4);
}

.products-grid-layout .quick-action-btn:hover i {
    transform: scale(1.1);
}

.products-grid-layout .quick-action-btn:active {
    transform: translateY(0);
}

.products-grid-layout .out-of-stock-btn {
    background: #e9ecef;
    color: #6c757d;
    cursor: not-allowed;
}

.products-grid-layout .out-of-stock-btn:hover {
    background: #e9ecef;
    color: #6c757d;
    transform: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Mobile: Always show buttons */
@media (max-width: 991px) {
    .products-grid-layout .product-quick-actions {
        transform: translateY(0);
        opacity: 1;
        background: linear-gradient(to top, rgba(0, 0, 0, 0.75), transparent);
    }
    
    .products-grid-layout .quick-action-btn {
        padding: 10px 20px;
        font-size: 13px;
    }
    
    .products-grid-layout .quick-action-btn i {
        font-size: 16px;
    }
}

@media (max-width: 767px) {
    .products-grid-layout .quick-action-btn {
        padding: 9px 16px;
        font-size: 12px;
        gap: 6px;
    }
    
    .products-grid-layout .quick-action-btn span {
        display: none;
    }
    
    .products-grid-layout .quick-action-btn i {
        font-size: 18px;
        margin: 0;
    }
    
    .products-grid-layout .quick-action-btn {
        width: 40px;
        height: 40px;
        padding: 0;
        border-radius: 50%;
        justify-content: center;
    }
}

.products-grid-layout .single-product-tags {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
    z-index: 5;
}

.products-grid-layout .single-product-tags span {
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-block;
    width: fit-content;
    white-space: nowrap;
}

.products-grid-layout .new-tag {
    background: #205ab8;
    color: #fff;
}

.products-grid-layout .sale-tag {
    background: #ff4757;
    color: #fff;
}

.products-grid-layout .product-info {
    padding: 18px 16px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
    position: relative;
}

.products-grid-layout .product-info .category {
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.products-grid-layout .product-info .title {
    margin-bottom: 10px;
}

.products-grid-layout .product-info .title a {
    color: #212529;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
    transition: color 0.2s ease;
    min-height: 42px;
}

.products-grid-layout .product-info .title a:hover {
    color: #0066cc;
}

.products-grid-layout .empty-message {
    grid-column: 1 / -1;
    padding: 40px 20px;
    text-align: center;
}

.products-grid-layout .product-info .review {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 10px;
    padding: 0;
    list-style: none;
}

.products-grid-layout .product-info .review li {
    line-height: 1;
}

.products-grid-layout .product-info .review i {
    font-size: 14px;
    color: #ffc107;
}

.products-grid-layout .product-info .review span {
    font-size: 12px;
    color: #6c757d;
    margin-left: 4px;
}

.products-grid-layout .product-info .price {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid #f0f0f0;
    min-height: 50px;
}

.products-grid-layout .product-info .price > span:first-child {
    font-size: 18px;
    font-weight: 700;
    color: #0066cc;
    white-space: nowrap;
}

.products-grid-layout .product-info .price .discount-price {
    font-size: 14px;
    color: #999;
    text-decoration: line-through;
    font-weight: 400;
    white-space: nowrap;
    word-break: keep-all;
}

/* Responsive Adjustments */
@media (max-width: 1199px) {
    .products-grid-layout {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .products-grid-layout.search-page {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 991px) {
    .products-grid-layout {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .products-grid-layout.search-page {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .products-grid-layout .product-info {
        padding: 16px 14px;
    }
    
    .products-grid-layout .product-info .title a {
        font-size: 14px;
        min-height: 39px;
    }
    
    .products-grid-layout .product-info .price > span:first-child {
        font-size: 16px;
    }
    
    .products-grid-layout .product-info .price .discount-price {
        font-size: 13px;
    }
}

@media (max-width: 767px) {
    .products-grid-layout {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .products-grid-layout .product-item:nth-child(3n) {
        border-right: 1px solid #e9ecef;
    }
    
    .products-grid-layout .product-item:nth-child(2n) {
        border-right: none;
    }
    
    .products-grid-layout .product-info {
        padding: 14px 12px;
    }
    
    .products-grid-layout .product-info .title a {
        font-size: 14px;
        min-height: 39px;
    }
    
    .products-grid-layout .product-info .price > span:first-child {
        font-size: 16px;
    }
    
    .products-grid-layout .product-info .price .discount-price {
        font-size: 13px;
    }
    
    .products-grid-layout .product-info .price {
        min-height: 48px;
    }
    
    .products-grid-layout .single-product-tags {
        top: 8px;
        right: 8px;
    }
}

@media (max-width: 575px) {
    .products-grid-layout {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .products-grid-layout .product-info {
        padding: 12px 10px;
    }
    
    .products-grid-layout .product-info .category {
        font-size: 11px;
    }
    
    .products-grid-layout .product-info .title a {
        font-size: 13px;
        min-height: 36px;
    }
    
    .products-grid-layout .product-info .review i {
        font-size: 12px;
    }
    
    .products-grid-layout .product-info .review span {
        font-size: 11px;
    }
    
    .products-grid-layout .product-info .price > span:first-child {
        font-size: 15px;
    }
    
    .products-grid-layout .product-info .price .discount-price {
        font-size: 12px;
    }
    
    .products-grid-layout .product-info .price {
        min-height: 46px;
        gap: 4px 6px;
    }
    
    .products-grid-layout .product-image {
        padding-top: 100%;
    }
}
