/**
 * Optimized WooCommerce Category Display Styles
 * Version: 2.0.0
 * 
 * Features:
 * - Mobile-first responsive design
 * - CSS Grid for better performance
 * - Reduced specificity for easier customization
 * - Better accessibility support
 * - Smooth animations with GPU acceleration
 */

/* CSS Custom Properties for easy theming */
:root {
    --edpro-primary-color: #007cba;
    --edpro-primary-hover: #005a87;
    --edpro-text-color: #333;
    --edpro-text-light: #666;
    --edpro-border-color: #e0e0e0;
    --edpro-bg-light: #fff; /* ALL WHITE - NO GRAY */
    --edpro-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    --edpro-shadow-hover: 0 6px 20px rgba(0, 0, 0, 0.1);
    --edpro-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --edpro-radius: 8px;
    --edpro-spacing: 20px;
}

/* Base Category Grid */
.edpro-category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: var(--edpro-spacing);
    margin: 0;
    padding: 0;
}

.edpro-category-grid[data-columns="2"] {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.edpro-category-grid[data-columns="3"] {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.edpro-category-grid[data-columns="4"] {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}

.edpro-category-grid[data-columns="5"] {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

/* Category Item */
.edpro-category-item {
    position: relative;
    background: #fff;
    border-radius: var(--edpro-radius);
    overflow: hidden;
    transition: var(--edpro-transition);
    box-shadow: var(--edpro-shadow);
}

.edpro-category-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--edpro-shadow-hover);
}

.edpro-category-link {
    display: block;
    text-decoration: none;
    color: var(--edpro-text-color);
    height: 100%;
}

.edpro-category-image {
    aspect-ratio: 4/3;
    overflow: hidden;
    background: #fff; /* WHITE BACKGROUND */
    display: flex;
    align-items: center;
    justify-content: center;
}

.edpro-category-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.edpro-category-item:hover .edpro-category-image img {
    transform: scale(1.05);
}

.edpro-category-info {
    padding: var(--edpro-spacing);
    text-align: center;
}

.edpro-category-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0 0 0.5rem;
    color: var(--edpro-text-color);
    transition: color 0.2s ease;
}

.edpro-category-link:hover .edpro-category-title {
    color: var(--edpro-primary-color);
}

.edpro-category-count {
    font-size: 0.875rem;
    color: var(--edpro-text-light);
}

/* Desktop Toolbar */
.edpro-desktop-toolbar {
    background: #fff; /* WHITE BACKGROUND */
    border-bottom: 1px solid var(--edpro-border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    transform: translateZ(0); /* Force GPU acceleration */
}

.edpro-toolbar-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--edpro-spacing);
}

.edpro-category-nav {
    position: relative;
}

.edpro-category-menu {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin: 0;
    padding: 0.75rem 0;
    list-style: none;
}

.edpro-category-menu-item {
    position: relative;
}

.edpro-category-menu-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #fff;
    color: var(--edpro-text-color);
    text-decoration: none;
    border-radius: 4px;
    border: 1px solid var(--edpro-border-color);
    transition: var(--edpro-transition);
    font-size: 0.9375rem;
}

.edpro-category-menu-link:hover,
.edpro-category-menu-link:focus {
    background: var(--edpro-primary-color);
    color: #fff;
    border-color: var(--edpro-primary-color);
}

.edpro-dropdown-arrow {
    font-size: 0.75rem;
    transition: transform 0.3s ease;
}

.edpro-category-menu-item:hover .edpro-dropdown-arrow {
    transform: rotate(180deg);
}

/* Mega Dropdown */
.edpro-mega-dropdown {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    min-width: 600px;
    background: #fff;
    border: 1px solid var(--edpro-border-color);
    border-radius: var(--edpro-radius);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
    transform-origin: top center;
}

.edpro-category-menu-item:hover .edpro-mega-dropdown {
    opacity: 1;
    visibility: visible;
}

/* Adjust position for edge items */
.edpro-category-menu-item:first-child .edpro-mega-dropdown {
    left: 0;
    transform: translateX(0);
}

.edpro-category-menu-item:last-child .edpro-mega-dropdown {
    left: auto;
    right: 0;
    transform: translateX(0);
}

.edpro-mega-content {
    padding: 1.5rem;
}

.edpro-mega-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.edpro-mega-item {
    background: #fff; /* WHITE BACKGROUND */
    border: 1px solid var(--edpro-border-color);
    border-radius: 6px;
    overflow: hidden;
    transition: var(--edpro-transition);
}

.edpro-mega-item:hover {
    transform: translateY(-2px);
    background: #fff; /* KEEP WHITE ON HOVER */
    box-shadow: var(--edpro-shadow);
}

.edpro-mega-link {
    display: block;
    padding: 1rem;
    text-decoration: none;
    color: var(--edpro-text-color);
    text-align: center;
}

.edpro-mega-image {
    width: 60px;
    height: 60px;
    margin: 0 auto 0.75rem;
    overflow: hidden;
    border-radius: 4px;
}

.edpro-mega-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.edpro-mega-info h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0 0 0.25rem;
    color: var(--edpro-text-color);
}

.edpro-mega-count {
    font-size: 0.75rem;
    color: var(--edpro-text-light);
}

.edpro-mega-footer {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--edpro-border-color);
    text-align: center;
}

