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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
{% extends "base.html" %}

{% block title %}Products - Too Many Cables{% endblock %}

{% block content %}
<!-- Page Header -->
<section class="page-header">
    <div class="header-container">
        <div class="header-card">
            <h1>Our Products</h1>
            <p>Premium cables and accessories for all your connectivity needs</p>
        </div>
    </div>
</section>

<!-- Products Grid -->
<section class="products-section">
    <div class="container">
        <div class="products-grid" id="products-grid">
            <!-- USB-C Cables -->
            <div class="product-card" data-category="usb-c" data-price="24.99">
                <div class="product-image">πŸ”Œ</div>
                <h3>USB-C Premium Cable (100W)</h3>
                <p class="product-description">100W fast charging, 10Gbps data transfer, 6ft length with braided nylon protection</p>
                <div class="product-specs">
                    <span class="spec">100W Power</span>
                    <span class="spec">10Gbps Speed</span>
                    <span class="spec">6ft Length</span>
                </div>
                <div class="product-price">$24.99</div>
                <div class="product-rating">⭐⭐⭐⭐⭐ (1,247 reviews)</div>
                <button class="btn btn-primary" onclick="showProductDetails('usb-c-cable')">More Details</button>
            </div>

            <div class="product-card" data-category="usb-c" data-price="19.99">
                <div class="product-image">πŸ”Œ</div>
                <h3>USB-C Standard Cable (60W)</h3>
                <p class="product-description">60W fast charging, 5Gbps data transfer, 3ft compact design with PVC jacket</p>
                <div class="product-specs">
                    <span class="spec">60W Power</span>
                    <span class="spec">5Gbps Speed</span>
                    <span class="spec">3ft Length</span>
                </div>
                <div class="product-price">$19.99</div>
                <div class="product-rating">⭐⭐⭐⭐⭐ (892 reviews)</div>
                <button class="btn btn-primary" onclick="showProductDetails('usb-c-standard')">More Details</button>
            </div>

            <div class="product-card" data-category="usb-c" data-price="16.99">
                <div class="product-image">πŸ”Œ</div>
                <h3>USB-A to USB-C Cable</h3>
                <p class="product-description">Universal compatibility, 18W fast charging, 6ft braided design</p>
                <div class="product-specs">
                    <span class="spec">18W Charging</span>
                    <span class="spec">5Gbps Speed</span>
                    <span class="spec">6ft Length</span>
                </div>
                <div class="product-price">$16.99</div>
                <div class="product-rating">⭐⭐⭐⭐⭐ (734 reviews)</div>
                <button class="btn btn-primary" onclick="showProductDetails('usb-c-to-usb-a')">More Details</button>
            </div>

            <!-- HDMI Cables -->
            <div class="product-card" data-category="hdmi" data-price="34.99">
                <div class="product-image">πŸ“Ί</div>
                <h3>8K HDMI Cable (Ultra High Speed)</h3>
                <p class="product-description">8K@60Hz, 4K@120Hz, HDR10+, Dolby Vision, premium 10ft cable with gold-plated connectors</p>
                <div class="product-specs">
                    <span class="spec">8K@60Hz</span>
                    <span class="spec">48 Gbps</span>
                    <span class="spec">10ft Length</span>
                </div>
                <div class="product-price">$34.99</div>
                <div class="product-rating">⭐⭐⭐⭐⭐ (856 reviews)</div>
                <button class="btn btn-primary" onclick="showProductDetails('4k-hdmi-cable')">More Details</button>
            </div>

            <div class="product-card" data-category="hdmi" data-price="24.99">
                <div class="product-image">πŸ“Ί</div>
                <h3>4K HDMI Cable (High Speed)</h3>
                <p class="product-description">4K@60Hz, 1440p@144Hz, HDR10+, ARC audio, 6ft cable with durable PVC jacket</p>
                <div class="product-specs">
                    <span class="spec">4K@60Hz</span>
                    <span class="spec">18 Gbps</span>
                    <span class="spec">6ft Length</span>
                </div>
                <div class="product-price">$24.99</div>
                <div class="product-rating">⭐⭐⭐⭐⭐ (634 reviews)</div>
                <button class="btn btn-primary" onclick="showProductDetails('hdmi-standard')">More Details</button>
            </div>

            <div class="product-card" data-category="hdmi" data-price="18.99">
                <div class="product-image">πŸ“Ί</div>
                <h3>HDMI to USB-C Cable</h3>
                <p class="product-description">Direct connection from laptop to monitor, 4K@60Hz, 6ft cable</p>
                <div class="product-specs">
                    <span class="spec">4K@60Hz</span>
                    <span class="spec">Plug & Play</span>
                    <span class="spec">6ft Length</span>
                </div>
                <div class="product-price">$18.99</div>
                <div class="product-rating">⭐⭐⭐⭐⭐ (445 reviews)</div>
                <button class="btn btn-primary" onclick="showProductDetails('hdmi-usb-c-cable')">More Details</button>
            </div>

            <div class="product-card" data-category="hdmi" data-price="14.99">
                <div class="product-image">πŸ“Ί</div>
                <h3>Mini HDMI to HDMI Cable</h3>
                <p class="product-description">Connect tablets and cameras to displays, 4K@30Hz, 3ft flexible design</p>
                <div class="product-specs">
                    <span class="spec">4K@30Hz</span>
                    <span class="spec">Mini HDMI</span>
                    <span class="spec">3ft Length</span>
                </div>
                <div class="product-price">$14.99</div>
                <div class="product-rating">⭐⭐⭐⭐⭐ (312 reviews)</div>
                <button class="btn btn-primary" onclick="showProductDetails('mini-hdmi-cable')">More Details</button>
            </div>

            <div class="product-card" data-category="hdmi" data-price="14.99">
                <div class="product-image">πŸ“Ί</div>
                <h3>Micro HDMI to HDMI Cable</h3>
                <p class="product-description">Connect action cameras and devices to displays, 4K@30Hz, 3ft ultra-flexible</p>
                <div class="product-specs">
                    <span class="spec">4K@30Hz</span>
                    <span class="spec">Micro HDMI</span>
                    <span class="spec">3ft Length</span>
                </div>
                <div class="product-price">$14.99</div>
                <div class="product-rating">⭐⭐⭐⭐⭐ (284 reviews)</div>
                <button class="btn btn-primary" onclick="showProductDetails('micro-hdmi-cable')">More Details</button>
            </div>

            <!-- Lightning Cables -->
            <div class="product-card" data-category="lightning" data-price="19.99">
                <div class="product-image">⚑</div>
                <h3>Lightning to USB-A Cable (MFi)</h3>
                <p class="product-description">Apple MFi certified, 2.4A fast charging, 6ft durable cable for iPhone and iPad</p>
                <div class="product-specs">
                    <span class="spec">MFi Certified</span>
                    <span class="spec">2.4A Charging</span>
                    <span class="spec">6ft Length</span>
                </div>
                <div class="product-price">$19.99</div>
                <div class="product-rating">⭐⭐⭐⭐⭐ (1,542 reviews)</div>
                <button class="btn btn-primary" onclick="showProductDetails('lightning-cable')">More Details</button>
            </div>

            <!-- Charging Cables -->
            <div class="product-card" data-category="charging" data-price="49.99">
                <div class="product-image">πŸ”‹</div>
                <h3>Multi-Port Charging Hub</h3>
                <p class="product-description">6 ports, 100W total power, USB-C PD, smart charging technology</p>
                <div class="product-specs">
                    <span class="spec">100W Total</span>
                    <span class="spec">6 Ports</span>
                    <span class="spec">Smart Charging</span>
                </div>
                <div class="product-price">$49.99</div>
                <div class="product-rating">⭐⭐⭐⭐⭐ (692 reviews)</div>
                <button class="btn btn-primary" onclick="showProductDetails('charging-hub')">More Details</button>
            </div>

            <div class="product-card" data-category="charging" data-price="29.99">
                <div class="product-image">⚑</div>
                <h3>Wireless Charging Pad</h3>
                <p class="product-description">15W fast wireless charging, Qi-certified, LED indicator, non-slip design</p>
                <div class="product-specs">
                    <span class="spec">15W Fast</span>
                    <span class="spec">Qi Certified</span>
                    <span class="spec">LED Status</span>
                </div>
                <div class="product-price">$29.99</div>
                <div class="product-rating">⭐⭐⭐⭐⭐ (445 reviews)</div>
                <button class="btn btn-primary" onclick="showProductDetails('wireless-charging')">More Details</button>
            </div>

            <!-- Adapters & Hubs -->
            <div class="product-card" data-category="adapters" data-price="34.99">
                <div class="product-image">πŸ”—</div>
                <h3>USB-C Hub Adapter</h3>
                <p class="product-description">7-in-1 hub with HDMI, USB-A, SD card, Ethernet, compact aluminum design</p>
                <div class="product-specs">
                    <span class="spec">7-in-1 Hub</span>
                    <span class="spec">4K HDMI</span>
                    <span class="spec">Gigabit Ethernet</span>
                </div>
                <div class="product-price">$34.99</div>
                <div class="product-rating">⭐⭐⭐⭐⭐ (1,104 reviews)</div>
                <button class="btn btn-primary" onclick="showProductDetails('usb-c-hub')">More Details</button>
            </div>

            <div class="product-card" data-category="adapters" data-price="12.99">
                <div class="product-image">πŸ”„</div>
                <h3>USB-C to HDMI Adapter</h3>
                <p class="product-description">4K@30Hz video output, plug and play, ultra-compact design</p>
                <div class="product-specs">
                    <span class="spec">4K@30Hz</span>
                    <span class="spec">Plug & Play</span>
                    <span class="spec">Compact</span>
                </div>
                <div class="product-price">$12.99</div>
                <div class="product-rating">⭐⭐⭐⭐⭐ (789 reviews)</div>
                <button class="btn btn-primary" onclick="showProductDetails('usb-c-hdmi-adapter')">More Details</button>
            </div>

            <!-- Audio Cables -->
            <div class="product-card" data-category="audio" data-price="16.99">
                <div class="product-image">🎧</div>
                <h3>3.5mm Audio Cable</h3>
                <p class="product-description">Premium gold-plated connectors, tangle-free design, 6ft length</p>
                <div class="product-specs">
                    <span class="spec">Gold Plated</span>
                    <span class="spec">Tangle Free</span>
                    <span class="spec">6ft Length</span>
                </div>
                <div class="product-price">$16.99</div>
                <div class="product-rating">⭐⭐⭐⭐⭐ (567 reviews)</div>
                <button class="btn btn-primary" onclick="showProductDetails('audio-cable')">More Details</button>
            </div>

            <div class="product-card" data-category="audio" data-price="22.99">
                <div class="product-image">🎡</div>
                <h3>USB-C to 3.5mm Adapter</h3>
                <p class="product-description">High-resolution audio, 32-bit DAC, compact aluminum housing</p>
                <div class="product-specs">
                    <span class="spec">Hi-Res Audio</span>
                    <span class="spec">32-bit DAC</span>
                    <span class="spec">Aluminum</span>
                </div>
                <div class="product-price">$22.99</div>
                <div class="product-rating">⭐⭐⭐⭐⭐ (423 reviews)</div>
                <button class="btn btn-primary" onclick="showProductDetails('usb-c-audio-adapter')">More Details</button>
            </div>
        </div>
    </div>
