/* Category Selection Optimized Styles */

/* Tab-based Category Selection Styles */
.category-tabs-container {
    border: 2px solid #dee2e6;
    border-radius: 0.5rem;
    background-color: #ffffff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow: hidden;
    /* Performance optimizations */
    contain: layout style paint;
    will-change: auto;
}

.category-tabs {
    background-color: #ffffff;
    border-bottom: 1px solid #dee2e6;
    margin-bottom: 0;
    padding: 0.5rem 1rem 0 1rem;
}

.category-tabs .nav-link {
    border: none;
    border-radius: 0.375rem 0.375rem 0 0;
    margin-right: 0.25rem;
    padding: 0.75rem 1rem;
    color: #6c757d;
    background-color: transparent;
    border-bottom: 3px solid transparent;
    /* Optimized transitions */
    transition: color 0.2s ease, background-color 0.2s ease, border-bottom-color 0.2s ease;
    /* Performance optimizations */
    contain: layout style;
    will-change: auto;
}

.category-tabs .nav-link:hover {
    color: #0d6efd;
    background-color: #e9ecef;
    border-bottom-color: #0d6efd;
}

.category-tabs .nav-link.active {
    color: #0d6efd;
    background-color: #ffffff;
    border-bottom-color: #0d6efd;
    font-weight: 600;
}

.category-tabs .nav-link .badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
}

.category-tab-content {
    padding: 1.5rem;
    min-height: 300px;
    max-height: 400px;
    overflow-y: auto;
    background-color: #ffffff;
}

.category-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 0.5rem;
    background-color: #ffffff;
}

.category-item {
    padding: 0.5rem;
    border-radius: 0.25rem;
    transition: background-color 0.2s ease;
    margin-bottom: 0.25rem;
    background-color: #ffffff;
}

.category-item:hover {
    background-color: #f8f9fa;
}

.category-item .form-check-input {
    margin-top: 0.25rem;
}

.category-item .form-check-label {
    margin-left: 0.5rem;
    font-size: 0.9rem;
    cursor: pointer;
    line-height: 1.4;
}

.category-item .form-check-input:checked + .form-check-label {
    color: #0d6efd;
    font-weight: 600;
}

