/* Products Page Styles - Refined UI */

.products-container {
    display: flex;
    gap: 3rem;
    padding: 3rem 5%;
    max-width: 1400px;
    margin: 0 auto;
    align-items: flex-start;
    /* Prevent stretching/clipping issues */
    min-height: 80vh;
    /* Ensure page has height */
    box-sizing: border-box;
    width: 100%;
}

/* Sidebar Filters */
.filters-sidebar {
    width: 280px;
    flex-shrink: 0;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    /* Sticky Behavior */
    position: sticky;
    top: 100px;
    /* Adjust based on header height */
    align-self: flex-start;
    /* Removed max-height and overflow-y to prevent internal scrolling */
    height: auto;
    overflow: visible;
}

.search-box {
    margin-bottom: 2rem;
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 0.8rem 1rem 0.8rem 2.5rem;
    padding-right: 2.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-family: inherit;
    color: var(--text-main);
    font-size: 0.95rem;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 163, 224, 0.1);
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
    z-index: 1;
}

.search-clear {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    transition: all 0.2s ease;
    z-index: 2;
}

.search-clear:hover {
    background: #f1f5f9;
    color: var(--text-main);
}

.search-clear i {
    font-size: 0.875rem;
}

.filter-group {
    margin-bottom: 1.5rem;
}

/* Reduce margin when followed by persistent area */
.filter-group:last-of-type {
    margin-bottom: 0;
}

.filter-label {
    display: block;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Portfolio Grouping */
.portfolio-group {
    margin-bottom: 2rem;
}

.portfolio-header {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-left: 0.5rem;
}

.portfolio-header i {
    color: var(--secondary);
}

.category-list {
    list-style: none;
    padding-left: 0.5rem;
    margin-bottom: 0;
}

.category-list:last-child {
    margin-bottom: 0;
}

.category-item {
    padding: 0.6rem 1rem;
    cursor: pointer !important;
    color: var(--text-main);
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
    border-left: 3px solid transparent;
    position: relative;
    z-index: 101;
}

.category-item:last-child {
    margin-bottom: 0;
}

.category-item:hover {
    color: var(--primary);
    background-color: #f8fafc;
    border-left-color: #cbd5e1;
}

.category-item.active {
    background-color: #CAF0F8;
    color: #0077B6;
    font-weight: 700;
    border-left: 4px solid #00B4D8;
}

.category-item i {
    width: 20px;
    text-align: center;
    font-size: 0.9em;
}

/* Force Visibility for Persistent Buttons */
.sidebar-persistent-area {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative;
    z-index: 50;
    margin-top: 1.25rem;
    width: 100%;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
}

.sidebar-persistent-area .category-item,
.sidebar-persistent-area a {
    display: flex !important;
    justify-content: flex-start !important;
    align-items: center !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Ensure persistent buttons are never hidden */
.sidebar-persistent-area .category-item {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
    overflow: visible !important;
    cursor: pointer !important;
    pointer-events: auto !important;
    margin-top: 0;
    margin-bottom: 0.75rem;
}

/* View All Equipment button styling */
.sidebar-persistent-area .category-item.view-all-button,
.sidebar-persistent-area .view-all-button {
    font-weight: 700;
    margin-bottom: 0.75rem;
}

/* Switch Portfolio Link */
.switch-portfolio-link {
    display: flex !important;
    align-items: center !important;
    gap: 0.5rem !important;
    color: var(--primary) !important;
    text-decoration: none !important;
    font-weight: 600 !important;
    font-size: 0.9rem !important;
    padding: 0.5rem 0;
    margin-top: 0;
    transition: all 0.2s ease;
}

.switch-portfolio-link:hover {
    color: var(--primary-hover) !important;
    padding-left: 0.25rem;
}

/* Prevent any accidental hiding */
.sidebar-persistent-area * {
    visibility: visible !important;
    opacity: 1 !important;
}

/* Product Content */
main {
    flex-grow: 1;
}

.products-header {
    margin-bottom: 2rem;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    width: 100%;
}

/* Responsive Grid Breakpoints */
@media (max-width: 1199px) {
    .product-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.25rem;
    }
}

@media (max-width: 899px) {
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
}

/* Product Card - Modern Professional Design */
.product-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.08),
        0 1px 2px -1px rgba(0, 0, 0, 0.06);
    text-decoration: none !important;
    color: inherit;
    cursor: pointer;
    /* Hardware acceleration for smooth mobile animations */
    will-change: transform, box-shadow;
}

.product-card:hover,
.product-card:active {
    border-color: #00A3E0;
    box-shadow: 0 8px 25px -5px rgba(0, 163, 224, 0.2),
        0 4px 10px -4px rgba(0, 163, 224, 0.1);
    transform: translateY(-4px);
}

.product-image {
    height: 180px;
    background: linear-gradient(145deg, #f8fafc 0%, #f1f5f9 50%, #e0f2fe 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    border-bottom: 1px solid #e5e7eb;
    position: relative;
    overflow: hidden;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.3s ease;
}

.product-card:hover .product-image img {
    transform: scale(1.05);
}

.product-image:has(img[style*="display: none"]) i {
    display: flex !important;
}

/* Fallback for browsers that don't support :has() */
.product-image img[style*="display: none"] {
    display: none !important;
}

.product-image img[style*="display: none"]~i {
    display: flex !important;
}

.product-image i {
    font-size: 3rem;
    opacity: 0.35;
    color: #00A3E0;
}

.product-details {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-height: 0;
    align-items: center;
    text-align: center;
}

.product-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.4rem 0.85rem;
    border-radius: 20px;
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    align-self: center;
    margin-bottom: 0.75rem;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(0, 163, 224, 0.1);
}

