/* ==========================================================================
   Category Page Styles - MOBILE FIRST OPTIMIZED VERSION-category-style.css
   ========================================================================== */

/* CRITICAL FIXES FIRST - CANVAS VERSION */
.filters-canvas-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.5) !important;
    z-index: -1 !important;
    display: none !important;
    opacity: 0 !important;
    transition: opacity 0.3s ease !important;
    pointer-events: none !important;
}

.filters-canvas-overlay.show {
    z-index: 10000 !important;
    display: block !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* ==========================================================================
   HERO SECTION - MOBILE FIRST WITH FIXED DIMENSIONS
   ========================================================================== */

.category-hero-section {
    position: relative;
    width: 100%;
    height: 160px; /* Ultra small mobile first */
    overflow: hidden;
    margin-bottom: 1rem; /* Ridotto per mobile */
    z-index: 1;
    /* GPU Optimization */
    transform: translateZ(0);
    will-change: transform;
    backface-visibility: hidden;
}

.category-hero-image {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
    /* GPU Optimization */
    transform: translateZ(0);
    will-change: transform;
}

.category-hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
}

.category-hero-title {
    color: white;
    font-size: 1.6rem; /* Mobile first */
    font-weight: bold;
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
    margin: 0;
    padding: 0 0.5rem;
    /* Text wrapping optimized for mobile */
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    -webkit-hyphens: auto;
}

/* ==========================================================================
   SHORT DESCRIPTION - MOBILE OPTIMIZED
   ========================================================================== */

.category-short-description {
    background-color: #f8f9fa;
    padding: 1rem 0; /* Ridotto per mobile */
    margin-bottom: 0.75rem; /* Ridotto per mobile */
    position: relative;
    z-index: 2;
    overflow: hidden;
    width: 100%;
}

.category-short-description .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 0.75rem; /* Ridotto per mobile */
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.category-short-description p {
    font-size: 0.9rem; /* Mobile first */
    line-height: 1.5; /* Ottimizzato per mobile */
    color: #666;
    margin: 0;
    text-align: left; /* Meglio su mobile */
    
    /* ULTRA strong text wrapping per mobile */
    word-wrap: break-word !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    hyphens: auto !important;
    -webkit-hyphens: auto !important;
    -ms-hyphens: auto !important;
    -moz-hyphens: auto !important;
    
    /* Forza larghezza massima assoluta */
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    display: block !important;
}

/* ==========================================================================
   WOOCOMMERCE MESSAGES - MOBILE OPTIMIZED
   ========================================================================== */

.woocommerce-notices-wrapper {
    margin-bottom: 1rem; /* Ridotto per mobile */
    min-height: 0;
    transition: all 0.3s ease;
    position: relative;
    z-index: 5;
}

.woocommerce-notices-wrapper .woocommerce-message,
.woocommerce-notices-wrapper .woocommerce-error,
.woocommerce-notices-wrapper .woocommerce-info {
    background-color: #148d46;
    color: white;
    border: none;
    border-radius: 6px; /* Ridotto per mobile */
    padding: 0.75rem 1rem; /* Ridotto per mobile */
    margin: 0.4rem 0; /* Ridotto per mobile */
    position: relative;
    animation: slideDown 0.3s ease;
}

.woocommerce-notices-wrapper .woocommerce-error {
    background-color: #dc3545;
}

.woocommerce-notices-wrapper .woocommerce-info {
    background-color: #17a2b8;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   BREADCRUMB - MOBILE OPTIMIZED
   ========================================================================== */

.woocommerce-breadcrumb {
    position: relative !important;
    z-index: 100 !important;
    pointer-events: auto !important;
    margin-bottom: 1rem; /* Ridotto per mobile */
    padding: 0.75rem 0; /* Ridotto per mobile */
    background-color: #f8f9fa;
}

.woocommerce-breadcrumb a {
    pointer-events: auto !important;
    position: relative !important;
    z-index: 101 !important;
}

/* ==========================================================================
   FILTERS WRAPPER - MOBILE FIRST RESPONSIVE
   ========================================================================== */

.category-filters-wrapper {
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    margin-bottom: 1rem; /* Ridotto per mobile */
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    min-height: 60px; /* Ridotto per mobile */
    overflow: visible;
    position: relative;
    z-index: 10;
    pointer-events: auto;
    /* Mobile first: estende ai bordi */
    margin-left: -0.75rem;
    margin-right: -0.75rem;
    border-radius: 0;
    border-left: none;
    border-right: none;
}

.category-filters-wrapper .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 0.75rem; /* Ridotto per mobile */
    height: 100%;
}

.category-filters-grid {
    display: flex !important;
    align-items: stretch !important;
    flex-direction: column !important; /* Mobile first: vertical */
    gap: 1rem !important; /* Ridotto per mobile */
    min-height: 60px;
    padding: 1rem 0; /* Ridotto per mobile */
    overflow: visible;
    position: relative !important;
    z-index: 11 !important;
    pointer-events: auto !important;
}

.category-filters-grid > div {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important; /* Mobile first */
    gap: 0.75rem !important; /* Ridotto per mobile */
    width: 100%; /* Mobile first */
    flex-shrink: 0 !important;
    position: relative !important;
    z-index: 12 !important;
    pointer-events: auto !important;
    flex-wrap: wrap;
}

.category-filters-grid h4 {
    margin: 0 !important;
    font-size: 14px !important; /* Mobile first */
    font-weight: 600 !important;
    color: #333 !important;
    width: 100% !important; /* Mobile first */
    margin-bottom: 0.4rem !important; /* Mobile first */
}

/* ==========================================================================
   PRICE FILTER - MOBILE FIRST REDESIGNED
   ========================================================================== */

