/* General Styles */
body {
    font-family: 'Roboto', sans-serif;
    color: #333;
    background-color: #f8f9fa;
}

.section-title {
    color: #2c3e50;
    font-weight: 600;
    text-align: center;
    position: relative;
    margin-bottom: 0.75rem;
    margin-top: 0.75rem;
}

.section-title::after {
    content: '';
    display: block;
    width: 50px;
    height: 3px;
    background-color: #3498db;
    margin: 0.3rem auto 0;
}

/* Product Card Styles */
.product-card {
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1), box-shadow 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
    height: 420px; /* Increased fixed height */
    min-height: 420px; /* Consistent min-height */
    max-height: 420px; /* Ensure maximum height is also fixed */
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    will-change: transform, box-shadow;
    contain: content;
    margin-bottom: 25px;
    width: 100%;
}


.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
    border-color: #3498db;
}

@media (prefers-reduced-motion: reduce) {
    .product-card {
        transition: none;
    }
    .product-card:hover {
        transform: none;
    }
}

.featured-card {
    border: 2px solid #3498db;
}

.featured-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: #3498db;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
    z-index: 1;
}

.product-img-container {
    height: 200px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f8f9fa;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    contain: strict;
    position: relative;
    min-height: 200px;
    max-height: 200px;
    flex-shrink: 0; /* Prevent shrinking */
    padding: 10px;
}

.product-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    width: 100px;
    height: 100px;
    aspect-ratio: 1;
    transform: translateZ(0);
    transition: all 0.3s ease;
    padding: 5px;
}

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

/* Image placeholder for loading state */
.product-img-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #f0f0f0 25%, #f8f8f8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.product-info {
    padding: 0.9rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 220px;
    max-height: 220px;
    overflow: hidden;
    justify-content: space-between;
}

.row > [class*="col-"] {
    display: flex;
    margin-bottom: 20px;
    padding: 0 12px;
    height: 420px; /* Match the updated card height */
}

.product-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.7rem;
    color: #2c3e50;
    height: 3rem;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    contain: content;
    min-height: 3rem;
    max-height: 3rem;
}

