<?php
/**
 * Template Retail (E-Commerce) - Tema Claro Elegante
 * Template para lojas de varejo/e-commerce
 */

// Verificar se foi chamado corretamente
if (!defined('BARBERFLOW')) {
    die('Acesso negado');
}

// Variáveis esperadas: $store, $pdo, $currentStoreId, $storeName, $logo, $banner, $whatsapp, $address, $city

// Buscar produtos para o e-commerce
try {
    $productsStmt = $pdo->prepare("SELECT * FROM products WHERE store_id = ? AND is_active = 1 ORDER BY id DESC LIMIT 16");
    $productsStmt->execute([$currentStoreId]);
    $products = $productsStmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
    $products = [];
}

// Buscar categorias
try {
    $categoriesStmt = $pdo->prepare("SELECT DISTINCT category FROM products WHERE store_id = ? AND is_active = 1 AND category IS NOT NULL AND category != '' LIMIT 6");
    $categoriesStmt->execute([$currentStoreId]);
    $categories = $categoriesStmt->fetchAll(PDO::FETCH_COLUMN);
} catch (PDOException $e) {
    $categories = [];
}
?>
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo htmlspecialchars($storeName); ?> - Loja Online</title>
<meta name="description" content="<?php echo htmlspecialchars($storeName); ?> - Loja online com os melhores produtos.">
<meta name="theme-color" content="#ffffff">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/iconify-icon@1.0.7/dist/iconify-icon.min.js"></script>
<style>
:root {
    --bg: <?php echo htmlspecialchars($bgColor ?? '#FAFBFC'); ?>;
    --bg-white: <?php echo htmlspecialchars($cardColor ?? '#FFFFFF'); ?>;
    --surface: <?php echo htmlspecialchars($cardColor ?? '#FFFFFF'); ?>;
    --surface-hover: #F8F9FA;
    --border: #E5E7EB;
    --border-light: #F3F4F6;
    --primary: <?php echo htmlspecialchars($primaryColor ?? '#2563EB'); ?>;
    --primary-soft: <?php echo htmlspecialchars($primaryColor ?? '#2563EB'); ?>14;
    --primary-hover: <?php echo htmlspecialchars($customSettings['colors']['secondary'] ?? $primaryColor ?? '#1D4ED8'); ?>;
    --accent: <?php echo htmlspecialchars($accentColor ?? '#10B981'); ?>;
    --accent-soft: <?php echo htmlspecialchars($accentColor ?? '#10B981'); ?>1A;
    --text: <?php echo htmlspecialchars($textColor ?? '#111827'); ?>;
    --text-secondary: <?php echo htmlspecialchars($textSecondary ?? '#4B5563'); ?>;
    --muted: #9CA3AF;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 4px 12px rgba(0,0,0,0.05);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.08);
    --radius: 12px;
    --radius-lg: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

/* ===== HEADER SUPERIOR ===== */
.top-header {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-light);
    z-index: 100;
}

.top-header.sticky-header {
    position: sticky;
    top: 0;
}

.header-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
    height: 72px;
    display: flex;
    align-items: center;
    gap: 32px;
}

/* Logo */
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text);
    flex-shrink: 0;
}

.brand-logo {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary) 0%, #3B82F6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 800;
    font-size: 1.1rem;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
    overflow: hidden;
}

.brand-logo.has-image {
    background: transparent;
    box-shadow: none;
}

.brand-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 10px;
}

.brand-name {
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.02em;
}

/* Menu de navegação */
.nav-menu {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-link {
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
}

.nav-link:hover {
    color: var(--text);
    background: var(--surface-hover);
}

.nav-link.active {
    color: var(--primary);
    background: var(--primary-soft);
}

/* Barra de pesquisa */
.search-bar {
    flex: 1;
    max-width: 480px;
    position: relative;
}

.search-bar input {
    width: 100%;
    height: 44px;
    padding: 0 16px 0 44px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: var(--bg);
    font-size: 0.9rem;
    color: var(--text);
    transition: all 0.2s;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-white);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.search-bar input::placeholder {
    color: var(--muted);
}

.search-bar .search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 1.1rem;
}

/* Ações do header */
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.action-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-white);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.action-btn:hover {
    background: var(--surface-hover);
    border-color: var(--border);
    color: var(--text);
}

