/* Accessibility Styles */
.screen-reader-text {
    clip: rect(1px, 1px, 1px, 1px);
    position: absolute !important;
    height: 1px;
    width: 1px;
    overflow: hidden;
}

/* High Contrast and Focus Styles */
*:focus {
    outline: 3px solid #4CAF50;
    outline-offset: 2px;
}

.category-card:focus,
.product-card:focus {
    outline: 3px solidrgb(138, 138, 138);
    outline-offset: 2px;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

/* Enhanced Button Focus */
.toggle-categories-btn:focus {
    outline: 3px solid #fff;
    outline-offset: 2px;
    box-shadow: 0 0 0 6pxrgb(138, 138, 138);
}

/* Link Focus Enhancement */
a:focus {
    outline: 3px solidrgb(138, 138, 138);
    outline-offset: 2px;
    text-decoration: underline;
}

/* Improved Color Contrast */
.category-title,
.product-title {
    color: #1a1a1a !important;
    font-weight: 700;
}

.category-count-text {
    color: #555 !important;
    font-weight: 600;
}

.section-header h2 {
    color: #1a1a1a !important;
}

/* Zoom Support - Ensure layout works up to 200% zoom */
@media (max-width: 1200px) {
    .product-categories-grid,
    .product-list-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
}

@media (max-width: 768px) {
    .product-categories-grid,
    .product-list-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .category-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .toggle-categories-btn,
    .view-all-link {
        justify-content: center;
        text-align: center;
    }
}

/* Motion Preferences */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .category-card:hover,
    .product-card:hover {
        transform: none;
    }
}

