.machinery-categories {
    padding: 40px 0;
}

.page-header {
    text-align: center;
    margin-bottom: 50px;
}

.page-title {
    font-size: 2.5rem;
    margin-bottom: 10px;
    color: var(--secondary-color);
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.category-item {
    text-align: center;
}

.category-link {
    display: block;
    text-decoration: none;
    color: inherit;
    transition: transform 0.3s ease;
}

.category-link:hover {
    transform: translateY(-5px);
}

.category-image {
    width: 150px;
    height: 150px;
    margin: 0 auto 15px;
    border-radius: 50%;
    background-color: #f5f5f5;
    overflow: visible;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.3s ease;
    position: relative;
}

.category-link:hover .category-image {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.category-image img {
    width: 120%;
    height: 120%;
    object-fit: contain;
    position: relative;
    z-index: 2;
    transition: transform 0.3s ease;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.1));
}

.category-link:hover .category-image img {
    transform: scale(1.1);
}

.category-title {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: #333;
    font-weight: 600;
}

.category-description {
    font-size: 0.9rem;
    color: #666;
    line-height: 1.4;
    margin: 0;
}

.no-categories {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: #666;
}

/* Subcategory indicator */
.subcategory-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--primary-color);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    z-index: 3;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.category-link:hover .subcategory-indicator {
    background: var(--secondary-color);
}

/* Popup styles */
.subcategories-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.subcategories-popup.active {
    opacity: 1;
    visibility: visible;
}

.popup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.popup-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 95vw;
    min-width: 80vw;
    max-height: 90vh;
    overflow: hidden;
    transition: transform 0.3s ease;
}

.subcategories-popup.active .popup-content {
    transform: translate(-50%, -50%) scale(1);
}

.popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 25px 30px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
}

.popup-title {
    margin: 0;
    font-size: 1.5rem;
    color: #333;
    font-weight: 600;
}

.popup-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    padding: 5px;
    line-height: 1;
    transition: color 0.3s ease;
}

.popup-close:hover {
    color: #333;
}

.popup-categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    padding: 30px;
    max-height: 60vh;
    overflow-y: auto;
}

.subcategory-item {
    text-align: center;
}

.subcategory-link {
    display: block;
    text-decoration: none;
    color: inherit;
    transition: transform 0.3s ease;
}

.subcategory-link:hover {
    transform: translateY(-3px);
}

.subcategory-image {
    width: 120px;
    height: 120px;
    margin: 0 auto 15px;
    border-radius: 50%;
    background-color: #f5f5f5;
    overflow: visible;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.3s ease;
    position: relative;
}

.subcategory-link:hover .subcategory-image {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.subcategory-image img {
    width: 120%;
    height: 120%;
    object-fit: contain;
    position: relative;
    z-index: 2;
    transition: transform 0.3s ease;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.1));
}

.subcategory-link:hover .subcategory-image img {
    transform: scale(1.1);
}

/* View All special styling */
.subcategory-item.view-all .subcategory-image {
    background: var(--secondary-color);
    color: white;
}

.subcategory-item.view-all .subcategory-image i {
    font-size: 40px;
    color: white;
}

.subcategory-title {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: #333;
    font-weight: 600;
}

.subcategory-description {
    font-size: 0.8rem;
    color: #666;
    line-height: 1.3;
    margin: 0;
}

/* Prevent body scroll when popup is open */
body.popup-open {
    overflow: hidden;
}

/* Responsive */
@media (max-width: 992px) {
    .categories-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 18px;
    }
    
    .category-image {
        width: 130px;
        height: 130px;
    }
    
    .category-title {
        font-size: 1rem;
    }
}

@media (max-width: 768px) {
    .categories-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
        padding: 0 20px;
    }
    
    .category-image {
        width: 110px;
        height: 110px;
    }
    
    .category-title {
        font-size: 0.95rem;
    }
    
    .page-title {
        font-size: 2rem;
    }
    
    .popup-content {
        max-width: 95vw;
        max-height: 95vh;
    }
    
    .popup-header {
        padding: 20px;
    }
    
    .popup-title {
        font-size: 1.3rem;
    }
    
    .popup-categories-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 15px;
        padding: 20px;
    }
    
    .subcategory-image {
        width: 100px;
        height: 100px;
    }
    
    .subcategory-item.view-all .subcategory-image i {
        font-size: 30px;
    }
}

@media (max-width: 480px) {
    .categories-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }
    
    .category-image {
        width: 90px;
        height: 90px;
    }
    
    .category-title {
        font-size: 0.85rem;
    }
    
    .popup-categories-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
        padding: 15px;
    }
    
    .subcategory-image {
        width: 80px;
        height: 80px;
    }
    
    .subcategory-title {
        font-size: 1rem;
    }
}