</section>

<!-- Product Support CTA -->
<section class="product-support-cta">
    <div class="container">
                <div class="cta-content">
            <h2>Need Help Choosing?</h2>
            <p>Our AI assistant can help you find the perfect cable for your specific needs.</p>
            <a href="#" class="btn btn-primary btn-large chat-trigger-btn">Get Product Recommendations πŸ’¬</a>
        </div>
    </div>
</section>

<!-- Product Details Modal -->
<div id="product-details-modal" class="modal" style="display: none;">
    <div class="modal-content">
        <div class="modal-header">
            <h2 id="product-modal-title">Product Details</h2>
            <span class="close-modal" onclick="closeProductModal()">&times;</span>
        </div>
        <div class="modal-body">
            <div id="product-modal-content" class="product-details-content">
                <div class="loading">Loading product specifications...</div>
            </div>
        </div>
    </div>
</div>

<style>
.product-details-content {
    max-height: 70vh;
    overflow-y: auto;
    line-height: 1.6;
}

.product-details-content h3 {
    color: #2c3e50;
    margin-top: 20px;
    margin-bottom: 10px;
}

.product-details-content h4 {
    color: #34495e;
    margin-top: 15px;
    margin-bottom: 8px;
}

.product-details-content h5 {
    color: #5d6d7e;
    margin-top: 12px;
    margin-bottom: 6px;
}