.product-generic-name {
    font-size: 0.875rem;
    color: #6c757d;
    margin-bottom: 0.5rem;
    height: 1.5rem;
    min-height: 1.5rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.product-badges {
    margin-bottom: 1.2rem;
    height: 2.2rem;
    min-height: 2.2rem;
    overflow: hidden;
}

.product-badges .badge {
    margin-right: 0.3rem;
    margin-bottom: 0.3rem;
}

.view-details-btn {
    margin-top: auto;
    width: 100%;
    padding: 0.6rem 1rem;
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.25s ease;
}

/* Alpha Navigation */
.alpha-nav {
    background-color: #f8f9fa;
    padding: 0.5rem;
    border-radius: 8px;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.alpha-buttons {
    gap: 0.3rem;
}

.alpha-buttons .btn {
    min-width: 40px;
}

/* Search Section Styles */
.search-section {
    max-width: 1000px;
    margin: 0 auto 15px;
    padding: 15px 20px;
    background-color: #e6f3ff;
    border-radius: 8px;
    position: relative;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.product-catalog-header {
    margin-bottom: 12px;
}

.product-catalog-header h1 {
    color: #2c3e50;
    font-weight: 600;
    font-size: 1.4rem;
    margin-bottom: 4px;
}

.product-catalog-header p {
    color: #5a6a7e;
    font-size: 0.85rem;
    margin-bottom: 0;
}

.search-container {
    display: flex;
    flex-wrap: nowrap;
    gap: 15px;
    align-items: flex-end;
}

.search-field {
    flex: 1;
}

.search-field label {
    display: block;
    color: #2c3e50;
    font-weight: 500;
    font-size: 0.8rem;
    margin-bottom: 3px;
    white-space: nowrap;
}

.search-field label i {
    color: #3498db;
    margin-right: 4px;
}

.search-section .input-group-text {
    background-color: #ffffff;
    border-right: none;
    border-top-left-radius: 6px;
    border-bottom-left-radius: 6px;
    color: #3498db;
    transition: all 0.2s ease;
    padding: 0.25rem 0.5rem;
    height: 30px;
}

.search-section .input-group:hover .input-group-text {
    color: #2980b9;
}

.search-section .form-control,
.search-section .form-select {
    box-shadow: none;
    height: 32px;
    border-radius: 4px;
    font-size: 0.8rem;
    background-color: #ffffff;
    padding: 0.25rem 0.5rem;
    border: 1px solid #ced4da;
    width: 100%;
}

.search-section .form-control:focus,
.search-section .form-select:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 0.1rem rgba(52, 152, 219, 0.1);
}

.search-section .form-select:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 0.1rem rgba(52, 152, 219, 0.1);
}

.search-section .btn-primary {
    background-color: #3498db;
    border-color: #3498db;
    padding: 0.25rem 0.6rem;
    font-weight: 500;
    height: 32px;
    border-radius: 4px;
    font-size: 0.75rem;
}

.search-section .btn-primary:hover {
    background-color: #2980b9;
    border-color: #2980b9;
}

.search-section .btn-outline-secondary {
    color: #6c757d;
    border-color: #ced4da;
    padding: 0.25rem 0.6rem;
    font-weight: 500;
    height: 32px;
    border-radius: 4px;
    font-size: 0.75rem;
}

.search-section .btn-outline-secondary:hover {
    background-color: #f8f9fa;
    color: #495057;
}

.search-section .row {
    margin-bottom: 0;
    align-items: flex-end;
}

.search-section .row:last-of-type {
    margin-bottom: 0;
    margin-top: 0;
}

.search-section .d-flex {
    margin-top: 0;
    gap: 0.5rem;
    justify-content: flex-end;
}

.search-section .btn {
    padding-left: 1rem;
    padding-right: 1rem;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-section .form-label {
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 0.05rem;
    color: #2c3e50;
    display: block;
}

/* Search section responsive adjustments */
@media (max-width: 767.98px) {
    .search-section {
        margin: 8px auto 12px;
        padding: 10px 12px;
    }
    
    .search-container {
        flex-direction: column;
        gap: 8px;
    }
    
    .search-field {
        width: 100%;
    }
    
    .product-catalog-header h1 {
        font-size: 1.2rem;
    }
    
    .product-catalog-header p {
        font-size: 0.75rem;
    }
    
    .search-section .form-control,
    .search-section .form-select,
    .search-section .btn {
        height: 28px;
        font-size: 0.7rem;
        padding: 0.15rem 0.4rem;
    }
    
    .search-section .input-group-text {
        height: 28px;
        padding: 0.15rem 0.3rem;
    }
    
    .search-section .row {
        margin-bottom: 0;
    }
    
    .search-section .form-label {
        font-size: 0.7rem;
        margin-bottom: 0.1rem;
    }
    
    .search-section .d-flex {
        flex-wrap: wrap;
        gap: 6px;
        margin-top: 0.15rem;
    }
    
    .search-section .btn-outline-secondary,
    .search-section .btn-primary {
        flex: 1;
        min-width: 80px;
        justify-content: center;
    }
}

/* Footer styles removed */

/* Pagination */
.pagination .page-link {
    color: #3498db;
}

.pagination .page-item.active .page-link {
    background-color: #3498db;
    border-color: #3498db;
}

/* Modal Styles */
.modal-content {
    border-radius: 8px;
    overflow: hidden;
}

.modal-header {
    background-color: #3498db;
    color: white;
}

.modal-title {
    font-weight: 600;
}

/* Responsive Adjustments */
@media (max-width: 767.98px) {
    .product-img-container {
        height: 150px;
    }
    
    .alpha-buttons .btn {
        min-width: 35px;
        padding: 0.25rem 0.5rem;
        font-size: 0.875rem;
    }
    
    .search-section .row {
        flex-direction: column;
        gap: 12px;
    }
    
    .search-section .col-md-4 {
        margin-bottom: 0;
    }
    
    .search-section .d-flex {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .search-section .btn {
        margin-bottom: 0;
        flex: 1;
        min-width: 120px;
    }
    
    .search-section .btn-outline-secondary {
        margin-right: 10px !important;
    }
    
    .search-section .input-group {
        margin-bottom: 0;
    }
    
    .search-section .form-control,
    .search-section .form-select {
        border-radius: 8px;
    }
    
    .search-section .input-group .form-control {
        border-top-left-radius: 0;
        border-bottom-left-radius: 0;
    }
    
    .search-section .input-group .input-group-text {
        border-top-right-radius: 0;
        border-bottom-right-radius: 0;
    }

}

/* Performance Optimizations */
.products-section {
    contain: content;
    min-height: 300px; /* Prevent layout shifts during filtering */
    will-change: contents;
    transform: translateZ(0);
    margin-top: 0.3rem;
}

#productsContainer {
    contain: layout style;
    transition: opacity 0.3s ease-out;
    will-change: opacity, contents;
    backface-visibility: hidden;
}

.pagination {
    contain: layout style;
    transition: opacity 0.2s ease-out;
}

/* Prevent layout shifts */
.row > [class*="col-"] {
    display: flex;
    margin-bottom: 20px;
    padding: 0 12px;
    height: 420px; /* Match the updated card height */
}

/* Fixed height for product cards to prevent layout shifts */
.product-card {
    min-height: 420px;
    height: 420px;
    max-height: 420px;
}

.featured-card {
    border: 2px solid #3498db;
    min-height: 420px;
    height: 420px;
    max-height: 420px;
}

/* Loading state styles */
.filtering-in-progress #productsContainer,
.filtering-in-progress .pagination {
    opacity: 0.7;
    pointer-events: none;
    transition: opacity 0.3s ease-out;
}

.filtering-in-progress .alpha-buttons .btn,
.filtering-in-progress select,
.filtering-in-progress input,
.filtering-in-progress button {
    pointer-events: none;
}

/* Smooth transitions for all interactive elements */
.btn, .form-select, .form-control, .product-card, .page-link {
    transition: all 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* Optimize animations for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    .btn, .form-select, .form-control, .product-card, .page-link,
    #productsContainer, .pagination {
        transition: none;
    }
}


/* Additional Product Info Styles */
.product-details {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 0.8rem;
    font-size: 0.85rem;
    height: auto;
    min-height: 3rem;
    max-height: 4.5rem;
    overflow: hidden;
}

.product-manufacturer,
.product-form,
.product-agent {
    margin-right: 0.8rem;
    margin-bottom: 0.3rem;
    color: #6c757d;
}

.product-manufacturer::before {
    content: '🏭 ';
}

.product-form::before {
    content: '💊 ';
}

.product-agent::before {
    content: '👨‍⚕️ ';
}

/* Modal Additional Info */
.modal-additional-info {
    background-color: #f8f9fa;
    padding: 0.8rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.modal-additional-info h6 {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

/* Modal animations */
.modal.fade .modal-dialog {
    transition: transform 0.25s cubic-bezier(0.25, 0.1, 0.25, 1);
    transform: scale(0.95);
}

.modal.show .modal-dialog {
    transform: scale(1);
}

/* Optimize modal image loading */
#modalProductImage {
    transition: opacity 0.2s ease-out;
    will-change: opacity;
    contain: strict;
    height: auto;
    width: 100%;
    max-height: 200px;
    object-fit: contain;
}

/* Prevent content jumping in modal */
.modal-body {
    min-height: 300px;
}

@media (prefers-reduced-motion: reduce) {
    .modal.fade .modal-dialog,
    #modalProductImage {
        transition: none;
    }
}