.filter-price {
    width: 100%; /* Mobile first */
    display: flex !important;
    align-items: stretch !important;
    flex-direction: column !important; /* Mobile first */
    gap: 0.75rem !important; /* Ridotto per mobile */
    position: relative !important;
    z-index: 15 !important;
    pointer-events: auto !important;
}

.price-filter-compact {
    display: flex;
    align-items: stretch;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
    pointer-events: auto;
}

.price-slider-wrapper {
    position: relative;
    width: 100%; /* Mobile first */
    height: 50px; /* Spazio per valori */
    display: flex;
    align-items: center;
    z-index: 20;
    pointer-events: auto;
    flex-direction: column;
    justify-content: center;
    padding: 0 15px; /* Padding per evitare overflow */
    box-sizing: border-box;
    /* Touch scrolling optimization */
    -webkit-overflow-scrolling: touch;
}

.price-slider {
    width: calc(100% - 30px); /* Mobile first con padding */
    height: 6px;
    background: #ddd;
    border-radius: 3px;
    position: relative !important;
    cursor: pointer;
    z-index: 21 !important;
    pointer-events: auto !important;
    margin: 15px 15px; /* Spazio per valori */
}

.price-slider .ui-slider-range {
    background: linear-gradient(90deg, #148d46 0%, #1ea557 100%);
    border-radius: 3px;
    height: 6px;
}

.price-slider .ui-slider-handle {
    width: 20px !important; /* Pi첫 grande per touch */
    height: 20px !important;
    background: linear-gradient(135deg, #148d46 0%, #1ea557 100%) !important;
    border: 3px solid #fff !important;
    border-radius: 50% !important;
    cursor: grab !important;
    position: absolute !important;
    top: -7px !important;
    box-shadow: 0 2px 6px rgba(20, 141, 70, 0.3) !important;
    outline: none !important;
    transition: all 0.2s ease !important;
    z-index: 22 !important;
    pointer-events: auto !important;
}

.price-slider .ui-slider-handle:hover {
    background: linear-gradient(135deg, #1ea557 0%, #148d46 100%) !important;
    box-shadow: 0 3px 8px rgba(20, 141, 70, 0.4) !important;
    transform: scale(1.1) !important;
}

.price-slider .ui-slider-handle:active {
    cursor: grabbing !important;
    transform: scale(1.05) !important;
}

.price-values-display {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    font-size: 11px; /* Mobile optimized */
    color: #148d46;
    font-weight: 600;
    pointer-events: none;
    z-index: 23;
    padding: 0 15px;
    box-sizing: border-box;
}

.price-value-min,
.price-value-max {
    background: rgba(20, 141, 70, 0.1);
    padding: 2px 5px; /* Ridotto per mobile */
    border-radius: 4px;
    white-space: nowrap;
    font-size: 10px; /* Mobile optimized */
}

.price-value-min {
    transform: translateX(-40%);
}

.price-value-max {
    transform: translateX(40%);
}

.price-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font-size: 12px; /* Mobile optimized */
    color: #666;
    text-align: center;
    padding: 0.4rem;
    background: rgba(20, 141, 70, 0.05);
    border-radius: 6px;
    margin-top: 0;
}

.price-from,
.price-to {
    font-weight: 500;
    color: #148d46;
}

#price-min,
#price-max {
    font-weight: 600;
    color: #148d46;
}

/* ==========================================================================
   BRAND FILTER - MOBILE FIRST
   ========================================================================== */

.filter-brand {
    width: 100%; /* Mobile first */
    position: relative !important;
    z-index: 15 !important;
    pointer-events: auto !important;
}

.brand-filter-compact {
    display: flex;
    align-items: center;
    position: relative;
    width: 100%;
}

.brand-select {
    padding: 0.6rem 2.5rem 0.6rem 0.75rem !important; /* Aumentato per mobile */
    border: 1px solid #ddd !important;
    border-radius: 15px !important;
    font-size: 14px !important;
    width: 100% !important; /* Mobile first */
    background: white !important;
    height: 44px !important; /* Touch target size */
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    position: relative !important;
    z-index: 999 !important;
    pointer-events: auto !important;
    box-sizing: border-box;
}

.brand-select:hover {
    border-color: #148d46 !important;
    box-shadow: 0 2px 4px rgba(20, 141, 70, 0.1) !important;
}

.brand-select:focus {
    border-color: #148d46 !important;
    box-shadow: 0 0 0 3px rgba(20, 141, 70, 0.1) !important;
    outline: none !important;
}

.brand-filter-compact::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 8px solid #148d46;
    pointer-events: none;
    z-index: 1000;
}

/* ==========================================================================
   FILTER BUTTONS - MOBILE FIRST
   ========================================================================== */