.product-details-content ul {
    margin: 10px 0;
    padding-left: 20px;
}

.product-details-content li {
    margin: 5px 0;
}

.product-details-content strong {
    color: #2980b9;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #7f8c8d;
}

.error {
    text-align: center;
    padding: 40px;
    color: #e74c3c;
}

.specs-content {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
</style>
{% endblock %}

{% block extra_scripts %}
<script>
    // Product filtering functionality
    document.addEventListener('DOMContentLoaded', function() {
        const categoryFilter = document.getElementById('category-filter');
        const priceFilter = document.getElementById('price-filter');
        const productsGrid = document.getElementById('products-grid');
        const products = Array.from(productsGrid.querySelectorAll('.product-card'));

        function filterProducts() {
            const selectedCategory = categoryFilter.value;
            const selectedPriceRange = priceFilter.value;
            
            products.forEach(product => {
                const category = product.dataset.category;
                const price = parseFloat(product.dataset.price);
                
                let showProduct = true;
                
                // Category filter
                if (selectedCategory && category !== selectedCategory) {
                    showProduct = false;
                }
                
                // Price filter
                if (selectedPriceRange) {
                    const [min, max] = selectedPriceRange.split('-').map(p => p === '+' ? Infinity : parseFloat(p));
                    if (selectedPriceRange.includes('+')) {
                        if (price < min) showProduct = false;
                    } else {
                        if (price < min || price > max) showProduct = false;
                    }
                }
                
                product.style.display = showProduct ? 'block' : 'none';
            });
        }

        // Event listeners
        categoryFilter.addEventListener('change', filterProducts);
        priceFilter.addEventListener('change', filterProducts);
    });

    // Product details functionality
    async function showProductDetails(productName) {
        const modal = document.getElementById('product-details-modal');
        const title = document.getElementById('product-modal-title');
        const content = document.getElementById('product-modal-content');
        
        // Show modal with loading state
        modal.style.display = 'flex';
        title.textContent = 'Loading Product Details...';
        content.innerHTML = '<div class="loading">Loading product specifications...</div>';
        
        try {
            const response = await fetch(`/api/product/${productName}`);
            const data = await response.json();
            
            if (data.success) {
                // Set product title
                const productTitles = {
                    'usb-c-cable': 'USB-C to USB-C Cable',
                    'usb-c-to-usb-a': 'USB-C to USB-A Cable',
                    '4k-hdmi-cable': '4K HDMI Cable',
                    'hdmi-usb-c-cable': 'HDMI to USB-C Cable',
                    'charging-hub': 'Multi-Port Charging Hub',
                    'wireless-charging': 'Wireless Charging Pad',
                    'usb-c-hub': 'USB-C Hub Adapter',
                    'usb-c-hdmi-adapter': 'USB-C to HDMI Adapter',
                    'audio-cable': '3.5mm Audio Cable',
                    'usb-c-audio-adapter': 'USB-C to 3.5mm Adapter'
                };
                
                title.textContent = productTitles[productName] || 'Product Details';
                
                // Format and display specifications
                const specs = data.specifications;
                const formattedSpecs = formatProductSpecs(specs);
                content.innerHTML = formattedSpecs;
            } else {
                content.innerHTML = '<div class="error">Failed to load product specifications. Please try again.</div>';
            }
        } catch (error) {
            console.error('Error fetching product details:', error);
            content.innerHTML = '<div class="error">Failed to load product specifications. Please try again.</div>';
        }
    }

    function formatProductSpecs(specs) {
        // Convert the raw specifications text into formatted HTML
        let formatted = specs
            .replace(/\n\n/g, '</p><p>')
            .replace(/\n/g, '<br>')
            .replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>')
            .replace(/^# (.*?)$/gm, '<h3>$1</h3>')
            .replace(/^## (.*?)$/gm, '<h4>$1</h4>')
            .replace(/^### (.*?)$/gm, '<h5>$1</h5>');
        
        return `<div class="specs-content"><p>${formatted}</p></div>`;
    }

    function closeProductModal() {
        const modal = document.getElementById('product-details-modal');
        modal.style.display = 'none';
    }

    // Close modal when clicking outside
    document.addEventListener('click', function(e) {
        const modal = document.getElementById('product-details-modal');
        if (e.target === modal) {
            closeProductModal();
        }
    });
</script>
{% endblock %}