/* Category Page Styles - Improved & Compact Version */

.category-page-container {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
}

.category-page-inner {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 40px;
    align-items: start;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 20px;
    box-sizing: border-box;
}

/* Sidebar Styles */
.category-sidebar {
    position: sticky;
    top: 20px;
}

.category-sidebar-inner {
    background: #f9f9f9;
    border-radius: 8px;
    padding: 24px;
    border: 1px solid #e0e0e0;
}

.category-sidebar-title {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 20px 0;
    color: #333;
    border-bottom: 2px solid #333;
    padding-bottom: 12px;
}

/* Category Menu Styles */
.category-menu {
    margin: 0;
}

.category-menu-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.category-menu-list.level-0 {
    margin: 0;
}

.category-menu-list.level-1,
.category-menu-list.level-2 {
    margin-left: 20px;
    margin-top: 4px;
    display: none;
}

.category-menu-item.expanded > .category-menu-list {
    display: block;
}

.category-menu-item {
    margin: 0 0 4px 0;
    position: relative;
}

.category-menu-item-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
    position: relative;
}

/* Active category indicator */
.category-menu-item.active > .category-menu-item-wrapper {
    border-left: 3px solid #2c5aa0;
    padding-left: 8px;
    margin-left: -3px;
}

.category-menu-item.active > .category-menu-item-wrapper .category-link {
    font-weight: 700;
    color: #2c5aa0;
}

.category-link {
    flex: 1;
    display: block;
    padding: 8px 12px;
    color: #333;
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.2s ease;
    font-size: 15px;
}

.category-link:hover {
    background: #e8e8e8;
    color: #000;
}

.category-menu-item.in-path > .category-menu-item-wrapper .category-link {
    color: #1a1a1a;
    font-weight: 500;
}

/* Toggle Button Styles */
.category-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: #666;
    font-size: 12px;
    min-width: 28px;
    min-height: 28px;
    flex-shrink: 0;
    border-radius: 4px;
}

.category-toggle:hover {
    color: #333;
    background: #e8e8e8;
}

.category-toggle:focus {
    outline: 2px solid #2c5aa0;
    outline-offset: 2px;
}

.category-menu-item.expanded > .category-menu-item-wrapper .category-toggle .toggle-icon {
    transform: rotate(90deg);
}

.toggle-icon {
    display: inline-block;
    transition: transform 0.2s ease;
    font-size: 10px;
}

/* Content Styles */
.category-content {
    min-height: 400px;
}

.category-header {
    margin-bottom: 24px;
}

.category-title {
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 12px 0;
    color: #1a1a1a;
}

.category-description {
    color: #666;
    line-height: 1.6;
    margin: 0;
    font-size: 14px;
}

/* IMPROVED: Smaller Subcategory Boxes */
.category-subcategories {
    background: #f5f5f5;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 28px;
    border: 1px solid #e0e0e0;
}

.subcategories-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 16px 0;
    color: #333;
}

.subcategories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.subcategory-card {
    background: #fff;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    text-align: center;
    transition: all 0.3s ease;
    display: block;
    position: relative;
}

.subcategory-card:hover {
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
    border-color: #2c5aa0;
}

/* Make entire card clickable */
.subcategory-card-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px;
    text-decoration: none;
    color: inherit;
    height: 100%;
}

.subcategory-image-wrapper {
    width: 100%;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    overflow: hidden;
    border-radius: 4px;
    background: #fafafa;
}

.subcategory-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.subcategory-title {
    font-size: 13px;
    font-weight: 600;
    margin: 0;
    line-height: 1.3;
    color: #333;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.2s ease;
}

.subcategory-card:hover .subcategory-title {
    color: #2c5aa0;
}

/* IMPROVED: Product Grid - 5 columns, compact design */
.category-products {
    margin-top: 24px;
}

/* Strong overrides for WooCommerce default product grid */
.category-products .woocommerce {
    width: 100%;
}