.add-filters-btn {
    background: linear-gradient(135deg, #148d46 0%, #1ea557 100%) !important;
    color: white !important;
    border: none !important;
    padding: 0.75rem 1.5rem !important; /* Aumentato per mobile */
    border-radius: 15px !important;
    font-size: 14px !important;
    cursor: pointer !important;
    height: 44px !important; /* Touch target */
    width: 100% !important; /* Mobile first */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.5rem !important;
    transition: all 0.3s ease !important;
    white-space: nowrap !important;
    box-shadow: 0 2px 4px rgba(20, 141, 70, 0.2) !important;
    position: relative !important;
    z-index: 999 !important;
    pointer-events: auto !important;
    margin-top: 0.75rem !important; /* Mobile spacing */
    box-sizing: border-box;
}

.add-filters-btn:hover {
    background: linear-gradient(135deg, #1ea557 0%, #148d46 100%) !important;
    box-shadow: 0 4px 8px rgba(20, 141, 70, 0.3) !important;
    transform: translateY(-1px) !important;
}

.add-filters-btn .plus-icon {
    font-weight: bold;
    font-size: 16px;
}

.clear-filters-btn {
    background: #dc3545 !important;
    color: white !important;
    border: none !important;
    padding: 0.75rem 1.5rem !important; /* Aumentato per mobile */
    border-radius: 15px !important;
    font-size: 14px !important;
    cursor: pointer !important;
    height: 44px !important; /* Touch target */
    width: 100% !important; /* Mobile first */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.5rem !important;
    transition: all 0.3s ease !important;
    white-space: nowrap !important;
    opacity: 0.5 !important;
    pointer-events: none !important;
    margin-left: 0 !important;
    margin-top: 0.5rem !important; /* Mobile spacing */
    position: relative !important;
    z-index: 999 !important;
    box-sizing: border-box;
}

.clear-filters-btn.active {
    opacity: 1 !important;
    pointer-events: auto !important;
    box-shadow: 0 2px 4px rgba(220, 53, 69, 0.2) !important;
}

.clear-filters-btn.active:hover {
    background: #c82333 !important;
    box-shadow: 0 4px 8px rgba(220, 53, 69, 0.3) !important;
    transform: translateY(-1px) !important;
}

/* ==========================================================================
   CANVAS SYSTEM - MOBILE FIRST OPTIMIZED WITH ACCORDIONS
   ========================================================================== */

.filters-canvas-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.5) !important;
    z-index: -1 !important;
    display: none !important;
    opacity: 0 !important;
    transition: opacity 0.3s ease !important;
    pointer-events: none !important;
}

.filters-canvas-overlay.show {
    z-index: 10000 !important;
    display: block !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

.filters-canvas {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 100%;
    max-width: 400px;
    background: white;
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.15);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    z-index: 10001;
    -webkit-overflow-scrolling: touch;
}

.filters-canvas-overlay.show .filters-canvas {
    transform: translateX(0);
}

.filters-canvas-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    z-index: 10000;
}

.filters-canvas-header {
    background: linear-gradient(135deg, #148d46 0%, #1ea557 100%);
    color: white;
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    min-height: 60px;
    box-sizing: border-box;
}

.filters-canvas-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.filters-canvas-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.filters-canvas-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.filters-canvas-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    -webkit-overflow-scrolling: touch;
}

.filters-accordions-container {
    padding: 0;
}

/* ==========================================================================
   ACCORDION SYSTEM - OPTIMIZED FOR MOBILE
   ========================================================================== */

.filters-accordion-item {
    border-bottom: 1px solid #e0e0e0;
}

.filters-accordion-item:last-child {
    border-bottom: none;
}

.filters-accordion-header {
    padding: 1rem 1.25rem;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: none;
    width: 100%;
    text-align: left;
    min-height: 60px;
    box-sizing: border-box;
    user-select: none;
}

.filters-accordion-header:hover {
    background: #f8f9fa;
}

.filters-accordion-header:focus {
    outline: 2px solid #148d46;
    outline-offset: -2px;
}

.filters-accordion-item.active .filters-accordion-header {
    background: #e8f5e8;
    color: #148d46;
    font-weight: 600;
}

.accordion-title {
    font-size: 0.95rem;
    font-weight: 500;
    flex-grow: 1;
    margin: 0;
}

.accordion-icon {
    font-size: 1.2rem;
    font-weight: bold;
    color: #148d46;
    transition: transform 0.2s ease;
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(20, 141, 70, 0.1);
    border-radius: 50%;
}

.filters-accordion-item.active .accordion-icon {
    background: rgba(20, 141, 70, 0.2);
}

.filters-accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: #fafafa;
}

.filters-accordion-body {
    padding: 0 1.25rem 1rem 1.25rem;
}

.filters-checkbox-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(224, 224, 224, 0.5);
    cursor: pointer;
    transition: background 0.2s ease;
    min-height: 48px;
    box-sizing: border-box;
}

.filters-checkbox-item:last-child {
    border-bottom: none;
}

.filters-checkbox-item:hover {
    background: rgba(20, 141, 70, 0.05);
    margin: 0 -1rem;
    padding-left: 1rem;
    padding-right: 1rem;
    border-radius: 6px;
}

.filters-checkbox-item input[type="checkbox"] {
    margin-right: 0.75rem;
    width: 20px;
    height: 20px;
    accent-color: #148d46;
    flex-shrink: 0;
}

.checkbox-term-name {
    flex-grow: 1;
    font-size: 0.9rem;
    color: #333;
}

.checkbox-term-count {
    color: #666;
    font-size: 0.8rem;
    background: rgba(20, 141, 70, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-weight: 500;
    flex-shrink: 0;
}

.filters-empty-state {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 2rem 1rem;
    font-size: 0.9rem;
}

.filters-canvas-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: stretch;
    background: #f8f9fa;
    flex-shrink: 0;
    box-sizing: border-box;
}

.filters-selected-count {
    color: #666;
    font-size: 0.85rem;
    text-align: center;
    font-weight: 500;
}

.filters-canvas-actions {
    display: flex;
    gap: 0.75rem;
    width: 100%;
}

.filters-cancel-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
    font-size: 0.9rem;
    min-height: 48px;
    font-weight: 500;
}

.filters-cancel-btn:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