.badge-refurbished,
.badge-new {
    background: #f0f9ff;
    color: #0284c7;
    border: 1px solid #bae6fd;
}

.badge-disposable {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #6ee7b7;
}

.product-card h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.4;
    color: #1e293b;
    margin: 0 0 0.75rem 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    letter-spacing: -0.01em;
    flex-shrink: 0;
    min-height: 2.8rem;
}

.product-card h3 mark {
    background-color: #fef3c7;
    color: #92400e;
    padding: 0.1em 0.2em;
    border-radius: 3px;
    font-weight: 600;
}

.view-details {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: #00a3e0;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    margin-top: auto;
    padding: 0.5rem 0;
    transition: all 0.2s ease;
}

.product-card:hover .view-details {
    color: #0077b6;
    gap: 0.75rem;
}

.view-details i {
    font-size: 0.75rem;
    transition: transform 0.2s ease;
}

.product-card:hover .view-details i {
    transform: translateX(2px);
}

/* Responsive Design */
@media (max-width: 768px) {
    .products-container {
        flex-direction: column;
        padding: 1.5rem 1rem;
        gap: 1.5rem;
    }

    .filters-sidebar {
        width: 100%;
        margin-bottom: 1.5rem;
        position: static;
        height: auto;
        overflow: visible;
        top: auto;
        order: -1;
        padding: 1rem;
        border-radius: 12px;
    }

    .search-box {
        margin-bottom: 1rem;
    }

    .search-box input {
        font-size: 0.95rem;
        padding: 0.75rem 1rem 0.75rem 2.5rem;
    }

    /* 2-Column Grid for Tablets and Mobile */
    .product-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem;
    }

    .product-card {
        border-radius: 10px;
    }

    .product-image {
        height: 120px;
    }

    .product-image i {
        font-size: 2.5rem;
    }

    .product-details {
        padding: 0.75rem;
    }

    .product-card h3 {
        font-size: 0.8125rem;
        line-height: 1.3;
        min-height: auto;
        margin-bottom: 0.375rem;
        -webkit-line-clamp: 2;
    }

    .product-badge {
        font-size: 0.5625rem;
        padding: 0.2rem 0.4rem;
        margin-bottom: 0.375rem;
        letter-spacing: 0.3px;
    }

    .view-details {
        font-size: 0.75rem;
        padding: 0.25rem 0;
    }

    .filter-group {
        margin-bottom: 1rem;
    }

    .portfolio-group {
        margin-bottom: 1rem;
    }

    .category-item {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .products-container {
        padding: 1rem 0.75rem;
    }

    .product-grid {
        gap: 0.625rem;
    }

    .product-image {
        height: 100px;
    }

    .product-image i {
        font-size: 2rem;
    }

    .product-details {
        padding: 0.625rem;
    }

    .product-card h3 {
        font-size: 0.75rem;
        margin-bottom: 0.25rem;
    }

    .product-badge {
        font-size: 0.5rem;
        padding: 0.15rem 0.35rem;
        margin-bottom: 0.25rem;
    }

    .view-details {
        font-size: 0.6875rem;
    }

    .filters-sidebar {
        padding: 0.875rem;
        margin-bottom: 1rem;
    }

    .category-item {
        padding: 0.5rem 0.625rem;
        font-size: 0.8rem;
    }

    .sidebar-persistent-area {
        margin-top: 0.75rem;
        padding-top: 0.5rem;
    }

    .brands-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .brand-item {
        padding: 0.625rem;
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .products-container {
        padding: 1rem 0.75rem;
    }

    .product-grid {
        grid-template-columns: 1fr;
        gap: 0.875rem;
    }

    .product-card {
        max-width: 100%;
        margin: 0 auto;
    }

    /* Optimize product image for mobile */
    .product-image {
        height: 140px;
    }

    .product-details {
        padding: 0.75rem;
    }

    .product-card h3 {
        font-size: 0.875rem;
        line-height: 1.3;
        margin-bottom: 0.375rem;
    }

    .product-badge {
        font-size: 0.65rem;
        padding: 0.15rem 0.4rem;
        margin-bottom: 0.375rem;
    }

    .view-details {
        font-size: 0.8125rem;
        padding: 0.375rem 0;
        margin-top: auto;
    }

    .filters-sidebar {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .search-box input {
        font-size: 0.9375rem;
        padding: 0.75rem 0.875rem 0.75rem 2.5rem;
        padding-right: 2.5rem;
    }

    .category-item {
        padding: 0.625rem 0.875rem;
        font-size: 0.875rem;
        margin-bottom: 0.25rem;
    }

    .category-item i {
        width: 18px;
        font-size: 0.85rem;
    }
}

/* Brands Section - Global Styles */
.brands-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 2rem;
    align-items: center;
}

.brand-item {
    background: white;
    padding: 1.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
    color: #64748b;
    transition: all 0.2s;
    font-size: 0.95rem;
    cursor: default;
}

.brand-item:hover {
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}