.category-products .products {
    display: grid !important;
    grid-template-columns: repeat(5, 1fr) !important;
    gap: 16px;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
    clear: both !important;
}

/* Remove ALL WooCommerce clearfix pseudo-elements that cause layout issues */
.category-products .products::before,
.category-products .products::after,
.category-products .products li::before,
.category-products .products li::after {
    display: none !important;
    content: none !important;
}

.category-products ul.products::before,
.category-products ul.products::after {
    display: none !important;
    content: none !important;
}

/* IMPROVED: Compact Product Cards with flex layout for bottom alignment */
.category-products .product,
.category-products li.product {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 12px;
    transition: all 0.3s ease;
    display: flex !important;
    flex-direction: column !important;
    text-align: center;
    width: auto !important;
    margin: 0 !important;
    float: none !important;
    clear: none !important;
    list-style: none !important;
    min-height: 280px;
    max-height: 280px;
    box-sizing: border-box !important;
    overflow: hidden;
}

.category-products .product::before,
.category-products .product::after,
.category-products li.product::before,
.category-products li.product::after {
    display: none !important;
    content: none !important;
}

.category-products .product:hover,
.category-products li.product:hover {
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
    border-color: #2c5aa0;
}

/* Product Image - Centered vertically */
.category-products .product .product-image-wrapper {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 130px !important;
    min-height: 130px !important;
    max-height: 130px !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden;
    width: 100%;
    flex: 0 0 130px !important;
    background: transparent !important;
}

.category-products .product .product-image-wrapper a {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 100% !important;
    text-decoration: none !important;
}

.category-products .product .woocommerce-loop-product__link {
    text-decoration: none !important;
    color: inherit;
    display: block;
}

.category-products .product img {
    width: auto !important;
    height: auto !important;
    max-height: 120px !important;
    max-width: 100% !important;
    object-fit: contain !important;
    margin: auto !important;
    padding: 0 !important;
    border-radius: 4px;
    display: block !important;
    vertical-align: middle !important;
}

.category-products .product .attachment-woocommerce_thumbnail {
    width: auto !important;
    height: auto !important;
    max-height: 120px !important;
    max-width: 100% !important;
    object-fit: contain !important;
}

/* Product content wrapper to push button to bottom */
.category-products .product .product-bottom-content {
    margin-top: auto !important;
    padding-top: 10px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
    width: 100%;
    flex: 1 1 auto !important;
    justify-content: flex-end !important;
    align-items: stretch;
}

/* IMPROVED: Smaller Product Title with Ellipsis */
.category-products .product .woocommerce-loop-product__title {
    font-size: 13px !important;
    font-weight: 600 !important;
    line-height: 1.3 !important;
    margin: 0 0 6px 0 !important;
    padding: 0 !important;
    color: #333 !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 2.4em;
    max-height: 2.4em;
    width: 100%;
}

.category-products .product .product-bottom-content a:hover .woocommerce-loop-product__title {
    color: #2c5aa0 !important;
}

/* Links in bottom content */
.category-products .product .product-bottom-content > a:not(.button) {
    text-decoration: none;
    color: inherit;
    display: block;
    width: 100%;
}

/* Product Price */
.category-products .product .price {
    font-size: 14px !important;
    font-weight: 700 !important;
    color: #2c5aa0 !important;
    margin: 6px 0 !important;
    display: block !important;
    width: 100%;
}

.category-products .product .price del {
    opacity: 0.6;
    font-size: 12px;
    margin-right: 6px;
}

.category-products .product .price ins {
    text-decoration: none;
}

/* Prevent any absolute positioning on product elements */
.category-products .product * {
    position: relative !important;
}

.category-products .product,
.category-products .product .woocommerce-loop-product__link,
.category-products .product .product-image-wrapper,
.category-products .product .product-bottom-content {
    position: relative !important;
}

