<?php 
$productId = isset($_GET['id']) ? $_GET['id'] : '';
$pageTitle = "Product Details - Sigma Healthcare"; 
?>
<?php include 'includes/header.php'; ?>

<style>
/* Product Detail Page Styles - Updated Design */
.product-detail-section {
    padding: 140px 0 80px; /* Increased top padding */
    background: #ffffff;
    margin-top: 20px; /* Added margin to create gap */
}

.product-images {
    position: relative;
}

.main-product-image {
    width: 100%;
    height: 400px;
    object-fit: contain;
    border-radius: 15px;
    background: #f8f9fa;
    padding: 20px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    opacity: 0; /* Hide initially to prevent flash */
    transition: opacity 0.3s ease; /* Smooth fade in */
}

.main-product-image.loaded {
    opacity: 1; /* Show when loaded */
}

.product-info {
    padding-left: 40px;
}

.product-title {
    color: #333;
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 10px;
    line-height: 1.3;
}

.product-subtitle {
    color: #666;
    font-size: 1rem;
    margin-bottom: 20px;
    line-height: 1.6;
}

.product-rating {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
}

.rating-stars {
    color: #ffc107;
    margin-right: 10px;
}

.rating-text {
    color: #666;
    font-size: 0.9rem;
}

/* Size/Volume Selection */
.size-selection {
    margin-bottom: 25px;
}

.size-label {
    color: #333;
    font-weight: 600;
    margin-bottom: 10px;
    display: block;
}

.size-options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.size-option {
    padding: 8px 15px;
    border: 2px solid #ddd;
    border-radius: 25px;
    background: white;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    min-width: 60px;
    text-align: center;
}

.size-option:hover,
.size-option.active {
    border-color: #FE4600;
    background: #FE4600;
    color: white;
}

.product-price {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 25px;
}

.price-label {
    color: #666;
    font-size: 1rem;
    font-weight: normal;
    margin-right: 10px;
}

.price-value {
    color: #333;
}

.quantity-section {
    margin-bottom: 30px;
}

