/* All Products Section Styles */
.all-products-section {
    padding: 60px 0;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

.all-products-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, #e5e7eb, transparent);
    z-index: 1;
}

/* Hide All Products section when bulk order is active */
.bulk-active .all-products-section {
    display: none;
}

/* Section Header */
.section-header {
    text-align: center;
    margin-bottom: 48px;
}

.section-title {
    font-size: 36px;
    font-weight: 700;
    color: #111827;
    margin: 0 0 12px 0;
    background: linear-gradient(135deg, #a15a00, #dc2626);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.section-description {
    font-size: 16px;
    color: #6b7280;
    margin: 0;
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.6;
}

.all-products-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 40px;
    align-items: start;
}

/* Categories Sidebar */
.categories-sidebar {
    background: #ffffff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 80px;
    height: fit-content;
}

/* Mobile Categories Toggle Button */
.categories-toggle-btn {
    display: none;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 12px 16px;
    background: #dc2626;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 20px;
    transition: background 0.3s ease;
}

.mobile-text {
    display: none;
}

.categories-toggle-btn:hover {
    background: #b91c1c;
}

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

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

.categories-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e5e7eb;
}

.categories-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: #f3f4f6;
    border-radius: 8px;
    color: #6b7280;
}

.categories-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #111827;
}

.categories-nav-header {
    display: none;
}

.categories-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 16px;
}

.nav-group:last-child {
    margin-bottom: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: #374151;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    position: relative;
}

.nav-link:hover {
    background: #f9fafb;
    color: #111827;
}

.nav-link.active {
    background: #dc2626;
    color: #ffffff;
    font-weight: 600;
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: #ffffff;
    border-radius: 0 2px 2px 0;
}

.arrow,
.fa-chevron-right {
    font-size: 12px;
    color: #9ca3af;
    font-weight: 400;
}

.toggle-icon {
    transition: transform 0.3s ease;
}

.nav-link:hover .arrow,
.nav-link:hover .fa-chevron-right {
    color: #6b7280;
}

.nav-link.active .arrow,
.nav-link.active .fa-chevron-right {
    color: #ffffff;
}

/* Category Group with Subcategories */
.category-group {
    margin-bottom: 8px;
}

.category-group.open .toggle-icon {
    transform: rotate(90deg) !important;
}

.subcategories {
    margin-left: 12px;
    margin-top: 0;
    padding-left: 12px;
    border-left: 2px solid #e5e7eb;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), margin-top 0.3s ease, padding 0.3s ease;
}

.category-group.open .subcategories {
    max-height: 800px;
    opacity: 1;
    margin-top: 4px;
    padding-top: 2px;
    padding-bottom: 2px;
}

.subcategory-link {
    font-size: 13px;
    padding: 8px 12px;
    color: #6b7280;
}

.subcategory-link:hover {
    background: #f3f4f6;
    color: #374151;
}

.subcategory-link.active {
    background: #fee2e2;
    color: #dc2626;
    font-weight: 600;
}

.subcategory-link.active::before {
    background: #dc2626;
}

/* Products Main Area */
.products-main {
    flex: 1;
    min-height: 650px; /* Keep layout stable during AJAX filtering */
}

.products-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.products-title {
    margin: 0;
    font-size: 32px;
    font-weight: 700;
    color: #111827;
}

.products-filters {
    display: flex;
    gap: 16px;
    align-items: center;
}

.filter-group {
    position: relative;
}

.filter-select {
    appearance: none;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    min-width: 140px;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 8px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 40px;
}

.filter-select:focus {
    outline: none;
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

/* Products Grid */
.products-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-top: 24px;
}

/* Product Card Link */
.product-card-link {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: all 0.3s ease;
    position: relative;
    z-index: 100 !important;
    pointer-events: auto !important;
}

.product-card-link:hover {
    text-decoration: none;
    color: inherit;
    background: rgba(59, 130, 246, 0.05);
    border-radius: 12px;
}


/* Debug: Make links visible */
.product-card-link {
    border: 2px solid transparent;
}