/* Product Archive Styling */
.product-archive-main {
    padding: 3rem 0;
    background: var(--section-light, #f8f9fa);
    min-height: 60vh;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e9ecef;
}

.category-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    padding: 1rem 1.5rem;
    background: rgba(76, 175, 80, 0.05);
    border-radius: 8px;
    border-left: 4px solid var(--primary, #4CAF50);
}

.toggle-categories-btn {
    background: var(--primary, #4CAF50);
    color: #fff;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.toggle-categories-btn:hover {
    background: var(--primary-dark, #357a38);
    transform: translateY(-1px);
}

.toggle-categories-btn i {
    transition: transform 0.3s ease;
}

.toggle-categories-btn.expanded i {
    transform: rotate(180deg);
}

.section-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--heading-primary, #234C2A);
    margin: 0 0 0.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-header h2::before {
    content: '📦';
    font-size: 1.2rem;
}

.category-controls .view-all-link {
    color: var(--primary, #4CAF50);
    font-weight: 500;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--primary, #4CAF50);
    border-radius: 6px;
    background: #fff;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    white-space: nowrap;
}

.category-controls .view-all-link:hover,
.category-controls .view-all-link:focus {
    background: var(--primary, #4CAF50);
    color: #fff;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

.category-controls .view-all-link i {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

.category-controls .view-all-link:hover i {
    transform: translateX(2px);
}

/* Breadcrumb-style spacing for category controls */
.category-controls::before {
    content: '→';
    color: var(--primary, #4CAF50);
    font-weight: bold;
    font-size: 1.1rem;
    margin-right: 0.5rem;
}

/* Product Categories Grid */
.product-categories-section {
    margin-bottom: 3rem;
}

.product-categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
}

.category-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    transition: transform 0.2s, box-shadow 0.2s;
}

.category-card:hover,
.category-card:focus-within {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.category-image-wrapper {
    height: 180px;
    overflow: hidden;
}

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

.category-card:hover .category-image-wrapper img {
    transform: scale(1.05);
}

.category-content {
    padding: 1.25rem;
}

.category-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--heading-primary, #234C2A);
}

.category-count-text {
    font-size: 0.85rem;
    color: #6c757d;
    margin-bottom: 0.75rem;
    font-weight: 500;
}

.category-image-placeholder {
    background: linear-gradient(135deg, #e9ecef 0%, #f8f9fa 100%);
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #adb5bd;
    font-size: 2rem;
}

.category-extra {
    animation: fadeInUp 0.5s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.category-link {
    font-weight: 500;
    font-size: 0.95rem;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}



/* Product List Grid */
.product-list-section {
    margin-bottom: 2rem;
}

.product-list-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.product-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0,0,0,0.06);
    transition: transform 0.2s, box-shadow 0.2s;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.product-card:hover,
.product-card:focus-within {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.10);
}

.product-image-wrapper {
    height: 160px;
    overflow: hidden;
}

.product-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.product-card:hover .product-image-wrapper img {
    transform: scale(1.05);
}

.product-image-placeholder {
    background: linear-gradient(135deg, #e9ecef 0%, #f8f9fa 100%);
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    font-size: 2rem;
}

.product-excerpt {
    font-size: 0.9rem;
    color: #666;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.product-content {
    padding: 1.25rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--heading-primary, #234C2A);
    /* For long titles */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-link {
    margin-top: auto;
    font-weight: 500;
    font-size: 0.9rem;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.product-link:hover,
.product-link:focus {
    color: var(--primary-dark,rgb(90, 90, 90));
    text-decoration: underline;
}

/* No Products Found */
.no-products-found {
    text-align: center;
    padding: 3rem 1rem;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}

.no-products-found i {
    font-size: 3rem;
    color: #ced4da;
    margin-bottom: 1rem;
    display: block;
}

.no-products-found p {
    font-size: 1rem;
    color: #6c757d;
    margin-bottom: 1.5rem;
}

.no-products-found .btn {
    background-color: var(--primary, #4CAF50);
    border-color: var(--primary, #4CAF50);
    color: #fff;
    font-weight: 500;
    padding: 0.5rem 1.5rem;
    border-radius: 30px;
    text-decoration: none;
    display: inline-block;
    transition: all 0.2s;
}

.no-products-found .btn:hover,
.no-products-found .btn:focus {
    background-color: var(--primary-dark, #357a38);
    border-color: var(--primary-dark, #357a38);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Pagination */
.pagination {
    text-align: center;
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2rem;
}

.page-numbers {
    padding: 0.5rem 1rem;
    border-radius: 4px;
    background: #fff;
    border: 1px solid #dee2e6;
    color: #333;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
}

.page-numbers.current {
    background: var(--primary, #4CAF50);
    border-color: var(--primary, #4CAF50);
    color: #fff;
}

.page-numbers:hover,
.page-numbers:focus {
    border-color: var(--primary, #4CAF50);
    background: #f8f9fa;
}

/* Modern Industry Refresh Layer */
.product-archive-main {
    background:
        radial-gradient(circle at 15% 10%, rgba(15, 94, 66, 0.06) 0, rgba(15, 94, 66, 0) 35%),
        radial-gradient(circle at 85% 90%, rgba(15, 94, 66, 0.08) 0, rgba(15, 94, 66, 0) 32%),
        #f5f8f7;
    padding: 2.6rem 0 3rem;
}

.product-archive-main .container {
    max-width: 1240px;
}

.product-categories-section,
.product-list-section {
    background: #ffffff;
    border: 1px solid #e1ebe7;
    border-radius: 16px;
    padding: 1.35rem;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
}

.product-categories-section {
    margin-bottom: 1.35rem;
}

.section-header {
    border-bottom: 1px solid #dbe8e2;
    margin-bottom: 1.25rem;
    padding-bottom: 0.9rem;
}

.section-header h2 {
    color: #0f172a !important;
    font-size: clamp(1.25rem, 2.2vw, 1.7rem);
    letter-spacing: 0.01em;
}

.section-header h2::before {
    content: none;
}

.product-categories-grid {
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 1rem;
}

.category-card,
.product-card {
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    box-shadow: 0 6px 16px rgba(2, 8, 23, 0.06);
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.category-card:hover,
.category-card:focus-within,
.product-card:hover,
.product-card:focus-within {
    transform: translateY(-4px);
    border-color: #bbd8cd;
    box-shadow: 0 12px 28px rgba(2, 8, 23, 0.12);
}

.category-image-wrapper,
.product-image-wrapper {
    background: #f1f5f9;
}

.category-image-wrapper {
    height: 170px;
}

.product-image-wrapper {
    height: 185px;
}

.category-content,
.product-content {
    padding: 1rem;
}

.category-title,
.product-title {
    color: #0f172a !important;
    font-size: 1.02rem;
    line-height: 1.35;
    white-space: normal;
    overflow: visible;
    text-overflow: initial;
    min-height: 2.75em;
}

.category-count-text {
    color: #475569 !important;
}

.product-excerpt {
    color: #64748b;
    min-height: 2.8em;
}

.category-link,
.product-link {
    color: #0f5e42;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
}

.category-link:hover,
.category-link:focus,
.product-link:hover,
.product-link:focus {
    color: #0b4d36;
    text-decoration: none;
}

.product-link {
    margin-top: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.58rem 0.9rem;
    border: 1px solid #0f5e42;
    border-radius: 8px;
    background: #ffffff;
}

.product-link:hover,
.product-link:focus {
    background: #0f5e42;
    color: #ffffff;
}

.product-link:visited {
    color: #ffffff !important;
    background: #0f5e42;
    border-color: #0f5e42;
}

.product-link:visited:hover,
.product-link:visited:focus {
    background: #0b4d36;
    border-color: #0b4d36;
}

.pagination {
    margin-top: 1.5rem;
}

.page-numbers {
    border-radius: 8px;
}

.page-numbers.current {
    background: #0f5e42;
    border-color: #0f5e42;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .product-categories-section,
    .product-list-section {
        padding: 1rem;
        border-radius: 12px;
    }

    .product-archive-main {
        padding-top: 1.8rem;
    }

    .section-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .category-controls {
        justify-content: center;
        margin-top: 1rem;
        padding: 1rem;
    }
    
    .category-controls .view-all-link {
        flex: 1;
        justify-content: center;
        max-width: 300px;
    }

    .product-categories-grid,
    .product-list-grid {
        grid-template-columns: 1fr;
    }
}

/* Product Archive Layout Lock (conflict-safe) */
#main-content.product-archive-main > .container {
    max-width: 1240px !important;
    width: min(1240px, 94vw) !important;
    margin: 0 auto !important;
}

#main-content.product-archive-main .product-categories-grid,
#main-content.product-archive-main .product-list-grid {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 1rem !important;
    align-items: stretch !important;
    width: 100% !important;
}

#main-content.product-archive-main .category-card,
#main-content.product-archive-main .product-card {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 100% !important;
}

#main-content.product-archive-main .category-image-wrapper,
#main-content.product-archive-main .product-image-wrapper {
    height: 185px !important;
    flex: 0 0 185px !important;
    overflow: hidden !important;
}

#main-content.product-archive-main .category-image-wrapper img,
#main-content.product-archive-main .product-image-wrapper img {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
}

#main-content.product-archive-main .category-content,
#main-content.product-archive-main .product-content {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
}

#main-content.product-archive-main .product-link {
    margin-top: auto !important;
}

@media (min-width: 769px) and (max-width: 1100px) {
    #main-content.product-archive-main .product-categories-grid,
    #main-content.product-archive-main .product-list-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
}

@media (max-width: 768px) {
    #main-content.product-archive-main .product-categories-grid,
    #main-content.product-archive-main .product-list-grid {
        grid-template-columns: 1fr !important;
    }
}