/* Category Container Styling */
.category-container {
    background-color: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.category-container.nested-container {
    background-color: #ffffff;
    border: 1px solid #dee2e6;
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.category-parent-header {
    padding: 0.5rem 0;
    font-weight: 600;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #e9ecef;
    margin-bottom: 0.75rem;
}

.category-parent-header.nested-header {
    font-weight: 500;
    font-size: 0.9rem;
    border-bottom: 1px solid #f1f3f4;
    margin-bottom: 0.5rem;
    color: #6c757d;
}

.category-children-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem;
    padding-left: 0.5rem;
    background-color: #ffffff;
}

.category-children-container .category-item {
    margin-bottom: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    transition: background-color 0.2s ease;
}

.category-children-container .category-item:hover {
    background-color: #e9ecef;
}

.category-parent-header .fas {
    opacity: 0.7;
}

.category-parent-header small {
    font-size: 0.75rem;
    opacity: 0.8;
}

/* Selected Categories Summary */
.selected-categories-summary {
    transition: all 0.3s ease;
    max-width: 100%;
    overflow-wrap: break-word;
}

.selected-categories-summary .alert {
    max-width: 100%;
    overflow-wrap: break-word;
}

.selected-categories-summary .selected-categories-list {
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.selected-categories-summary .badge {
    font-size: 0.8rem;
    display: inline-block;
    white-space: normal;
    word-wrap: break-word;
    max-width: none;
    margin-bottom: 0.25rem;
    padding: 0.5rem 0.75rem;
    line-height: 1.2;
}

/* Category path badges - full width display */
.category-path-badge {
    display: inline-block !important;
    white-space: normal !important;
    word-wrap: break-word !important;
    max-width: none !important;
    width: auto !important;
    min-width: fit-content !important;
    margin-bottom: 0.5rem !important;
    padding: 0.5rem 0.75rem !important;
    line-height: 1.3 !important;
    border-radius: 0.375rem !important;
    font-size: 0.8rem !important;
}

/* Custom scrollbar for tab content */
.category-tab-content::-webkit-scrollbar {
    width: 6px;
}

.category-tab-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.category-tab-content::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.category-tab-content::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.form-label {
    font-size: 1.1rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.75rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .category-tab-content {
        padding: 1rem;
        min-height: 250px;
        max-height: 300px;
    }
    
    .category-list {
        grid-template-columns: 1fr;
    }
    
    .category-children-container {
        grid-template-columns: 1fr;
        padding-left: 0.25rem;
    }
    
    .category-container {
        padding: 0.5rem;
    }
    
    .category-container.nested-container {
        padding: 0.25rem;
    }
}

@media (max-width: 576px) {
    .category-tabs .nav-link {
        padding: 0.4rem 0.5rem;
        font-size: 0.8rem;
    }
    
    .category-tabs .nav-link .badge {
        font-size: 0.6rem;
        padding: 0.2rem 0.4rem;
    }
}

/* Performance optimizations */
.category-tabs-container {
    contain: layout style;
}

.category-list {
    contain: layout;
}

.category-item {
    contain: layout style;
}

/* Lazy loading for better performance */
.category-tab-content {
    will-change: scroll-position;
}

/* Optimize animations */
.category-item {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Lazy loading styles with performance optimizations */
.category-container {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.3s ease, transform 0.3s ease;
    /* Performance optimizations */
    contain: layout style paint;
    will-change: auto;
}

.category-container.loaded {
    opacity: 1;
    transform: translateY(0);
    will-change: auto;
}

/* Form optimization */
#productForm button[type="submit"]:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Smooth transitions for summary */
.selected-categories-summary {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.selected-categories-summary.show {
    animation: slideInUp 0.3s ease-out;
}

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

/* Similar Products Display */
#similar-products-alert {
    animation: slideInUp 0.3s ease-out;
}

.similar-products-list {
    max-height: 300px;
    min-height: 150px;
    overflow-y: scroll; /* Always show scrollbar */
    overflow-x: hidden;
    padding-right: 8px;
    margin-right: -8px;
    /* Force scrollbar to always show */
    scrollbar-gutter: stable;
    border: 1px solid #e9ecef;
    border-radius: 0.375rem;
    background-color: #fefefe;
}

/* Custom scrollbar styling for similar products - Webkit browsers */
.similar-products-list::-webkit-scrollbar {
    width: 10px;
    background: transparent;
}

.similar-products-list::-webkit-scrollbar-track {
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.similar-products-list::-webkit-scrollbar-thumb {
    background: #6c757d;
    border-radius: 6px;
    border: 1px solid #adb5bd;
}

.similar-products-list::-webkit-scrollbar-thumb:hover {
    background: #495057;
    border-color: #6c757d;
}

.similar-products-list::-webkit-scrollbar-thumb:active {
    background: #343a40;
}

/* Firefox scrollbar styling for similar products */
.similar-products-list {
    scrollbar-width: thin;
    scrollbar-color: #6c757d #f8f9fa;
}

/* Force scrollbar visibility on mobile */
@media (max-width: 768px) {
    .similar-products-list {
        max-height: 250px;
        -webkit-overflow-scrolling: touch;
        /* iOS smooth scrolling */
    }
    
    .similar-products-list::-webkit-scrollbar {
        width: 12px;
        /* Larger scrollbar for mobile */
    }
}

.similar-product-item {
    transition: all 0.2s ease;
    border-left: 3px solid #ffc107 !important;
    margin-right: 5px; /* Account for scrollbar space */
    background-color: #fefefe;
    min-height: auto;
}

.similar-product-item:hover {
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    transform: translateY(-1px);
    background-color: #fff8e1;
}

.similar-product-item .brand-sku-line {
    display: flex;
    align-items: center;
    font-size: 0.8rem;
    color: #6c757d;
}

.similar-product-item .brand-sku-line strong {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.similar-product-item .product-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #495057;
    line-height: 1.3;
    margin-bottom: 0.25rem;
}

.similar-product-item .sku-info code {
    font-size: 0.75rem;
    padding: 0.1rem 0.3rem;
    background-color: #e3f2fd;
    border: 1px solid #bbdefb;
    border-radius: 0.25rem;
}

.similar-product-item .badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
}

.similar-product-item .btn-sm {
    padding: 0.375rem 0.5rem;
    font-size: 0.8rem;
    line-height: 1;
    border-radius: 0.25rem;
    width: 2.2rem;
    height: 2.2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.similar-product-item .btn-sm i {
    font-size: 0.8rem;
}

/* Compact similar products alert */
#similar-products-alert {
    border-radius: 0.5rem;
    border: 1px solid #ffc107;
    background-color: #fff8e1;
}

#similar-products-alert .alert-heading {
    font-size: 1rem;
    font-weight: 600;
}

/* Responsive design for compact similar products */
@media (max-width: 768px) {
    .similar-product-item .row {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .similar-product-item .col-md-6,
    .similar-product-item .col-md-3 {
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    .similar-product-item .text-center,
    .similar-product-item .text-end {
        text-align: left !important;
    }
    
    .similar-product-item .badge {
        margin-right: 0.5rem;
        margin-bottom: 0.5rem;
    }
    
    .similar-product-item .btn-sm {
        margin-right: 0.25rem;
        margin-bottom: 0.25rem;
        display: inline-flex;
    }
}

/* Match type badges */
.badge.bg-danger {
    background-color: #dc3545 !important;
}

.badge.bg-warning {
    background-color: #ffc107 !important;
    color: #000 !important;
}

.badge.bg-success {
    background-color: #198754 !important;
}

.badge.bg-secondary {
    background-color: #6c757d !important;
}