/* Product Card */
.product-card {
    display: flex;
    width: 100%;
    height: 100%;
    flex-direction: column;
    align-items: flex-start;
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    border: 1px solid #e5e7eb;
    position: relative;
    padding: 0;
    cursor: pointer;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.product-image {
    position: relative;
    width: 100%;
    height: 200px;
    background: #f3f4f6;
    overflow: hidden;
    border-radius: 12px 12px 0 0;
    flex-shrink: 0;
}

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

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

.product-category {
    position: absolute;
    top: 12px;
    left: 12px;
    background: #dc2626;
    color: #ffffff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 2;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transform: translateY(-5px);
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.product-card:hover .product-category,
.product-card-link:hover .product-category {
    opacity: 1;
    transform: translateY(0);
}

.product-details {
    display: flex;
    width: 100%;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
    flex-grow: 1;
    justify-content: flex-start;
}

.product-name {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #555;
    line-height: 24px;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.product-rating {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.stars {
    display: flex;
    gap: 2px;
}

.star {
    color: #fbbf24;
    font-size: 14px;
}

.reviews {
    font-size: 12px;
    color: #3b82f6;
}

.product-price {
    font-size: 18px;
    font-weight: 700;
    color: #111827;
    margin: auto 0 0 0;
}

/* Loading State */
.products-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 60px 20px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f4f6;
    border-top: 3px solid #dc2626;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Empty State */
.products-empty {
    text-align: center;
    padding: 60px 20px;
    color: #6b7280;
}

.products-empty h3 {
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 600;
}

.products-empty p {
    margin: 0;
    font-size: 14px;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .section-title {
        font-size: 32px;
    }

    .all-products-layout {
        grid-template-columns: 240px 1fr;
        gap: 32px;
    }

    .categories-sidebar {
        padding: 20px;
    }

    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }

    .product-card {
        width: 100%;
        max-width: 253px;
        height: 100%;
    }

    .product-image {
        height: 180px;
    }
}

@media (max-width: 768px) {
    .section-description {
        display: none !important;
    }

    .all-products-layout {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .categories-sidebar {
        position: relative !important;
        z-index: 1000000 !important;
        order: 2;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        box-shadow: none !important;
        background: transparent !important;
    }

    .categories-header {
        display: none !important;
    }

    /* Show mobile toggle button in single row */
    .categories-toggle-btn {
        display: flex !important;
        flex: 2;
        min-width: 0;
        margin-bottom: 0 !important;
        padding: 8px 12px;
        font-size: 13px;
        white-space: nowrap;
        background: #dc2626;
        color: white;
        border: none;
        border-radius: 8px;
        font-weight: 600;
        cursor: pointer;
        align-items: center;
        justify-content: space-between;
        height: 38px;
    }

    .categories-toggle-btn .desktop-text {
        display: none;
    }

    .categories-toggle-btn .mobile-text {
        display: inline;
    }

    /* Mobile Overlay Backdrop (Transparent to avoid dark shades, blocks interactions) */
    .categories-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: transparent;
        z-index: 1000001;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }

    .categories-overlay.active {
        opacity: 1;
        pointer-events: auto;
    }

    /* Mobile Categories Nav Off-Canvas Drawer (Slides in from Right) */
    .categories-nav-header {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 20px;
        border-bottom: 1px solid #e5e7eb;
        padding-bottom: 12px;
    }

    .categories-nav-header h3 {
        margin: 0;
        font-size: 18px;
        font-weight: 600;
        color: #111827;
    }

    .categories-close-btn {
        background: none;
        border: none;
        font-size: 28px;
        color: #374151;
        cursor: pointer;
        line-height: 1;
        padding: 4px 8px;
    }

    .categories-nav {
        position: fixed !important;
        top: 0 !important;
        right: -300px !important; /* Hidden off the right edge */
        left: auto !important;
        transform: none !important;
        width: 300px !important;
        height: 100% !important;
        max-height: 100vh !important;
        z-index: 1000002 !important;
        background: #ffffff !important;
        border: none !important;
        box-shadow: -4px 0 25px rgba(0, 0, 0, 0.15) !important;
        border-radius: 0 !important;
        padding: 24px !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        display: flex !important; /* Keep flex-direction for drawer flow */
        flex-direction: column;
        gap: 12px;
        transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        opacity: 1 !important; /* Visible when sliding in */
    }

    .categories-nav.active {
        right: 0 !important;
    }

    .categories-nav .nav-link {
        padding: 12px 14px;
        font-size: 15px;
        border-radius: 8px;
        border: 1px solid #f3f4f6;
        background: #f9fafb;
    }
    
    .categories-nav .nav-link:hover {
        background: #f3f4f6;
    }
    
    .categories-nav .nav-link.active {
        background: #dc2626;
        color: #ffffff;
        border-color: #dc2626;
    }

    .categories-nav .subcategories {
        margin-left: 12px;
        border-left: 2px solid #e5e7eb;
        padding-left: 8px;
        display: flex;
        flex-direction: column;
        gap: 6px;
    }
    
    .categories-nav .subcategory-link {
        padding: 10px 12px;
        font-size: 13px;
        border-radius: 6px;
        background: transparent;
    }

    .products-main {
        order: 1;
        min-width: 0 !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    .products-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    .products-filters {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 8px;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    .products-filters .filter-group {
        flex: 1;
        min-width: 0;
    }

    .filter-select {
        width: 100%;
        min-width: 0 !important;
        padding: 8px 20px 8px 6px;
        font-size: 13px;
        height: 38px;
        border-radius: 8px;
    }

    .products-grid {
        gap: 16px;
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }

    .product-image {
        height: 170px;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
}

@media (max-width: 480px) {
    .all-products-section {
        padding: 20px 0;
    }

    .section-header {
        margin-bottom: 32px;
    }

    .section-title {
        font-size: 24px;
    }

    .section-description {
        font-size: 14px;
    }

    .categories-sidebar {
        padding: 0 !important;
        margin: 0 !important;
    }

    .categories-toggle-btn {
        font-size: 12px;
        padding: 6px 8px;
        height: 38px;
    }

    .products-filters {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 8px;
        width: 100%;
        box-sizing: border-box;
    }

    .products-filters .filter-group {
        flex: 1 !important;
        min-width: 0 !important;
        width: 50% !important;
    }

    .filter-select {
        width: 100%;
        min-width: 0 !important;
        font-size: 12px;
        padding: 6px 12px 6px 4px;
        height: 38px;
        box-sizing: border-box;
    }

    .products-grid {
        gap: 12px;
        grid-template-columns: repeat(2, 1fr) !important;
        max-width: 100%;
        margin-left: auto;
        margin-right: auto;
    }

    .product-card {
        width: 100%;
        max-width: 100%;
    }

    .product-image {
        height: 120px !important;
    }

    .product-details {
        padding: 10px !important;
    }

    .product-name {
        font-size: 13px !important;
        line-height: 1.3 !important;
        margin-bottom: 4px !important;
    }

    .pagination {
        flex-wrap: wrap;
        justify-content: center;
        gap: 4px;
    }

    .pagination-item {
        min-width: 32px;
        height: 32px;
        font-size: 12px;
        padding: 0 4px;
    }
}

@media (max-width: 360px) {
    .product-card {
        width: 100%;
        max-width: 100%;
        height: auto;
    }

    .product-image {
        height: 100px !important;
    }

    .product-name {
        font-size: 11px !important;
        line-height: 1.2 !important;
    }

    .product-price {
        font-size: 16px;
    }
}

/* Loading and Error States */
.loading-spinner,
.no-products,
.error-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: #6b7280;
    font-size: 16px;
}

.loading-spinner {
    position: relative;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-spinner::before {
    content: '';
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top-color: #dc2626;
    border-radius: 50%;
    animation: spinner 0.8s linear infinite;
}

/* Professional Overlay Loader */
.products-loader {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.65);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 50;
    backdrop-filter: blur(1px);
    border-radius: 12px;
}

.products-loader.active {
    display: flex;
}

.loading-ring {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(220, 38, 38, 0.1);
    border-top-color: #dc2626;
    border-radius: 50%;
    animation: ring-spin 0.8s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

@keyframes ring-spin {
    to {
        transform: rotate(360deg);
    }
}

.products-grid.loading {
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.2s ease-in-out;
}

@keyframes spinner {
    to {
        transform: rotate(360deg);
    }
}

.error-message {
    color: #dc2626;
}

.no-products p,
.error-message p {
    margin: 0;
    font-size: 18px;
    font-weight: 500;
}

/* View All Products Button */
.view-all-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 40px;
    margin-bottom: 20px;
    width: 100%;
}

.btn-view-all {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 32px;
    border-radius: 50px;
    background: #ffffff;
    color: #dc2626;
    border: 2px solid #dc2626;
    font-size: 15px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.08);
    cursor: pointer;
}

.btn-view-all:hover {
    background: #dc2626;
    color: #ffffff;
    box-shadow: 0 6px 20px rgba(220, 38, 38, 0.25);
    transform: translateY(-2px);
}

.btn-view-all .icon-arrow {
    transition: transform 0.3s ease;
    font-size: 14px;
}

.btn-view-all:hover .icon-arrow {
    transform: translateX(4px);
}

/* Breadcrumb Section */
.breadcrumb-container {
    padding-top: 30px;
    padding-bottom: 0px;
}

.breadcrumb-nav {
    margin-bottom: 0;
}

.breadcrumb {
    display: flex;
    align-items: center;
    list-style: none;
    padding: 0;
    margin: 0;
    flex-wrap: wrap;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
    font-size: 14px;
    color: #6b7280;
}

.breadcrumb-item:not(.active) a {
    color: #dc2626;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.breadcrumb-item:not(.active) a:hover {
    color: #b91c1c;
    text-decoration: underline;
}

.breadcrumb-item.active span {
    color: #4b5563;
    font-weight: 500;
}

.breadcrumb-separator {
    margin: 0 8px;
    font-size: 10px;
    color: #9ca3af;
}

/* Custom Pagination Styles */
.pagination-wrapper {
    display: flex;
    justify-content: center;
    margin-top: 48px;
    width: 100%;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pagination-item {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 6px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    color: #374151;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.pagination-item:hover:not(.disabled):not(.active) {
    border-color: #dc2626;
    color: #dc2626;
    background: #fff5f5;
    transform: translateY(-1px);
}

.pagination-item.active {
    background: #dc2626;
    border-color: #dc2626;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.2);
}

.pagination-item.disabled {
    color: #9ca3af;
    background: #f9fafb;
    cursor: not-allowed;
    border-color: #e5e7eb;
}

.pagination-item.dots {
    border: none;
    background: transparent;
    cursor: default;
}

/* Premium Layout Fixes when Pricing is Disabled */
.product-card.no-price {
    min-height: auto !important;
}

.product-card.no-price .product-details {
    justify-content: flex-start !important;
    gap: 8px !important;
}

/* Prevent broken image alt text from overlapping category badge */
.product-image img {
    color: transparent !important;
    text-indent: -9999px !important;
}

/* Scroll lock when categories drawer is open on mobile */
body.categories-open {
    overflow: hidden !important;
}