.edpro-view-all {
    color: var(--edpro-primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.edpro-view-all:hover {
    color: var(--edpro-primary-hover);
}

/* Subcategories Section */
.edpro-subcategories-section {
    margin: 2rem 0;
    padding: 2rem 0;
    background: #fff; /* WHITE BACKGROUND */
}

.edpro-subcategories-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--edpro-spacing);
}

.edpro-subcategories-title {
    text-align: center;
    font-size: 1.75rem;
    font-weight: 600;
    margin: 0 0 2rem;
    color: var(--edpro-text-color);
}

/* Mobile Categories */
.edpro-mobile-categories {
    display: none;
    border-bottom: 2px solid var(--edpro-border-color);
    margin-bottom: 1rem;
    background: #fff;
}

.edpro-mobile-header {
    font-weight: 700;
    font-size: 1rem;
    padding: 1rem;
    color: var(--edpro-text-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #fff; /* WHITE BACKGROUND */
    border-bottom: 1px solid var(--edpro-border-color);
}

.edpro-mobile-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.edpro-mobile-item {
    border-bottom: 1px solid var(--edpro-border-color);
}

.edpro-mobile-parent {
    display: flex;
    align-items: center;
    position: relative;
}

.edpro-mobile-link {
    flex: 1;
    display: flex;
    align-items: center;
    padding: 1rem;
    color: var(--edpro-text-color);
    text-decoration: none;
    font-size: 1rem;
    min-height: 48px; /* WCAG touch target */
    transition: background-color 0.2s ease;
}

.edpro-mobile-link--single {
    padding-right: 1rem;
}

.edpro-mobile-link:hover,
.edpro-mobile-link:active {
    background-color: #fff; /* WHITE ON HOVER */
    color: var(--edpro-primary-color);
}

.edpro-mobile-toggle {
    position: relative;
    width: 48px;
    height: 48px;
    padding: 0;
    background: none;
    border: none;
    color: var(--edpro-text-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.edpro-mobile-toggle:hover {
    color: var(--edpro-primary-color);
}

.edpro-mobile-toggle:focus {
    outline: 2px solid var(--edpro-primary-color);
    outline-offset: -2px;
}

.edpro-toggle-icon {
    font-size: 1.25rem;
    transition: transform 0.3s ease;
}

.edpro-mobile-toggle[aria-expanded="true"] .edpro-toggle-icon {
    transform: rotate(90deg);
}

.edpro-mobile-submenu {
    list-style: none;
    margin: 0;
    padding: 0;
    background-color: #fff; /* WHITE BACKGROUND */
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.edpro-mobile-submenu[aria-hidden="false"] {
    max-height: 1000px; /* Arbitrary large value */
}

.edpro-mobile-subitem {
    border-bottom: 1px solid var(--edpro-border-color);
}

.edpro-mobile-subitem:last-child {
    border-bottom: none;
}

.edpro-mobile-sublink {
    display: block;
    padding: 0.875rem 1rem 0.875rem 2.5rem;
    color: var(--edpro-text-light);
    text-decoration: none;
    font-size: 0.9375rem;
    transition: background-color 0.2s ease;
    min-height: 44px;
}

.edpro-mobile-sublink:hover,
.edpro-mobile-sublink:active {
    background-color: #fff; /* WHITE ON HOVER */
    color: var(--edpro-primary-color);
}

/* Responsive Breakpoints */
@media (max-width: 1200px) {
    .edpro-category-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
    
    .edpro-mega-dropdown {
        min-width: 500px;
    }
}

@media (max-width: 991px) {
    .edpro-desktop-toolbar {
        display: none;
    }
    
    .edpro-mobile-categories {
        display: block;
    }
    
    .edpro-category-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 1rem;
    }
    
    .edpro-subcategories-section {
        padding: 1.5rem 0;
    }
    
    .edpro-subcategories-title {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
    }
}

@media (max-width: 767px) {
    .edpro-category-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .edpro-category-info {
        padding: 0.75rem;
    }
    
    .edpro-category-title {
        font-size: 1rem;
    }
    
    .edpro-category-count {
        font-size: 0.8125rem;
    }
}

@media (max-width: 480px) {
    .edpro-category-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .edpro-category-image {
        aspect-ratio: 16/9;
    }
    
    .edpro-mobile-link {
        font-size: 1.0625rem;
        padding: 1.125rem 0.875rem;
    }
    
    .edpro-mobile-sublink {
        padding: 1rem 0.875rem 1rem 2rem;
        font-size: 0.9375rem;
    }
}

/* Print Styles */
@media print {
    .edpro-desktop-toolbar,
    .edpro-mobile-categories,
    .edpro-mega-dropdown {
        display: none !important;
    }
    
    .edpro-category-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .edpro-category-item,
    .edpro-mega-item {
        border: 2px solid currentColor;
    }
    
    .edpro-mobile-toggle:focus {
        outline-width: 3px;
    }
}

/* Dark Mode Support - REMOVED TO PREVENT BLACK BACKGROUNDS */
/* Commented out the entire dark mode section */

/* Loading States */
.edpro-loading {
    position: relative;
    min-height: 200px;
}

.edpro-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid var(--edpro-border-color);
    border-top-color: var(--edpro-primary-color);
    border-radius: 50%;
    animation: edpro-spin 1s linear infinite;
}

@keyframes edpro-spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}