.filters-apply-btn {
    background: linear-gradient(135deg, #148d46 0%, #1ea557 100%);
    color: white;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    flex: 1;
    font-size: 0.9rem;
    min-height: 48px;
    box-shadow: 0 2px 4px rgba(20, 141, 70, 0.2);
}

.filters-apply-btn:hover {
    background: linear-gradient(135deg, #1ea557 0%, #148d46 100%);
    box-shadow: 0 4px 8px rgba(20, 141, 70, 0.3);
    transform: translateY(-1px);
}

.filters-apply-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* ==========================================================================
   CANVAS RESPONSIVE ADJUSTMENTS
   ========================================================================== */

@media (min-width: 480px) {
    .filters-canvas {
        max-width: 450px;
    }
}

@media (min-width: 600px) {
    .filters-canvas {
        max-width: 480px;
    }
    
    .filters-accordion-header {
        padding: 1.25rem 1.5rem;
    }
    
    .filters-accordion-body {
        padding: 0 1.5rem 1.25rem 1.5rem;
    }
    
    .filters-canvas-header {
        padding: 1.25rem 1.5rem;
    }
    
    .filters-canvas-footer {
        padding: 1.25rem 1.5rem;
    }
}

@media (min-width: 768px) {
    .filters-canvas {
        max-width: 500px;
    }
    
    .filters-accordion-header {
        padding: 1.5rem 2rem;
        min-height: 70px;
    }
    
    .accordion-title {
        font-size: 1rem;
    }
    
    .filters-accordion-body {
        padding: 0 2rem 1.5rem 2rem;
    }
    
    .filters-checkbox-item {
        padding: 1rem 0;
        min-height: 52px;
    }
    
    .checkbox-term-name {
        font-size: 0.95rem;
    }
    
    .checkbox-term-count {
        font-size: 0.85rem;
    }
    
    .filters-canvas-header {
        padding: 1.5rem 2rem;
        min-height: 70px;
    }
    
    .filters-canvas-title {
        font-size: 1.1rem;
    }
    
    .filters-canvas-close {
        width: 44px;
        height: 44px;
        font-size: 1.75rem;
    }
    
    .filters-canvas-footer {
        padding: 1.5rem 2rem;
    }
    
    .filters-selected-count {
        font-size: 0.9rem;
    }
    
    .filters-cancel-btn,
    .filters-apply-btn {
        font-size: 0.95rem;
        min-height: 52px;
        padding: 1rem 1.25rem;
    }
}

@media (min-width: 1024px) {
    .filters-canvas {
        max-width: 520px;
    }
}

@media (min-width: 1200px) {
    .filters-canvas {
        max-width: 550px;
    }
}

/* Canvas Scrollbar Styling */
.filters-canvas-body::-webkit-scrollbar {
    width: 8px;
}

.filters-canvas-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.filters-canvas-body::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.filters-canvas-body::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* ==========================================================================
   CUSTOM CART POPUP - MOBILE FIRST OPTIMIZED
   ========================================================================== */

.custom-cart-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 999999;
    background: rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(2px);
    opacity: 0;
    transform: translateY(-100%);
    transition: all 0.3s ease;
    pointer-events: none;
    padding: 0 0.5rem; /* Mobile first */
    box-sizing: border-box;
}

.custom-cart-popup.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.popup-content {
    background: linear-gradient(135deg, #148d46 0%, #1ea557 100%);
    color: white;
    padding: 0.875rem 1rem; /* Mobile optimized */
    margin: 0.5rem auto 0; /* Mobile optimized */
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(20, 141, 70, 0.3);
    display: flex;
    align-items: center;
    gap: 0.5rem; /* Mobile optimized */
    position: relative;
    overflow: hidden;
    width: 100%;
    max-width: none; /* Mobile first */
    box-sizing: border-box;
    /* GPU Optimization */
    transform: translateZ(0);
    will-change: transform;
}

.popup-icon {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    padding: 0.4rem; /* Mobile optimized */
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    backdrop-filter: blur(10px);
}

.popup-icon svg {
    width: 20px; /* Mobile optimized */
    height: 20px;
    color: white;
}

.popup-message {
    flex-grow: 1;
    min-width: 0;
}

.popup-message h4 {
    margin: 0 0 0.2rem 0;
    font-size: 0.85rem; /* Mobile optimized */
    font-weight: 600;
    color: white;
}

.popup-message .product-name {
    margin: 0;
    font-size: 0.75rem; /* Mobile optimized */
    opacity: 0.9;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.popup-actions {
    display: flex;
    gap: 0.4rem; /* Mobile optimized */
    align-items: center;
    flex-shrink: 0;
}

.popup-cart-btn {
    background: rgba(255, 255, 255, 0.2) !important;
    color: white !important;
    text-decoration: none !important;
    padding: 0.4rem 0.6rem; /* Mobile optimized */
    border-radius: 8px;
    font-size: 0.75rem; /* Mobile optimized */
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.3rem; /* Mobile optimized */
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    white-space: nowrap;
    min-height: 36px; /* Touch target */
    min-width: 50px; /* Mobile optimized */
}

.popup-cart-btn:hover {
    background: rgba(255, 255, 255, 0.3) !important;
    color: white !important;
    text-decoration: none !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.popup-cart-btn svg {
    width: 14px; /* Mobile optimized */
    height: 14px;
    color: white;
}

.popup-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 0.4rem; /* Mobile optimized */
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    min-height: 36px; /* Touch target */
    min-width: 36px;
}

.popup-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.popup-close-btn svg {
    width: 14px; /* Mobile optimized */
    height: 14px;
    color: white;
}

.popup-timer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 0 0 12px 12px;
}

.timer-bar {
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    width: 100%;
    transition: width 7s linear;
    border-radius: 0 0 12px 12px;
}

/* Animation Effects */
.popup-content {
    animation: popupSlideIn 0.3s ease-out;
}

@keyframes popupSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.custom-cart-popup:not(.show) .popup-content {
    animation: popupSlideOut 0.3s ease-in;
}

@keyframes popupSlideOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
}

/* ==========================================================================
   LONG DESCRIPTION - MOBILE FIRST OPTIMIZED
   ========================================================================== */

.category-long-description-container,
.category-long-description-section {
    background-color: #f8f9fa;
    padding: 1.5rem 0; /* Mobile first - ridotto */
    margin-top: 1.5rem !important; /* Mobile first - ridotto */
    clear: both;
    display: block;
    position: relative;
    z-index: 1;
    overflow: hidden;
    width: 100%;
}

.category-long-description-container .container,
.category-long-description-section .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 0.75rem; /* Mobile first - ridotto */
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.category-long-description-content {
    font-size: 0.95rem; /* Mobile first */
    line-height: 1.6;
    color: #666;
    
    /* ULTRA strong text wrapping per mobile */
    word-wrap: break-word !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    hyphens: auto !important;
    -webkit-hyphens: auto !important;
    -ms-hyphens: auto !important;
    -moz-hyphens: auto !important;
    
    /* Forza larghezza massima assoluta */
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    display: block !important;
}

.category-long-description-content h2 {
    font-size: 1.5rem; /* Mobile first */
    margin-bottom: 1rem;
    color: #333;
    text-align: center;
    
    /* ULTRA strong text wrapping per titoli */
    word-wrap: break-word !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    hyphens: auto !important;
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    display: block !important;
}

.category-long-description-content h3 {
    font-size: 1.3rem; /* Mobile first */
    margin-bottom: 0.75rem;
    color: #333;
    
    /* ULTRA strong text wrapping per sottotitoli */
    word-wrap: break-word !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    hyphens: auto !important;
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    display: block !important;
}

.category-long-description-content h4,
.category-long-description-content h5,
.category-long-description-content h6 {
    /* ULTRA strong text wrapping per tutti i titoli */
    word-wrap: break-word !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    hyphens: auto !important;
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    display: block !important;
}

.category-long-description-content p {
    margin-bottom: 1rem; /* Mobile optimized */
    
    /* ULTRA strong text wrapping per paragrafi */
    word-wrap: break-word !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    hyphens: auto !important;
    -webkit-hyphens: auto !important;
    -ms-hyphens: auto !important;
    -moz-hyphens: auto !important;
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    display: block !important;
}

.category-long-description-content ul,
.category-long-description-content ol {
    margin-bottom: 1rem; /* Mobile optimized */
    padding-left: 1.5rem; /* Mobile optimized */
    
    /* ULTRA strong text wrapping per liste */
    word-wrap: break-word !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    display: block !important;
}

.category-long-description-content li {
    margin-bottom: 0.4rem; /* Mobile optimized */
    
    /* ULTRA strong text wrapping per elementi lista */
    word-wrap: break-word !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    hyphens: auto !important;
    -webkit-hyphens: auto !important;
    -ms-hyphens: auto !important;
    -moz-hyphens: auto !important;
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    display: block !important;
}

/* Text wrapping per tutti gli elementi */
.category-long-description-content *,
.category-short-description * {
    word-wrap: break-word !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
}

/* Gestione speciale per link lunghi */
.category-long-description-content a,
.category-short-description a {
    word-wrap: break-word !important;
    overflow-wrap: anywhere !important;
    word-break: break-all !important; /* Pi첫 aggressivo per URL */
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* ==========================================================================
   CONTAINER UTILITY - MOBILE FIRST
   ========================================================================== */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 0.75rem; /* Mobile first */
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    
    /* Text wrapping per tutti i contenuti del container */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.container * {
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
    box-sizing: border-box;
}

/* ==========================================================================
   WOOCOMMERCE ADJUSTMENTS - MOBILE FIRST
   ========================================================================== */

.woocommerce-products-header {
    margin-bottom: 1.5rem; /* Mobile optimized */
    position: relative;
    z-index: 3;
}

.woocommerce-products-header__title {
    display: none;
}

.woocommerce .woocommerce-pagination {
    margin-bottom: 1.5rem; /* Mobile optimized */
    clear: both;
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS - PROGRESSIVE ENHANCEMENT
   ========================================================================== */

/* SMALL MOBILE IMPROVEMENTS (480px and up) */
@media (min-width: 480px) {
    .category-hero-section {
        height: 180px;
        margin-bottom: 1.25rem;
    }
    
    .category-hero-title {
        font-size: 1.8rem;
        padding: 0 0.75rem;
    }
    
    .category-filters-wrapper {
        margin-left: -1rem;
        margin-right: -1rem;
    }
    
    .category-short-description {
        padding: 1.25rem 0;
    }
    
    .category-short-description .container,
    .category-long-description-section .container {
        padding: 0 1rem;
    }
    
    .category-short-description p {
        font-size: 1rem;
    }
    
    .category-long-description-section {
        margin-top: 1.75rem !important;
        padding: 2rem 0;
    }
    
    .popup-content {
        margin: 0.75rem auto 0;
        padding: 1rem;
        gap: 0.6rem;
    }
    
    .popup-message h4 {
        font-size: 0.9rem;
    }
    
    .popup-message .product-name {
        font-size: 0.8rem;
    }
    
    .popup-cart-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }
}

/* LARGE MOBILE/SMALL TABLET (600px and up) */
@media (min-width: 600px) {
    .category-hero-section {
        height: 200px;
    }
    
    .category-hero-title {
        font-size: 2rem;
    }
    
    .category-short-description p {
        font-size: 1.05rem;
        text-align: center;
    }
    
    .popup-content {
        max-width: 500px;
    }
    
    .custom-cart-popup {
        padding: 0 0.75rem;
    }
}

/* TABLET PORTRAIT (768px and up) */
@media (min-width: 768px) {
    .category-hero-section {
        height: 220px; /* Ottimizzato - era 250px */
        margin-bottom: 1.5rem;
    }
    
    .category-hero-title {
        font-size: 2.2rem;
    }
    
    .category-filters-wrapper {
        min-height: 70px;
        margin-left: 0;
        margin-right: 0;
        border-radius: 6px;
        border-left: 1px solid #e0e0e0;
        border-right: 1px solid #e0e0e0;
    }
    
    .category-filters-grid {
        flex-direction: row !important;
        align-items: center !important;
        gap: 2rem !important;
        flex-wrap: nowrap !important;
        padding: 1rem 0;
    }
    
    .category-filters-grid > div {
        flex-direction: row;
        justify-content: flex-start;
        width: auto;
        flex-wrap: nowrap;
    }
    
    .category-filters-grid h4 {
        font-size: 16px !important;
        width: auto !important;
        margin-bottom: 0 !important;
        white-space: nowrap;
    }
    
    .filter-price {
        min-width: 280px;
        flex-direction: row !important;
        align-items: center !important;
    }
    
    .price-filter-compact {
        min-width: 250px;
        flex-direction: row;
        align-items: center;
    }
    
    .price-slider-wrapper {
        width: 150px;
        height: 40px;
        padding: 0;
    }
    
    .price-slider {
        width: 100%;
        margin: 10px 0;
    }
    
    .price-values-display {
        top: -25px;
        padding: 0;
    }
    
    .price-value-min,
    .price-value-max {
        transform: none;
    }
    
    .price-display {
        margin-top: 10px;
        padding: 0;
        background: transparent;
        border-radius: 0;
    }
    
    .filter-brand {
        min-width: 180px;
        width: auto;
    }
    
    .brand-select {
        min-width: 160px !important;
        width: auto !important;
    }
    
    .add-filters-btn,
    .clear-filters-btn {
        width: auto !important;
        margin-top: 0 !important;
    }
    
    .clear-filters-btn {
        margin-left: 0.5rem !important;
    }
    
    .category-short-description {
        padding: 1.5rem 0;
        margin-bottom: 1rem;
    }
    
    .category-short-description p {
        font-size: 1.1rem;
        line-height: 1.6;
    }
    
    .category-long-description-section {
        margin-top: 2.5rem !important; /* Ottimizzato - era 3rem */
        padding: 2.5rem 0;
    }
    
    .category-long-description-content {
        font-size: 1.1rem;
    }
    
    .category-long-description-content h2 {
        font-size: 1.75rem;
        margin-bottom: 1.25rem;
    }
    
    .category-long-description-content h3 {
        font-size: 1.4rem;
        margin-bottom: 1rem;
    }
    
    /* Modal adjustments for tablet */
    .filters-modal-overlay.show {
        align-items: center !important;
        padding: 1rem !important;
    }
    
    .filters-modal {
        width: 90% !important;
        max-width: 700px !important;
        border-radius: 12px !important;
        transform: scale(0.9);
        max-height: 80vh;
    }
    
    .filters-modal-overlay.show .filters-modal {
        transform: scale(1);
    }
    
    .filters-modal-body {
        flex-direction: row;
        height: 400px;
        max-height: 50vh;
    }
    
    .filters-attributes-list {
        width: 40%;
        border-right: 1px solid #e0e0e0;
        border-bottom: none;
        max-height: none;
    }
    
    .filters-values-list {
        width: 60%;
        max-height: none;
    }
    
    .filters-modal-footer {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    
    .filters-modal-actions {
        width: auto;
    }
    
    .filters-cancel-btn,
    .filters-apply-btn {
        flex: none;
        min-width: 100px;
    }
    
    /* Cart popup adjustments */
    .custom-cart-popup {
        padding: 0 1rem;
    }
    
    .popup-content {
        max-width: 500px;
        margin: 1rem auto 0;
        padding: 1rem 1.5rem;
        gap: 1rem;
    }
    
    .popup-message h4 {
        font-size: 1rem;
    }
    
    .popup-message .product-name {
        font-size: 0.875rem;
    }
    
    .popup-cart-btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
}

/* DESKTOP (1024px and up) */
@media (min-width: 1024px) {
    .category-hero-section {
        height: 300px; /* Ottimizzato - era 400px */
        margin-bottom: 2rem;
    }
    
    .category-hero-title {
        font-size: 2.8rem;
        padding: 0 1rem;
    }
    
    .category-filters-grid {
        gap: 3rem !important;
    }
    
    .filter-price {
        min-width: 350px;
    }
    
    .price-filter-compact {
        min-width: 280px;
    }
    
    .price-slider-wrapper {
        width: 180px;
    }
    
    .brand-select {
        min-width: 180px !important;
    }
    
    .category-short-description .container,
    .category-long-description-section .container,
    .container {
        padding: 0 1rem;
    }
    
    .category-long-description-section {
        margin-top: 3rem !important; /* Ripristinato per desktop */
        padding: 3rem 0;
    }
    
    .category-long-description-content h2 {
        font-size: 2rem;
        margin-bottom: 1.5rem;
    }
    
    .category-long-description-content h3 {
        font-size: 1.5rem;
    }
    
    .filters-modal {
        width: 90%;
        max-width: 800px;
    }
    
    .popup-content {
        max-width: 600px;
    }
}

/* LARGE DESKTOP (1200px and up) */
@media (min-width: 1200px) {
    .category-hero-section {
        height: 400px; /* Ripristinato per large desktop */
    }
    
    .category-hero-title {
        font-size: 3.5rem;
    }
}

/* ==========================================================================
   SCROLLBAR STYLING - MOBILE FRIENDLY
   ========================================================================== */

.filters-attributes-list::-webkit-scrollbar,
.filters-values-list::-webkit-scrollbar {
    width: 8px; /* Pi첫 largo per mobile */
}

.filters-attributes-list::-webkit-scrollbar-track,
.filters-values-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.filters-attributes-list::-webkit-scrollbar-thumb,
.filters-values-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.filters-attributes-list::-webkit-scrollbar-thumb:hover,
.filters-values-list::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* ==========================================================================
   FORCE CLICKABLE ELEMENTS
   ========================================================================== */

.brand-select,
.add-filters-btn,
.clear-filters-btn,
.price-slider,
.ui-slider-handle,
.woocommerce-breadcrumb a,
.popup-cart-btn,
.popup-close-btn,
.filters-modal-close,
.attribute-item,
.value-checkbox-item {
    position: relative !important;
    z-index: 999 !important;
    pointer-events: auto !important;
}

*::before,
*::after {
    pointer-events: none;
}

.brand-filter-compact::after {
    pointer-events: none !important;
}

/* ==========================================================================
   ACCESSIBILITY & PERFORMANCE OPTIMIZATIONS
   ========================================================================== */

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .popup-content {
        border: 2px solid rgba(255, 255, 255, 0.8);
    }
    
    .popup-cart-btn,
    .popup-close-btn {
        border: 2px solid rgba(255, 255, 255, 0.8);
    }
    
    .filters-modal {
        border: 2px solid #148d46;
    }
    
    .add-filters-btn,
    .clear-filters-btn.active {
        border: 2px solid #fff;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .custom-cart-popup,
    .filters-modal,
    .popup-content,
    .timer-bar,
    .ui-slider-handle,
    .add-filters-btn,
    .clear-filters-btn,
    .popup-cart-btn,
    .popup-close-btn {
        transition: none !important;
        animation: none !important;
        transform: none !important;
    }
    
    .popup-cart-btn:hover,
    .popup-close-btn:hover,
    .add-filters-btn:hover,
    .clear-filters-btn.active:hover,
    .ui-slider-handle:hover {
        transform: none !important;
    }
}

/* Focus Styles for Accessibility */
.popup-cart-btn:focus,
.popup-close-btn:focus {
    outline: 3px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
}

.brand-select:focus,
.add-filters-btn:focus,
.clear-filters-btn:focus {
    outline: 3px solid #148d46;
    outline-offset: 2px;
}

.filters-modal-close:focus,
.filters-cancel-btn:focus,
.filters-apply-btn:focus,
.attribute-item:focus,
.value-checkbox-item:focus {
    outline: 3px solid #148d46;
    outline-offset: 2px;
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .popup-cart-btn,
    .popup-close-btn,
    .add-filters-btn,
    .clear-filters-btn,
    .brand-select {
        min-height: 44px;
        min-width: 44px;
    }
    
    .attribute-item,
    .value-checkbox-item {
        min-height: 48px;
        padding: 0.75rem 1.25rem;
    }
    
    .ui-slider-handle {
        width: 26px !important;
        height: 26px !important;
        top: -10px !important;
    }
    
    .value-checkbox-item input[type="checkbox"] {
        width: 22px;
        height: 22px;
    }
}

/* GPU Acceleration for smooth animations */
.custom-cart-popup,
.filters-modal-overlay,
.filters-modal,
.popup-content,
.category-hero-image,
.category-hero-section {
    transform: translateZ(0);
    will-change: transform;
    backface-visibility: hidden;
}

/* Touch scrolling optimization */
.filters-attributes-list,
.filters-values-list,
.filters-modal-body {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Prevent layout shifts */
.category-hero-section,
.category-filters-wrapper,
.category-short-description,
.category-long-description-section {
    contain: layout style;
}

/* Text rendering optimization */
.category-hero-title,
.category-short-description p,
.category-long-description-content {
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
/* ==========================================================================
   CATEGORY CARDS GRID SYSTEM - 3 CARD PER RIGA SU DESKTOP
   ========================================================================== */

.category-cards-section {
    background-color: transparent; /* RIMOSSO SFONDO GRIGIO */
    padding: 1rem 0; 
    margin: 0.75rem 0 0 0; /* RIMOSSO MARGINE INFERIORE */
    clear: both;
    display: block;
    position: relative;
    z-index: 3;
    overflow: hidden;
    width: 100%;
}

.category-cards-section .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 0.75rem;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.category-cards-grid {
    display: grid;
    grid-template-columns: 1fr; /* Mobile: 1 colonna */
    gap: 0.75rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 0;
    margin: 0;
    justify-content: center;
}

.category-card {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    background: white;
    height: 120px; /* Mobile */
    width: 100%;
    max-width: 280px; /* Larghezza aumentata per desktop */
    box-sizing: border-box;
    /* GPU Optimization */
    transform: translateZ(0);
    will-change: transform;
    backface-visibility: hidden;
    margin: 0 auto; /* Centra su mobile */
}

.category-card:hover {
    transform: translateY(-1px) scale(1.01);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.category-card-link {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
    color: inherit;
    position: relative;
    z-index: 4;
    pointer-events: auto;
}

.category-card-link:hover {
    text-decoration: none;
    color: inherit;
}

.category-card-image {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
    /* GPU Optimization */
    transform: translateZ(0);
    will-change: transform;
}

.category-card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        135deg,
        rgba(0, 0, 0, 0.3) 0%,
        rgba(0, 0, 0, 0.1) 50%,
        rgba(0, 0, 0, 0.4) 100%
    );
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}

.category-card:hover .category-card-overlay {
    background: linear-gradient(
        135deg,
        rgba(20, 141, 70, 0.3) 0%,
        rgba(20, 141, 70, 0.1) 50%,
        rgba(20, 141, 70, 0.4) 100%
    );
}

.category-card-content {
    text-align: center;
    padding: 0.5rem;
    width: 100%;
    box-sizing: border-box;
    position: relative;
    z-index: 5;
}

.category-card-title {
    color: white;
    font-size: 0.9rem; /* Mobile aumentato */
    font-weight: 700;
    margin: 0 0 0.2rem 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
    line-height: 1.2;
    
    /* Strong text wrapping */
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    word-break: break-word !important;
    hyphens: auto !important;
    -webkit-hyphens: auto !important;
    
    /* Prevent overflow */
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    display: block;
}

.category-card-count {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.7rem; /* Mobile aumentato */
    font-weight: 500;
    margin: 0;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    opacity: 0.9;
    transition: opacity 0.3s ease;
}

.category-card:hover .category-card-count {
    opacity: 1;
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS
   ========================================================================== */

/* SMALL MOBILE IMPROVEMENTS (480px and up) */
@media (min-width: 480px) {
    .category-cards-grid {
        gap: 1rem;
    }
    
    .category-card {
        height: 130px;
        max-width: 300px;
    }
    
    .category-card-title {
        font-size: 0.95rem;
    }
    
    .category-card-count {
        font-size: 0.75rem;
    }
    
    .category-card-content {
        padding: 0.6rem;
    }
}

/* LARGE MOBILE/SMALL TABLET (600px and up) */
@media (min-width: 600px) {
    .category-cards-section .container {
        padding: 0 1rem;
    }
    
    .category-cards-grid {
        grid-template-columns: repeat(2, 1fr); /* Tablet: 2 colonne */
        gap: 1.25rem;
        justify-content: center;
    }
    
    .category-card {
        height: 140px;
        max-width: none; /* Rimuovi limite su tablet */
        margin: 0; /* Rimuovi centratura */
    }
    
    .category-card-title {
        font-size: 1rem;
    }
    
    .category-card-count {
        font-size: 0.8rem;
    }
    
    .category-card-content {
        padding: 0.7rem;
    }
}

/* TABLET PORTRAIT (768px and up) */
@media (min-width: 768px) {
    .category-cards-section {
        padding: 1.25rem 0;
    }
    
    .category-cards-grid {
        gap: 1.5rem;
    }
    
    .category-card {
        height: 150px;
        border-radius: 10px;
    }
    
    .category-card:hover {
        transform: translateY(-2px) scale(1.02);
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
    }
    
    .category-card-title {
        font-size: 1.1rem;
        margin: 0 0 0.25rem 0;
    }
    
    .category-card-count {
        font-size: 0.85rem;
    }
    
    .category-card-content {
        padding: 0.8rem;
    }
}

/* DESKTOP (1024px and up) - 3 CARD PER RIGA */
@media (min-width: 1024px) {
    .category-cards-section {
        padding: 1.5rem 0;
    }
    
    .category-cards-grid {
        grid-template-columns: repeat(3, 1fr); /* Desktop: 3 colonne FISSE */
        gap: 2rem;
        justify-content: center;
    }
    
    .category-card {
        height: 160px; /* Altezza aumentata per desktop */
        max-width: none; /* Rimuovi limite - usa spazio disponibile */
        border-radius: 12px;
    }
    
    .category-card:hover {
        transform: translateY(-3px) scale(1.03);
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    }
    
    .category-card-title {
        font-size: 1.2rem; /* Font più grande per desktop */
    }
    
    .category-card-count {
        font-size: 0.9rem;
    }
    
    .category-card-content {
        padding: 1rem; /* Padding aumentato */
    }
}

/* LARGE DESKTOP (1200px and up) */
@media (min-width: 1200px) {
    .category-cards-section {
        padding: 1.75rem 0;
    }
    
    .category-cards-grid {
        gap: 2.5rem; /* Gap più ampio su schermi grandi */
    }
    
    .category-card {
        height: 170px; /* Altezza massima finale */
    }
    
    .category-card-title {
        font-size: 1.3rem; /* Font massimo */
        margin: 0 0 0.3rem 0;
    }
    
    .category-card-count {
        font-size: 0.95rem;
    }
    
    .category-card-content {
        padding: 1.1rem;
    }
}

/* ==========================================================================
   FALLBACK STYLES FOR EMPTY/MISSING IMAGES
   ========================================================================== */

.category-card-image[style*="data:image/svg+xml"] {
    background-color: #f8f9fa;
    border: 1px dashed #e0e0e0;
}

.category-card-image[style*="data:image/svg+xml"] .category-card-overlay {
    background: linear-gradient(
        135deg,
        rgba(108, 117, 125, 0.8) 0%,
        rgba(108, 117, 125, 0.9) 100%
    );
}

.category-card-image[style*="data:image/svg+xml"]:hover .category-card-overlay {
    background: linear-gradient(
        135deg,
        rgba(20, 141, 70, 0.8) 0%,
        rgba(20, 141, 70, 0.9) 100%
    );
}

/* ==========================================================================
   ACCESSIBILITY IMPROVEMENTS
   ========================================================================== */

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .category-card {
        border: 2px solid #148d46;
    }
    
    .category-card-overlay {
        background: rgba(0, 0, 0, 0.8) !important;
    }
    
    .category-card-title,
    .category-card-count {
        text-shadow: 3px 3px 6px rgba(0, 0, 0, 1) !important;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .category-card,
    .category-card-overlay,
    .category-card-count {
        transition: none !important;
        animation: none !important;
    }
    
    .category-card:hover {
        transform: none !important;
    }
}

/* Focus Styles for Accessibility */
.category-card-link:focus {
    outline: 3px solid #148d46;
    outline-offset: 2px;
    border-radius: 8px;
}

.category-card-link:focus .category-card {
    box-shadow: 0 0 0 4px rgba(20, 141, 70, 0.3);
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .category-card {
        min-height: 140px;
    }
    
    .category-card:hover {
        transform: scale(1.01);
    }
    
    .category-card-content {
        padding: 0.8rem;
    }
}

/* GPU Acceleration for smooth animations */
.category-card,
.category-card-image,
.category-card-overlay {
    transform: translateZ(0);
    will-change: transform;
    backface-visibility: hidden;
}

/* Prevent layout shifts */
.category-cards-section,
.category-cards-grid {
    contain: layout style;
}

/* Text rendering optimization */
.category-card-title,
.category-card-count {
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Grid fallback for older browsers */
@supports not (display: grid) {
    .category-cards-grid {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .category-card {
        width: 100%;
        max-width: 280px;
        margin: 0 0.375rem 0.75rem;
        flex-shrink: 0;
    }
    
    @media (min-width: 600px) {
        .category-card {
            width: calc(50% - 0.625rem);
            max-width: none;
        }
    
    @media (min-width: 1024px) {
        .category-card {
            width: calc(33.333% - 1.333rem);
        }
    }