.action-btn .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: var(--primary);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px 6px 6px;
    border-radius: 24px;
    border: 1px solid var(--border);
    background: var(--bg-white);
    cursor: pointer;
    transition: all 0.2s;
}

.user-btn:hover {
    background: var(--surface-hover);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #E0E7FF 0%, #C7D2FE 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 0.85rem;
}

.user-btn span {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* ===== HERO BANNER ===== */
.hero-banner {
    position: relative;
    height: 400px;
    background: linear-gradient(135deg, #667EEA 0%, #764BA2 50%, #F093FB 100%);
    overflow: hidden;
}

.hero-banner.has-image {
    background: #1a1a2e;
}

.hero-banner .banner-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.9;
}

.hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.4) 100%);
}

.hero-content {
    position: relative;
    z-index: 10;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.hero-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(10px);
    border-radius: 50px;
    color: white;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 16px;
    width: fit-content;
}

.hero-title {
    font-size: 3rem;
    font-weight: 800;
    color: white;
    line-height: 1.1;
    max-width: 600px;
    margin-bottom: 16px;
    text-shadow: 0 2px 20px rgba(0,0,0,0.2);
}

.hero-subtitle {
    font-size: 1.1rem;
    color: rgba(255,255,255,0.9);
    max-width: 500px;
    margin-bottom: 24px;
}

.hero-cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    background: white;
    color: var(--text);
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: 50px;
    text-decoration: none;
    transition: all 0.2s;
    box-shadow: var(--shadow-lg);
    width: fit-content;
}

.hero-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 48px rgba(0,0,0,0.15);
}

/* ===== MAIN CONTENT ===== */
.main-content {
    max-width: 1280px;
    margin: 0 auto;
    padding: 40px 24px 60px;
}

/* Section header */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
}

.section-link {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--primary);
    text-decoration: none;
}

.section-link:hover {
    text-decoration: underline;
}

/* Categories */
.categories-row {
    display: flex;
    gap: 12px;
    margin-bottom: 32px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.category-chip {
    flex-shrink: 0;
    padding: 10px 20px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.category-chip:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.category-chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* Products Grid */
.products-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
}

.product-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-light);
    transition: all 0.3s;
}

.product-card:hover {
    border-color: var(--border);
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
}