.quantity-label {
    color: #333;
    font-weight: 600;
    margin-bottom: 10px;
    display: block;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.quantity-btn {
    width: 35px;
    height: 35px;
    border: 1px solid #ddd;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 5px;
    font-size: 18px;
    transition: all 0.3s ease;
}

.quantity-btn:hover {
    background: #FE4600;
    color: white;
    border-color: #FE4600;
}

.quantity-input {
    width: 60px;
    height: 35px;
    text-align: center;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-weight: 600;
}

.btn-request-quote {
    background: #FE4600;
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.3s ease;
    display: inline-block;
    text-decoration: none;
    margin-bottom: 40px;
    width: 100%;
    text-align: center;
}

.btn-request-quote:hover {
    background: #e03d00;
    color: white;
    transform: translateY(-2px);
    text-decoration: none;
}

/* Product Description Section - Updated with image */
.product-description-section {
    background: #f8f9fa;
    padding: 60px 0;
}

.description-content {
    background: white;
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

.description-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 30px;
}

.description-tabs {
    flex: 1;
}

.tab-buttons {
    display: flex;
    gap: 0;
    margin-bottom: 30px;
}

.tab-btn {
    padding: 12px 25px;
    background: #f8f9fa;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    border-radius: 0;
}

.tab-btn:first-child {
    border-radius: 8px 0 0 8px;
}

.tab-btn:last-child {
    border-radius: 0 8px 8px 0;
}

.tab-btn.active {
    background: #FE4600;
    color: white;
}

.description-image {
    width: 300px;
    height: 200px;
    object-fit: contain;
    border-radius: 10px;
    background: #f8f9fa;
    padding: 15px;
    margin-left: 30px;
    opacity: 0; /* Hide initially */
    transition: opacity 0.3s ease; /* Smooth fade in */
}

.description-image.loaded {
    opacity: 1; /* Show when loaded */
}

.description-text {
    color: #666;
    line-height: 1.8;
    font-size: 1rem;
}

/* Loading placeholder */
.image-placeholder {
    width: 100%;
    height: 400px;
    background: #f8f9fa;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: #999;
    border: 2px dashed #ddd;
}

/* Responsive Design */
@media (max-width: 992px) {
    .product-info {
        padding-left: 0;
        margin-top: 40px;
    }
    
    .product-title {
        font-size: 1.8rem;
    }
    
    .main-product-image {
        height: 350px;
    }

    .description-header {
        flex-direction: column;
    }

    .description-image {
        margin-left: 0;
        margin-top: 20px;
        width: 100%;
        max-width: 300px;
    }
}

@media (max-width: 768px) {
    .product-detail-section {
        padding: 120px 0 60px; /* Adjusted for mobile */
        margin-top: 15px; /* Added margin for mobile */
    }
    
    .product-title {
        font-size: 1.6rem;
    }
    
    .main-product-image {
        height: 300px;
    }
    
    .description-content {
        padding: 30px 20px;
    }

    .size-options {
        gap: 8px;
    }

    .size-option {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .tab-buttons {
        flex-direction: column;
    }

    .tab-btn {
        border-radius: 8px !important;
        margin-bottom: 5px;
    }
}

@media (max-width: 576px) {
    .product-detail-section {
        padding: 110px 0 50px; /* Adjusted for mobile */
        margin-top: 15px; /* Added margin for mobile */
    }

    .product-title {
        font-size: 1.4rem;
    }

    .main-product-image {
        height: 250px;
    }

    .description-content {
        padding: 25px 15px;
    }

    .size-options {
        flex-direction: column;
    }

    .size-option {
        width: 100%;
        padding: 10px;
        font-size: 1rem;
    }

    .quantity-controls {
        flex-direction: column;
    }

    .quantity-btn {
        width: 100%;
        padding: 10px;
        font-size: 1.2rem;
    }

    .quantity-input {
        width: 100%;
        padding: 10px;
        font-size: 1.2rem;
    }
}

@media (max-width: 375px) {
    .product-detail-section {
        padding: 100px 0 40px; /* Adjusted for small mobile */
        margin-top: 15px; /* Added margin for small mobile */
    }

    .product-title {
        font-size: 1.2rem;
    }

    .main-product-image {
        height: 200px;
    }

    .description-content {
        padding: 20px 10px;
    }

    .size-options {
        flex-direction: column;
    }

    .size-option {
        width: 100%;
        padding: 8px;
        font-size: 0.9rem;
    }

    .quantity-controls {
        flex-direction: column;
    }

    .quantity-btn {
        width: 100%;
        padding: 8px;
        font-size: 1rem;
    }

    .quantity-input {
        width: 100%;
        padding: 8px;
        font-size: 1rem;
    }
}
</style>

<section class="product-detail-section">
    <div class="container">
        <div class="row">
            <div class="col-lg-6">
                <div class="product-images">
                    <!-- Removed the default src, will be set by JavaScript -->
                    <img src="" alt="Product Image" class="main-product-image" id="mainImage" style="display: none;">
                    <div class="image-placeholder" id="imagePlaceholder">Loading product image...</div>
                </div>
            </div>
            
            <div class="col-lg-6">
                <div class="product-info">
                    <h1 class="product-title" id="productTitle">Loading...</h1>
                    <p class="product-subtitle" id="productSubtitle">Loading product details...</p>
                    
                    <div class="product-rating">
                        <div class="rating-stars">
                            ★★★★★
                        </div>
                        <span class="rating-text">(40+ Reviews)</span>
                    </div>

                    <!-- Size/Volume Selection -->
                    <div class="size-selection">
                        <label class="size-label">Size</label>
                        <div class="size-options" id="sizeOptions">
                            <!-- Will be populated by JavaScript -->
                        </div>
                    </div>
                    
                    <div class="quantity-section">
                        <label class="quantity-label">Quantity</label>
                        <div class="quantity-controls">
                            <button class="quantity-btn" onclick="decreaseQuantity()">-</button>
                            <input type="number" id="quantity" class="quantity-input" value="1" min="1" readonly>
                            <button class="quantity-btn" onclick="increaseQuantity()">+</button>
                        </div>
                    </div>
                    
                    <a href="#" class="btn-request-quote">Request Quote</a>
                </div>
            </div>
        </div>
    </div>
</section>

<!-- Product Description Section -->
<section class="product-description-section">
    <div class="container">
        <div class="row">
            <div class="col-12">
                <div class="description-content">
                    <div class="description-header">
                        <div class="description-tabs">
                            <div class="tab-buttons">
                                <button class="tab-btn active" onclick="switchTab('description')">Description</button>
                                <button class="tab-btn" onclick="switchTab('faq')">FAQ</button>
                            </div>
                            
                            <div class="tab-content" id="descriptionTab">
                                <div class="description-text" id="productDescription">
                                    <p>Loading product description...</p>
                                </div>
                            </div>

                            <div class="tab-content" id="faqTab" style="display: none;">
                                <div class="description-text" id="productFAQ">
                                    <p>Loading FAQ...</p>
                                </div>
                            </div>
                        </div>

                        <img src="" alt="Product Image" class="description-image" id="descriptionImage" style="display: none;">
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>

<script>
// Quantity control functions
function increaseQuantity() {
    const quantityInput = document.getElementById('quantity');
    quantityInput.value = parseInt(quantityInput.value) + 1;
}

function decreaseQuantity() {
    const quantityInput = document.getElementById('quantity');
    if (parseInt(quantityInput.value) > 1) {
        quantityInput.value = parseInt(quantityInput.value) - 1;
    }
}

// Tab switching functionality
function switchTab(tabName) {
    // Hide all tab contents
    document.getElementById('descriptionTab').style.display = 'none';
    document.getElementById('faqTab').style.display = 'none';
    
    // Remove active class from all tab buttons
    document.querySelectorAll('.tab-btn').forEach(btn => btn.classList.remove('active'));
    
    // Show selected tab and mark button as active
    if (tabName === 'description') {
        document.getElementById('descriptionTab').style.display = 'block';
        document.querySelectorAll('.tab-btn')[0].classList.add('active');
    } else if (tabName === 'faq') {
        document.getElementById('faqTab').style.display = 'block';
        document.querySelectorAll('.tab-btn')[1].classList.add('active');
    }
}

// Function to load image with proper handling
function loadImage(src, callback) {
    const img = new Image();
    img.onload = function() {
        callback(null, this);
    };
    img.onerror = function() {
        callback(new Error('Failed to load image'), null);
    };
    img.src = src;
}

// Product data - Updated with corrected image paths for new rapid test products
const productData = {
    // New Rapid Test Products - UPDATED IMAGE PATHS
    'cocaine-coc-rapid-test': {
        title: 'Cocaine (COC) Rapid Test Cassette',
        subtitle: 'Professional-grade rapid diagnostic test for qualitative detection of cocaine metabolites in urine samples.',
        sizes: [
            { size: 'Single Test', price: '$8.50' },
            { size: '25 Tests', price: '$185.00' }
        ],
        image: 'images/products/Cocaine (COC) Rapid Test Cassette.jpg',
        descriptionImage: 'images/products/Cocaine (COC) Rapid Test Cassette.jpg',
        description: 'The Cocaine (COC) Rapid Test Cassette is a lateral flow chromatographic immunoassay for the qualitative detection of benzoylecgonine (cocaine metabolite) in human urine. This test provides a screening result only and is intended for professional use in clinical laboratories, hospitals, and testing facilities. The test is based on the principle of competitive binding and utilizes a monoclonal antibody to selectively detect elevated levels of cocaine metabolites.',
        faq: [
            { q: 'What is the detection window for cocaine?', a: 'Cocaine metabolites can typically be detected 2-3 days after use, depending on usage patterns.' },
            { q: 'What is the cutoff level for this test?', a: 'The test has a cutoff concentration of 300 ng/ml for benzoylecgonine.' },
            { q: 'How long does it take to get results?', a: 'Results are available within 5 minutes of sample application.' }
        ]
    },
    'dengue-rapid-test': {
        title: 'Dengue Rapid Test Cassette',
        subtitle: 'Immunochromatographic rapid test for simultaneous detection of dengue NS1 antigen, IgM and IgG antibodies.',
        sizes: [
            { size: 'Single Test', price: '$12.00' },
            { size: '25 Tests', price: '$275.00' }
        ],
        image: 'images/products/Dengue Rapid Test Cassette.jpg',
        descriptionImage: 'images/products/Dengue Rapid Test Cassette.jpg',
        description: 'The Dengue Rapid Test Cassette is a lateral flow immunoassay designed for the qualitative detection of dengue virus NS1 antigen and IgM/IgG antibodies in human serum, plasma, or whole blood. This multi-marker test enables early detection during the acute phase (NS1) and identifies immune response markers (IgM/IgG) for comprehensive dengue diagnosis. The test is crucial for rapid clinical decision-making in dengue-endemic areas.',
        faq: [
            { q: 'What dengue markers does this test detect?', a: 'The test detects NS1 antigen (early infection) and IgM/IgG antibodies (immune response).' },
            { q: 'When should this test be performed?', a: 'Optimal testing is within the first 7 days of fever onset for NS1, and after day 5 for antibodies.' },
            { q: 'Can it differentiate between dengue serotypes?', a: 'No, this is a pan-dengue test that detects all four dengue virus serotypes but does not differentiate between them.' }
        ]
    },
    'hbsag-rapid-test': {
        title: 'HBsAg Rapid Test Cassette',
        subtitle: 'Immunochromatographic test for qualitative detection of Hepatitis B surface antigen in human specimens.',
        sizes: [
            { size: 'Single Test', price: '$6.50' },
            { size: '25 Tests', price: '$145.00' }
        ],
        image: 'images/products/HBsAg Rapid Test Cassette.jpg',
        descriptionImage: 'images/products/HBsAg Rapid Test Cassette.jpg',
        description: 'The HBsAg Rapid Test Cassette is a qualitative, membrane-based immunoassay for the detection of Hepatitis B surface antigen in human serum, plasma, or whole blood. This test is designed for screening purposes and early detection of Hepatitis B infection. The test utilizes anti-HBs antibodies immobilized on a nitrocellulose membrane to capture HBsAg present in the specimen, providing rapid and reliable results.',
        faq: [
            { q: 'How early can this test detect Hepatitis B?', a: 'HBsAg can be detected as early as 2-8 weeks after infection, before symptoms appear.' },
            { q: 'What is the sensitivity of this test?', a: 'The test has a sensitivity of >99.5% when compared to reference methods.' },
            { q: 'Can this test be used for blood screening?', a: 'This is a screening test; positive results should be confirmed with additional testing methods.' }
        ]
    },
    'hiv-rapid-test': {
        title: 'HIV 1,2 Rapid Test Cassette',
        subtitle: 'Fourth-generation rapid test for simultaneous detection of HIV-1/2 antibodies and p24 antigen.',
        sizes: [
            { size: 'Single Test', price: '$9.75' },
            { size: '25 Tests', price: '$220.00' }
        ],
        image: 'images/products/HIV 1.2 Rapid Test Cassette.jpg',
        descriptionImage: 'images/products/HIV 1.2 Rapid Test Cassette.jpg',
        description: 'The HIV 1,2 Rapid Test Cassette is a fourth-generation immunochromatographic test that simultaneously detects HIV-1/2 antibodies and HIV-1 p24 antigen in human serum, plasma, or whole blood. This combination approach reduces the window period for detection and provides earlier identification of HIV infection. The test is designed for professional use in clinical settings and point-of-care testing environments.',
        faq: [
            { q: 'What is the window period for this test?', a: 'The combination of antibody and antigen detection reduces the window period to approximately 2-4 weeks.' },
            { q: 'Does it detect both HIV-1 and HIV-2?', a: 'Yes, the test detects antibodies to both HIV-1 and HIV-2, plus HIV-1 p24 antigen.' },
            { q: 'How accurate is this rapid test?', a: 'The test shows >99% sensitivity and specificity when used according to instructions.' }
        ]
    },
    'marijuana-thc-rapid-test': {
        title: 'Marijuana (THC) Rapid Test (Urine)',
        subtitle: 'Immunochromatographic rapid test for qualitative detection of THC metabolites in urine samples.',
        sizes: [
            { size: 'Single Test', price: '$7.25' },
            { size: '25 Tests', price: '$165.00' }
        ],
        image: 'images/products/Marijuana (THC) Rapid Test (Urine).jpg',
        descriptionImage: 'images/products/Marijuana (THC) Rapid Test (Urine).jpg',
        description: 'The Marijuana (THC) Rapid Test is a lateral flow chromatographic immunoassay designed for the qualitative detection of 11-nor-Δ9-tetrahydrocannabinol-9-carboxylic acid (THC-COOH), the primary metabolite of marijuana, in human urine. This test is intended for professional use in clinical laboratories, workplace testing, and rehabilitation programs. The test provides a preliminary screening result for THC use.',
        faq: [
            { q: 'What is the cutoff level for THC detection?', a: 'The test cutoff is 50 ng/ml for THC-COOH, following SAMHSA guidelines.' },
            { q: 'How long can THC be detected in urine?', a: 'Detection time varies: 3-30 days depending on frequency of use and individual metabolism.' },
            { q: 'Is this test specific for marijuana only?', a: 'Yes, the test specifically detects THC metabolites from marijuana/cannabis use.' }
        ]
    },
    'methamphetamine-met-rapid-test': {
        title: 'Methamphetamine (MET) Rapid Test (Urine)',
        subtitle: 'Professional rapid diagnostic test for qualitative detection of methamphetamine and amphetamine in urine.',
        sizes: [
            { size: 'Single Test', price: '$7.75' },
            { size: '25 Tests', price: '$175.00' }
        ],
        image: 'images/products/Methamphetamine (MET) Rapid Test (Urine).jpg',
        descriptionImage: 'images/products/Methamphetamine (MET) Rapid Test (Urine).jpg',
        description: 'The Methamphetamine (MET) Rapid Test is an immunochromatographic assay for the qualitative detection of methamphetamine and amphetamine in human urine specimens. This test utilizes specific antibodies to detect elevated levels of methamphetamine metabolites, providing rapid screening results for professional testing environments including clinical laboratories, rehabilitation centers, and workplace testing programs.',
        faq: [
            { q: 'What substances does this test detect?', a: 'The test detects methamphetamine and its metabolite amphetamine in urine samples.' },
            { q: 'What is the detection cutoff level?', a: 'The test has a cutoff concentration of 1000 ng/ml for methamphetamine.' },
            { q: 'Can prescription medications cause false positives?', a: 'Some prescription medications containing amphetamines may cause positive results.' }
        ]
    },
    
    // Original products continue here (unchanged)...
    'glass-beaker-25ml': {
        title: 'Glass Beaker 25ml',
        subtitle: 'High-quality borosilicate glass beaker designed for precision laboratory measurements and general laboratory applications.',
        sizes: [
            { size: '25ml', price: '$25' }
        ],
        image: 'images/products/beaker25.jpg',
        descriptionImage: 'images/products/beaker25.jpg',
        description: 'Our 25ml glass beaker is manufactured from premium borosilicate glass, ensuring exceptional chemical resistance and thermal stability. This laboratory-grade beaker features precise graduated markings for accurate volume measurements and is designed to withstand repeated use in demanding laboratory environments. The compact size makes it ideal for small-scale experiments and precise measurements. Each beaker undergoes rigorous quality control testing to meet international laboratory standards.',
        faq: [
            { q: 'What material is the beaker made from?', a: 'Our beakers are made from high-quality borosilicate glass, which is heat and chemical resistant.' },
            { q: 'Can this beaker be used for heating?', a: 'Yes, borosilicate glass beakers can withstand high temperatures and are suitable for heating applications.' },
            { q: 'What is the accuracy of the volume markings?', a: 'The volume markings are accurate to ±5% and are permanently etched into the glass.' }
        ]
    },
    'glass-beaker-50ml': {
        title: 'Glass Beaker 50ml',
        subtitle: 'Professional-grade borosilicate glass beaker perfect for medium-scale laboratory experiments and educational use.',
        sizes: [
            { size: '50ml', price: '$35' }
        ],
        image: 'images/products/beaker50.png',
        descriptionImage: 'images/products/beaker50.png',
        description: 'Our 50ml glass beaker combines durability with precision, featuring clear volume graduations and a reinforced spout for accurate pouring. Made from superior borosilicate glass, it offers excellent resistance to thermal shock and chemical corrosion. The medium capacity makes it versatile for various laboratory applications including sample preparation, mixing, and general laboratory work.',
        faq: [
            { q: 'Is this beaker suitable for organic solvents?', a: 'Yes, borosilicate glass is compatible with most organic solvents and chemicals.' },
            { q: 'Can it be autoclaved?', a: 'Yes, this beaker is autoclavable and can withstand sterilization temperatures.' },
            { q: 'What is the wall thickness?', a: 'The beaker features uniform wall thickness for consistent heat distribution and durability.' }
        ]
    },
    'glass-beaker-100ml': {
        title: 'Glass Beaker 100ml',
        subtitle: 'Versatile laboratory beaker ideal for routine analysis, sample preparation, and educational demonstrations.',
        sizes: [
            { size: '100ml', price: '$45' }
        ],
        image: 'images/products/beker100.jpeg',
        descriptionImage: 'images/products/beker100.jpeg',
        description: 'The 100ml glass beaker is our most popular size, offering the perfect balance of capacity and handling convenience. Manufactured from premium borosilicate glass with precise volume graduations, this beaker is essential for any laboratory. The wide mouth design facilitates easy filling and cleaning, while the reinforced rim ensures long-lasting durability.',
        faq: [
            { q: 'What are the graduation intervals?', a: 'The beaker features graduations at 10ml intervals with intermediate markings for precise measurement.' },
            { q: 'Is it microwave safe?', a: 'While borosilicate glass is microwave-compatible, we recommend caution with chemical solutions.' },
            { q: 'What is the maximum temperature it can withstand?', a: 'The beaker can withstand temperatures up to 500°C (932°F).' }
        ]
    },
    'glass-beaker-250ml': {
        title: 'Glass Beaker 250ml',
        subtitle: 'Large capacity laboratory beaker designed for bulk preparations and extended experimental procedures.',
        sizes: [
            { size: '250ml', price: '$55' }
        ],
        image: 'images/products/beker250.jpeg',
        descriptionImage: 'images/products/beker250.jpeg',
        description: 'Our 250ml glass beaker provides ample capacity for larger scale laboratory work while maintaining the precision and quality of smaller sizes. The robust construction and clear graduations make it ideal for bulk solution preparation, crystallization experiments, and educational demonstrations. The wide base provides excellent stability during use.',
        faq: [
            { q: 'What is the base diameter?', a: 'The 250ml beaker has a base diameter of approximately 70mm for excellent stability.' },
            { q: 'Can it be used with magnetic stirrers?', a: 'Yes, the flat bottom design makes it compatible with magnetic stirring plates.' },
            { q: 'How should it be cleaned?', a: 'Clean with laboratory detergent and rinse thoroughly, or use an ultrasonic cleaner for stubborn residues.' }
        ]
    },
    'vacutainer-1': {
        title: 'Vacutainer Blood Collection Tube',
        subtitle: 'Sterile vacuum blood collection tubes designed for safe and efficient blood sampling in clinical laboratories.',
        sizes: [
            { size: '3ml', price: '$2.50' },
            { size: '5ml', price: '$3.00' }
        ],
        image: 'images/products/Vacutainers.jpg',
        descriptionImage: 'images/products/Vacutainers.jpg',
        description: 'Our Vacutainer blood collection tubes are manufactured to the highest medical standards for reliable blood sampling. These sterile, single-use tubes feature precise vacuum levels for optimal blood draw and are compatible with standard collection systems. The clear polypropylene construction allows easy visual inspection of samples.',
        faq: [
            { q: 'What is the shelf life?', a: 'Vacutainer tubes have a shelf life of 3 years when stored properly at room temperature.' },
            { q: 'Are they latex-free?', a: 'Yes, all our Vacutainer tubes are manufactured latex-free to prevent allergic reactions.' },
            { q: 'What needle gauge is recommended?', a: 'We recommend 20-22 gauge needles for optimal blood flow and patient comfort.' }
        ]
    },
    'vacutainer-2': {
        title: 'Vacutainer EDTA Tube',
        subtitle: 'Anticoagulant blood collection tubes pre-filled with EDTA for hematology and molecular biology applications.',
        sizes: [
            { size: '2ml', price: '$2.75' },
            { size: '4ml', price: '$3.25' }
        ],
        image: 'images/products/Vacutainer.jpeg',
        descriptionImage: 'images/products/Vacutainer.jpeg',
        description: 'EDTA Vacutainer tubes contain precise amounts of ethylenediaminetetraacetic acid for effective anticoagulation. These purple-top tubes are essential for complete blood counts, blood typing, and DNA/RNA extraction procedures. The spray-dried EDTA coating ensures uniform distribution and optimal sample preservation.',
        faq: [
            { q: 'How much EDTA is in each tube?', a: 'EDTA concentration is 1.5mg per ml of blood capacity for optimal anticoagulation.' },
            { q: 'How should samples be mixed?', a: 'Gently invert 8-10 times immediately after collection to ensure proper mixing.' },
            { q: 'What is the storage temperature?', a: 'Store at room temperature (15-25°C) away from direct sunlight.' }
        ]
    },
    'vacutainer-4': {
        title: 'Vacutainer Heparin Tube',
        subtitle: 'Lithium heparin anticoagulant tubes for plasma separation and clinical chemistry analysis.',
        sizes: [
            { size: '3ml', price: '$2.80' },
            { size: '5ml', price: '$3.30' }
        ],
        image: 'images/products/Vacutainer- heparin.jpeg',
        descriptionImage: 'images/products/Vacutainer- heparin.jpeg',
        description: 'Lithium heparin Vacutainer tubes are designed for plasma-based assays and clinical chemistry testing. The green-top tubes contain optimal amounts of lithium heparin to prevent coagulation while maintaining cellular morphology. Ideal for electrolyte analysis, enzyme studies, and emergency chemistry panels.',
        faq: [
            { q: 'What type of heparin is used?', a: 'We use pharmaceutical-grade lithium heparin for consistent anticoagulation.' },
            { q: 'How long is plasma stable?', a: 'Plasma samples are stable for 24 hours at room temperature or 7 days refrigerated.' },
            { q: 'Can it be used for glucose testing?', a: 'Yes, heparin tubes are suitable for glucose and most clinical chemistry tests.' }
        ]
    },
    'petri-dish': {
        title: 'Petri Dish',
        subtitle: 'Sterile polystyrene petri dishes for microbiology, cell culture, and research applications.',
        sizes: [
            { size: '90mm', price: '$1.50' },
            { size: '100mm', price: '$1.75' }
        ],
        image: 'images/products/petri-dish.jpeg',
        descriptionImage: 'images/products/petri-dish.jpeg',
        description: 'Our petri dishes are manufactured from high-quality polystyrene with crystal-clear optics for easy observation. Each dish features raised rings on the bottom for optimal gas exchange and includes tight-fitting lids to prevent contamination. Gamma sterilized and individually wrapped for immediate use in sterile environments.',
        faq: [
            { q: 'Are they pre-sterilized?', a: 'Yes, all petri dishes are gamma sterilized and ready for immediate use.' },
            { q: 'What is the material composition?', a: 'Made from virgin polystyrene that is non-toxic and biologically inert.' },
            { q: 'Can they be autoclaved?', a: 'These are single-use dishes not designed for autoclaving. Use sterile technique instead.' }
        ]
    },
    'pipettes': {
        title: 'Pipettes',
        subtitle: 'Precision glass pipettes for accurate liquid measurement and transfer in laboratory applications.',
        sizes: [
            { size: '1ml', price: '$12.00' },
            { size: '5ml', price: '$15.00' },
            { size: '10ml', price: '$18.00' }
        ],
        image: 'images/products/pipette.jpeg',
        descriptionImage: 'images/products/pipette.jpeg',
        description: 'Our precision pipettes are crafted from high-quality borosilicate glass with accurate volume graduations. These volumetric pipettes feature a single graduation mark for precise "to deliver" measurements. The narrow bore design ensures accurate liquid delivery with minimal retention, making them ideal for analytical procedures.',
        faq: [
            { q: 'What is the accuracy specification?', a: 'Our pipettes meet Class A accuracy standards with tolerances of ±0.006ml for 1ml pipettes.' },
            { q: 'Are they calibrated "to contain" or "to deliver"?', a: 'These are "to deliver" (TD) pipettes calibrated at 20°C.' },
            { q: 'How should they be cleaned?', a: 'Rinse immediately after use and clean with appropriate laboratory detergent.' }
        ]
    },
    'test-tubes': {
        title: 'Test Tubes',
        subtitle: 'Borosilicate glass test tubes for general laboratory use, sample storage, and chemical reactions.',
        sizes: [
            { size: '12x75mm', price: '$0.75' },
            { size: '16x100mm', price: '$1.00' },
            { size: '18x150mm', price: '$1.25' }
        ],
        image: 'images/products/testtubes.jpg',
        descriptionImage: 'images/products/testtubes.jpg',
        description: 'Our test tubes are manufactured from premium borosilicate glass offering excellent chemical resistance and thermal stability. Available in various sizes to accommodate different sample volumes and applications. The uniform wall thickness ensures consistent heat distribution, while the fire-polished rim prevents chipping and injury.',
        faq: [
            { q: 'What is the wall thickness?', a: 'Standard wall thickness of 1.2mm provides durability while allowing efficient heat transfer.' },
            { q: 'Are they suitable for centrifugation?', a: 'Yes, these tubes can withstand standard laboratory centrifugation speeds.' },
            { q: 'Can they be flame sterilized?', a: 'Yes, borosilicate glass test tubes can be flame sterilized safely.' }
        ]
    },
    'test-tube-rack-2': {
        title: 'Test Tube Rack',
        subtitle: 'Durable polypropylene test tube rack designed for organized storage and easy access to test tubes.',
        sizes: [
            { size: '24-hole', price: '$8.50' },
            { size: '50-hole', price: '$12.00' }
        ],
        image: 'images/products/testube-rack.jpg',
        descriptionImage: 'images/products/testube-rack.jpg',
        description: 'Our test tube racks are molded from high-quality polypropylene for chemical resistance and durability. The precisely sized holes accommodate standard test tube sizes while providing secure support. The bright colors aid in sample organization, and the autoclavable design allows for easy sterilization between uses.',
        faq: [
            { q: 'What tube sizes does it accommodate?', a: 'Designed for standard 12-16mm diameter test tubes up to 150mm length.' },
            { q: 'Is it autoclavable?', a: 'Yes, the polypropylene construction can withstand autoclave temperatures up to 121°C.' },
            { q: 'Are different colors available?', a: 'Available in blue, green, red, and yellow for easy color-coding systems.' }
        ]
    },
    'conical-flask': {
        title: 'Conical Flask',
        subtitle: 'Erlenmeyer-style conical flask with narrow neck for efficient mixing and reduced evaporation.',
        sizes: [
            { size: '125ml', price: '$18.00' },
            { size: '250ml', price: '$22.00' },
            { size: '500ml', price: '$28.00' }
        ],
        image: 'images/products/conical-flask.jpg',
        descriptionImage: 'images/products/conical-flask.jpg',
        description: 'Our conical flasks feature the classic Erlenmeyer design with a wide base and narrow neck for optimal mixing efficiency. Made from borosilicate glass, these flasks are perfect for culturing microorganisms, preparing solutions, and conducting reactions that require swirling or agitation. The narrow neck minimizes evaporation and contamination.',
        faq: [
            { q: 'Can it be used with rubber stoppers?', a: 'Yes, the standard neck size accommodates rubber stoppers and other closures.' },
            { q: 'Is it suitable for vacuum applications?', a: 'These flasks can withstand moderate vacuum but are not designed for high vacuum applications.' },
            { q: 'What is the maximum heating temperature?', a: 'Can be safely heated up to 500°C with gradual temperature changes.' }
        ]
    },
    'erlenmeyer-flask': {
        title: 'Erlenmeyer Flask',
        subtitle: 'Classic narrow-neck laboratory flask ideal for titrations, sample preparation, and general laboratory use.',
        sizes: [
            { size: '250ml', price: '$25.00' },
            { size: '500ml', price: '$32.00' },
            { size: '1000ml', price: '$45.00' }
        ],
        image: 'images/products/250_mL_Erlenmeyer_flask.jpg',
        descriptionImage: 'images/products/250_mL_Erlenmeyer_flask.jpg',
        description: 'The Erlenmeyer flask is an essential piece of laboratory glassware featuring a flat bottom, conical body, and narrow neck. This design provides excellent stability while allowing vigorous mixing without spillage. Made from high-quality borosilicate glass with permanent volume graduations for accurate measurements.',
        faq: [
            { q: 'What makes it different from a beaker?', a: 'The narrow neck allows for vigorous swirling without spillage and reduces evaporation.' },
            { q: 'Can it be used for reflux reactions?', a: 'Yes, when fitted with appropriate condensers and stoppers.' },
            { q: 'Are the graduations accurate for quantitative work?', a: 'Graduations are approximate; use volumetric glassware for precise measurements.' }
        ]
    },
    'vacutainer-5': {
        title: 'Volumetric Flask',
        subtitle: 'Precision volumetric flask with narrow neck for accurate dilution and solution preparation.',
        sizes: [
            { size: '100ml', price: '$35.00' },
            { size: '250ml', price: '$42.00' },
            { size: '500ml', price: '$55.00' }
        ],
        image: 'images/products/vflask.jpeg',
        descriptionImage: 'images/products/vflask.jpeg',
        description: 'Our volumetric flasks are precision instruments designed for accurate preparation of solutions to exact concentrations. Each flask features a single graduation mark on the narrow neck and is calibrated "to contain" at 20°C. Made from borosilicate glass with minimal thermal expansion for consistent accuracy.',
        faq: [
            { q: 'What is the accuracy tolerance?', a: 'Class A volumetric flasks meet ±0.1ml tolerance for 100ml flasks.' },
            { q: 'Should I fill to the meniscus?', a: 'Yes, fill to the bottom of the meniscus when viewed at eye level.' },
            { q: 'Can it be heated?', a: 'Volumetric flasks should not be heated as this affects their calibration accuracy.' }
        ]
    },
    'glass-beaker-1000ml': {
        title: 'Round-bottom Flask',
        subtitle: 'Round-bottom flask designed for heating applications, distillations, and organic synthesis reactions.',
        sizes: [
            { size: '250ml', price: '$28.00' },
            { size: '500ml', price: '$35.00' },
            { size: '1000ml', price: '$48.00' }
        ],
        image: 'images/products/round-flask.png',
        descriptionImage: 'images/products/round-flask.png',
        description: 'Round-bottom flasks are essential for heating applications where even heat distribution is crucial. The spherical shape provides maximum surface area contact with heating mantles and eliminates hot spots. Manufactured from borosilicate glass with standard taper joints for connecting condensers and other apparatus.',
        faq: [
            { q: 'What joint size does it have?', a: 'Available with standard 14/20, 19/22, or 24/29 ground glass joints.' },
            { q: 'Can it be used without a heating mantle?', a: 'Use proper support; never place directly on flat surfaces when heated.' },
            { q: 'Is it suitable for vacuum distillation?', a: 'Yes, borosilicate glass can withstand vacuum distillation conditions.' }
        ]
    }
};

// Load product data based on URL parameter
document.addEventListener('DOMContentLoaded', function() {
    const urlParams = new URLSearchParams(window.location.search);
    const productId = urlParams.get('id');
    
    const mainImage = document.getElementById('mainImage');
    const descriptionImage = document.getElementById('descriptionImage');
    const imagePlaceholder = document.getElementById('imagePlaceholder');
    
    if (productData[productId]) {
        const product = productData[productId];
        
        // Update text content immediately (no flash)
        document.getElementById('productTitle').textContent = product.title;
        document.getElementById('productSubtitle').textContent = product.subtitle;
        
        // Update description
        document.querySelector('#descriptionTab .description-text').innerHTML = '<p>' + product.description + '</p>';
        
        // Update FAQ
        let faqHTML = '';
        product.faq.forEach(item => {
            faqHTML += `<p><strong>Q: ${item.q}</strong></p>`;
            faqHTML += `<p>A: ${item.a}</p><br>`;
        });
        document.querySelector('#faqTab .description-text').innerHTML = faqHTML;
        
        // Load main image with proper handling
        loadImage(product.image, function(error, img) {
            if (!error) {
                mainImage.src = product.image;
                mainImage.style.display = 'block';
                mainImage.classList.add('loaded');
                imagePlaceholder.style.display = 'none';
            } else {
                imagePlaceholder.textContent = 'Failed to load product image';
            }
        });
        
        // Load description image with proper handling
        loadImage(product.descriptionImage, function(error, img) {
            if (!error) {
                descriptionImage.src = product.descriptionImage;
                descriptionImage.style.display = 'block';
                descriptionImage.classList.add('loaded');
            }
        });
        
        // Update size options
        if (product.sizes && product.sizes.length > 0) {
            const sizeContainer = document.getElementById('sizeOptions');
            sizeContainer.innerHTML = '';
            
            product.sizes.forEach((sizeOption, index) => {
                const sizeDiv = document.createElement('div');
                sizeDiv.className = `size-option ${index === 0 ? 'active' : ''}`;
                sizeDiv.setAttribute('data-size', sizeOption.size);
                sizeDiv.setAttribute('data-price', sizeOption.price);
                sizeDiv.textContent = sizeOption.size;
                sizeContainer.appendChild(sizeDiv);
                
                // Add click event
                sizeDiv.addEventListener('click', function() {
                    document.querySelectorAll('.size-option').forEach(opt => opt.classList.remove('active'));
                    this.classList.add('active');
                });
            });
            
            // Hide size selection if only one size
            if (product.sizes.length === 1) {
                document.querySelector('.size-selection').style.display = 'none';
            }
        }
    } else {
        // Default product if ID not found
        document.getElementById('productTitle').textContent = 'Product Not Found';
        document.getElementById('productSubtitle').textContent = 'The requested product could not be found.';
        imagePlaceholder.textContent = 'Product not found';
    }
});
</script>

<?php include 'includes/footer.php'; ?>