/* Add to Cart Button - Always at bottom */
.category-products .product .button,
.category-products .product .added_to_cart {
    font-size: 12px !important;
    padding: 7px 12px !important;
    background: #2c5aa0 !important;
    color: #fff !important;
    border: none !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    text-decoration: none !important;
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    text-align: center !important;
    box-sizing: border-box !important;
    flex: 0 0 auto !important;
}

.category-products .product .button:hover,
.category-products .product .added_to_cart:hover {
    background: #1e3d6f !important;
    transform: translateY(-1px);
}

/* Override any WooCommerce positioning */
.category-products .product a.button {
    position: relative !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
}

/* No products message */
.no-products-message {
    padding: 40px;
    text-align: center;
    background: #f9f9f9;
    border-radius: 8px;
    color: #666;
    font-size: 16px;
}

/* Category Overview Grid */
.category-overview {
    margin-top: 24px;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.category-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    text-align: center;
    transition: all 0.3s ease;
    display: block;
    position: relative;
}

.category-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.category-card-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    text-decoration: none;
    color: inherit;
}

.category-image {
    width: 100%;
    height: auto;
    max-height: 120px;
    object-fit: contain;
    border-radius: 4px;
    margin-bottom: 12px;
}

.category-card-title {
    font-size: 16px;
    margin: 0;
    color: #333;
    transition: color 0.2s ease;
}

.category-card:hover .category-card-title {
    color: #2c5aa0;
}

/* Custom Pagination */
.category-pagination {
    margin-top: 32px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 8px;
}

.pagination-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.pagination-info {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

.pagination-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}

.pagination-item {
    margin: 0;
}

.pagination-link {
    display: inline-block;
    padding: 8px 14px;
    background: #fff;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s ease;
    font-weight: 500;
    min-width: 40px;
    text-align: center;
}

.pagination-link:hover:not(.current) {
    background: #2c5aa0;
    color: #fff;
    border-color: #2c5aa0;
    transform: translateY(-1px);
}

.pagination-link.current {
    background: #2c5aa0;
    color: #fff;
    border-color: #2c5aa0;
    font-weight: 700;
    cursor: default;
}

/* Loading state */
.category-products.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .category-products .products {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}

@media (max-width: 1024px) {
    .category-page-inner {
        grid-template-columns: 240px 1fr;
        gap: 24px;
    }
    
    .category-products .products {
        grid-template-columns: repeat(3, 1fr) !important;
    }
    
    .subcategories-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    }
}

@media (max-width: 768px) {
    .category-page-inner {
        grid-template-columns: 1fr;
        padding: 20px 10px;
    }
    
    .category-sidebar {
        position: static;
    }
    
    .category-sidebar-inner {
        padding: 16px;
    }
    
    .category-products .products {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px;
    }
    
    .category-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .subcategories-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
    
    .subcategory-card {
        padding: 10px;
    }
    
    .subcategory-image-wrapper {
        height: 70px;
    }
    
    .category-title {
        font-size: 22px;
    }
}

@media (max-width: 480px) {
    .category-page-inner {
        padding: 16px 8px;
    }
    
    .category-products .products {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }
    
    .category-products .product {
        padding: 10px;
        min-height: 260px;
        max-height: 260px;
    }
    
    .category-products .product .product-image-wrapper {
        height: 110px !important;
        min-height: 110px !important;
        max-height: 110px !important;
        flex: 0 0 110px !important;
    }
    
    .category-products .product img {
        max-height: 100px !important;
    }
    
    .category-products .product .woocommerce-loop-product__title {
        font-size: 12px !important;
    }
    
    .category-products .product .price {
        font-size: 13px !important;
        margin: 4px 0 !important;
    }
    
    .category-products .product .button {
        font-size: 11px !important;
        padding: 6px 10px !important;
    }
    
    .subcategories-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .category-menu-list.level-1,
    .category-menu-list.level-2 {
        margin-left: 12px;
    }
    
    .category-link {
        font-size: 14px;
        padding: 6px 10px;
    }
}