.product-image {
    position: relative;
    aspect-ratio: 1;
    background: linear-gradient(135deg, #F8FAFC 0%, #F1F5F9 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

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

.product-placeholder {
    width: 80px;
    height: 100px;
    background: linear-gradient(180deg, #E2E8F0 0%, #CBD5E1 100%);
    border-radius: 8px;
}

.product-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 6px 12px;
    background: var(--accent);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 6px;
    text-transform: uppercase;
}

.product-wishlist {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
    border: none;
}

.product-wishlist:hover {
    color: #EF4444;
    transform: scale(1.1);
}

.product-info {
    padding: 16px;
}

.product-category {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.product-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

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

.product-rating iconify-icon {
    color: #FBBF24;
    font-size: 0.9rem;
}

.product-rating span {
    font-size: 0.8rem;
    color: var(--muted);
}

.product-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.product-price {
    display: flex;
    flex-direction: column;
}

.price-current {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
}

.price-old {
    font-size: 0.8rem;
    color: var(--muted);
    text-decoration: line-through;
}

.btn-add-cart {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--primary);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-add-cart:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

/* ===== FOOTER ===== */
.site-footer {
    background: var(--bg-white);
    border-top: 1px solid var(--border-light);
    padding: 48px 24px 24px;
    margin-top: 40px;
}

.footer-inner {
    max-width: 1280px;
    margin: 0 auto;
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 48px;
    margin-bottom: 40px;
}

.footer-brand {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.footer-brand p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.footer-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
}

.footer-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.footer-links a {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--primary);
}

.footer-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 24px;
    border-top: 1px solid var(--border-light);
    font-size: 0.85rem;
    color: var(--muted);
}

.footer-social {
    display: flex;
    gap: 12px;
}

.footer-social a {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
}

.footer-social a:hover {
    background: var(--primary);
    color: white;
}

/* ===== RESPONSIVO ===== */
@media (max-width: 1024px) {
    .products-grid { grid-template-columns: repeat(3, 1fr); }
    .footer-grid { grid-template-columns: 1fr 1fr; gap: 32px; }
}

@media (max-width: 768px) {
    .header-inner { height: 64px; gap: 16px; }
    .nav-menu { display: none; }
    .search-bar { max-width: none; }
    .user-btn span { display: none; }
    .hero-banner { height: 320px; }
    .hero-title { font-size: 2rem; }
    .products-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
    .footer-grid { grid-template-columns: 1fr; }
    .footer-bottom { flex-direction: column; gap: 16px; text-align: center; }
}

@media (max-width: 480px) {
    .header-actions .action-btn:not(.cart-btn) { display: none; }
    .hero-title { font-size: 1.75rem; }
    .hero-subtitle { font-size: 0.95rem; }
    .product-info { padding: 12px; }
    .product-name { font-size: 0.9rem; }
}
</style>
</head>
<body>

<?php
// Configurações do cabeçalho (vindas do storefront_home.php)
$headerSettings = $headerSettings ?? [
    'logo_type' => 'text',
    'logo_text' => $storeName,
    'logo_image' => $logo,
    'show_search' => true,
    'show_cart' => true,
    'show_wishlist' => true,
    'sticky' => true
];
$stickyClass = ($headerSettings['sticky'] ?? true) ? ' sticky-header' : '';
?>

<!-- HEADER SUPERIOR -->
<header class="top-header<?php echo $stickyClass; ?>">
    <div class="header-inner">
        <!-- Logo -->
        <a href="#" class="brand">
            <?php 
            $logoType = $headerSettings['logo_type'] ?? 'text';
            $logoImage = !empty($headerSettings['logo_image']) ? $headerSettings['logo_image'] : $logo;
            $logoText = !empty($headerSettings['logo_text']) ? $headerSettings['logo_text'] : $storeName;
            ?>
            
            <?php if ($logoType === 'image' || $logoType === 'both'): ?>
                <?php if (!empty($logoImage)): ?>
                    <div class="brand-logo has-image">
                        <img src="<?php echo htmlspecialchars($logoImage); ?>" alt="<?php echo htmlspecialchars($logoText); ?>">
                    </div>
                <?php else: ?>
                    <div class="brand-logo">
                        <?php echo strtoupper(substr($logoText, 0, 1)); ?>
                    </div>
                <?php endif; ?>
            <?php endif; ?>
            
            <?php if ($logoType === 'text'): ?>
                <div class="brand-logo">
                    <?php echo strtoupper(substr($logoText, 0, 1)); ?>
                </div>
            <?php endif; ?>
            
            <?php if ($logoType === 'text' || $logoType === 'both'): ?>
                <span class="brand-name"><?php echo htmlspecialchars($logoText); ?></span>
            <?php endif; ?>
        </a>

        <!-- Menu de navegação -->
        <nav class="nav-menu">
            <a href="#" class="nav-link active">Início</a>
            <a href="#produtos" class="nav-link">Produtos</a>
            <a href="#" class="nav-link">Ofertas</a>
            <a href="#" class="nav-link">Contato</a>
        </nav>

        <?php if ($headerSettings['show_search'] ?? true): ?>
        <!-- Barra de pesquisa -->
        <div class="search-bar">
            <iconify-icon icon="solar:magnifer-bold" class="search-icon"></iconify-icon>
            <input type="text" placeholder="Buscar produtos..." aria-label="Buscar produtos">
        </div>
        <?php endif; ?>

        <!-- Ações do header -->
        <div class="header-actions">
            <?php if ($headerSettings['show_wishlist'] ?? true): ?>
            <button class="action-btn" title="Favoritos">
                <iconify-icon icon="solar:heart-outline" style="font-size: 1.3rem;"></iconify-icon>
            </button>
            <?php endif; ?>
            
            <?php if ($headerSettings['show_cart'] ?? true): ?>
            <button class="action-btn cart-btn" title="Carrinho">
                <iconify-icon icon="solar:bag-3-outline" style="font-size: 1.3rem;"></iconify-icon>
                <span class="badge">0</span>
            </button>
            <?php endif; ?>
            
            <button class="user-btn">
                <div class="user-avatar">
                    <iconify-icon icon="solar:user-bold"></iconify-icon>
                </div>
                <span>Entrar</span>
            </button>
        </div>
    </div>
</header>

<!-- HERO BANNER -->
<section class="hero-banner <?php echo !empty($banner) ? 'has-image' : ''; ?>">
    <?php if (!empty($banner)): ?>
        <img src="<?php echo htmlspecialchars($banner); ?>" alt="Banner" class="banner-image">
    <?php endif; ?>
    <div class="hero-overlay"></div>
    <div class="hero-content">
        <div class="hero-tag">
            <iconify-icon icon="solar:star-bold"></iconify-icon>
            Novidades da Semana
        </div>
        <h1 class="hero-title">Descubra produtos incríveis para você</h1>
        <p class="hero-subtitle">Qualidade premium, preços especiais e entrega rápida. Aproveite nossas ofertas exclusivas.</p>
        <a href="#produtos" class="hero-cta">
            <iconify-icon icon="solar:bag-3-bold"></iconify-icon>
            Ver Produtos
        </a>
    </div>
</section>

<!-- MAIN CONTENT -->
<main class="main-content" id="produtos">
    <!-- Categorias -->
    <div class="categories-row">
        <button class="category-chip active">Todos</button>
        <?php if (!empty($categories)): ?>
            <?php foreach ($categories as $cat): ?>
                <button class="category-chip"><?php echo htmlspecialchars($cat); ?></button>
            <?php endforeach; ?>
        <?php else: ?>
            <button class="category-chip">Novidades</button>
            <button class="category-chip">Mais Vendidos</button>
            <button class="category-chip">Promoções</button>
        <?php endif; ?>
    </div>

    <!-- Section header -->
    <div class="section-header">
        <h2 class="section-title">Nossos Produtos</h2>
        <a href="#" class="section-link">
            Ver todos
            <iconify-icon icon="solar:arrow-right-linear"></iconify-icon>
        </a>
    </div>

    <!-- Products Grid -->
    <div class="products-grid">
        <?php if (!empty($products)): ?>
            <?php foreach ($products as $p): ?>
            <article class="product-card">
                <div class="product-image">
                    <?php if (!empty($p['image'])): ?>
                        <img src="<?php echo htmlspecialchars($p['image']); ?>" alt="<?php echo htmlspecialchars($p['name']); ?>">
                    <?php else: ?>
                        <div class="product-placeholder"></div>
                    <?php endif; ?>
                    <span class="product-badge">Novo</span>
                    <button class="product-wishlist" title="Adicionar aos favoritos">
                        <iconify-icon icon="solar:heart-outline" style="font-size: 1.1rem;"></iconify-icon>
                    </button>
                </div>
                <div class="product-info">
                    <div class="product-category"><?php echo htmlspecialchars($p['category'] ?? 'Produto'); ?></div>
                    <h3 class="product-name"><?php echo htmlspecialchars($p['name']); ?></h3>
                    <div class="product-rating">
                        <iconify-icon icon="solar:star-bold"></iconify-icon>
                        <iconify-icon icon="solar:star-bold"></iconify-icon>
                        <iconify-icon icon="solar:star-bold"></iconify-icon>
                        <iconify-icon icon="solar:star-bold"></iconify-icon>
                        <iconify-icon icon="solar:star-outline"></iconify-icon>
                        <span>(4.0)</span>
                    </div>
                    <div class="product-footer">
                        <div class="product-price">
                            <span class="price-current">R$ <?php echo number_format($p['price'] ?? 0, 2, ',', '.'); ?></span>
                        </div>
                        <button class="btn-add-cart" title="Adicionar ao carrinho">
                            <iconify-icon icon="solar:cart-plus-bold" style="font-size: 1.2rem;"></iconify-icon>
                        </button>
                    </div>
                </div>
            </article>
            <?php endforeach; ?>
        <?php else: ?>
            <?php for ($i = 0; $i < 8; $i++): ?>
            <article class="product-card">
                <div class="product-image">
                    <div class="product-placeholder"></div>
                    <span class="product-badge">Novo</span>
                    <button class="product-wishlist" title="Adicionar aos favoritos">
                        <iconify-icon icon="solar:heart-outline" style="font-size: 1.1rem;"></iconify-icon>
                    </button>
                </div>
                <div class="product-info">
                    <div class="product-category">Categoria</div>
                    <h3 class="product-name">Produto de Exemplo</h3>
                    <div class="product-rating">
                        <iconify-icon icon="solar:star-bold"></iconify-icon>
                        <iconify-icon icon="solar:star-bold"></iconify-icon>
                        <iconify-icon icon="solar:star-bold"></iconify-icon>
                        <iconify-icon icon="solar:star-bold"></iconify-icon>
                        <iconify-icon icon="solar:star-outline"></iconify-icon>
                        <span>(4.0)</span>
                    </div>
                    <div class="product-footer">
                        <div class="product-price">
                            <span class="price-current">R$ 99,90</span>
                        </div>
                        <button class="btn-add-cart" title="Adicionar ao carrinho">
                            <iconify-icon icon="solar:cart-plus-bold" style="font-size: 1.2rem;"></iconify-icon>
                        </button>
                    </div>
                </div>
            </article>
            <?php endfor; ?>
        <?php endif; ?>
    </div>
</main>

<!-- FOOTER -->
<footer class="site-footer">
    <div class="footer-inner">
        <div class="footer-grid">
            <div class="footer-brand">
                <a href="#" class="brand">
                    <div class="brand-logo">
                        <?php if (!empty($logo)): ?>
                            <img src="<?php echo htmlspecialchars($logo); ?>" alt="">
                        <?php else: ?>
                            <?php echo strtoupper(substr($storeName, 0, 1)); ?>
                        <?php endif; ?>
                    </div>
                    <span class="brand-name"><?php echo htmlspecialchars($storeName); ?></span>
                </a>
                <p>Sua loja online de confiança. Produtos de qualidade com os melhores preços e entrega rápida para todo o Brasil.</p>
            </div>
            <div>
                <h4 class="footer-title">Links</h4>
                <ul class="footer-links">
                    <li><a href="#">Início</a></li>
                    <li><a href="#">Produtos</a></li>
                    <li><a href="#">Ofertas</a></li>
                    <li><a href="#">Sobre nós</a></li>
                </ul>
            </div>
            <div>
                <h4 class="footer-title">Ajuda</h4>
                <ul class="footer-links">
                    <li><a href="#">FAQ</a></li>
                    <li><a href="#">Entregas</a></li>
                    <li><a href="#">Trocas</a></li>
                    <li><a href="#">Contato</a></li>
                </ul>
            </div>
            <div>
                <h4 class="footer-title">Contato</h4>
                <ul class="footer-links">
                    <?php if ($whatsapp): ?>
                    <li><a href="https://wa.me/55<?php echo preg_replace('/\D/', '', $whatsapp); ?>"><?php echo htmlspecialchars($whatsapp); ?></a></li>
                    <?php endif; ?>
                    <?php if ($address || $city): ?>
                    <li><a href="#"><?php echo htmlspecialchars(trim($address . ($city ? ', ' . $city : ''))); ?></a></li>
                    <?php endif; ?>
                </ul>
            </div>
        </div>
        <div class="footer-bottom">
            <span>&copy; <?php echo date('Y'); ?> <?php echo htmlspecialchars($storeName); ?>. Todos os direitos reservados.</span>
            <div class="footer-social">
                <a href="#" title="Instagram"><iconify-icon icon="mdi:instagram" style="font-size: 1.2rem;"></iconify-icon></a>
                <a href="#" title="Facebook"><iconify-icon icon="mdi:facebook" style="font-size: 1.2rem;"></iconify-icon></a>
                <?php if ($whatsapp): ?>
                <a href="https://wa.me/55<?php echo preg_replace('/\D/', '', $whatsapp); ?>" title="WhatsApp"><iconify-icon icon="mdi:whatsapp" style="font-size: 1.2rem;"></iconify-icon></a>
                <?php endif; ?>
            </div>
        </div>
    </div>
</footer>

<script>
// Smooth scroll para links internos
document.querySelectorAll('a[href^="#"]').forEach(a => {
    a.addEventListener('click', function(e) {
        e.preventDefault();
        const target = document.querySelector(this.getAttribute('href'));
        if (target) {
            target.scrollIntoView({ behavior: 'smooth', block: 'start' });
        }
    });
});

// Categoria ativa
document.querySelectorAll('.category-chip').forEach(chip => {
    chip.addEventListener('click', function() {
        document.querySelectorAll('.category-chip').forEach(c => c.classList.remove('active'));
        this.classList.add('active');
    });
});
</script>

</body>
</html>
