<?php
require_once 'config.php';
require_once 'includes/product.php';

$pageTitle = 'Home';
$productModel = new Product();
$products = $productModel->getAll(null, null, 8);
$categories = $productModel->getCategories();

require_once 'includes/header.php';
?>

<!-- Hero Section -->
<section class="hero">
    <div class="hero-pattern"></div>
    <div class="hero-content">
        <h1>Rorschach Co.</h1>
        <p>Minimalist fashion for the modern era. Quality craftsmanship, timeless design.</p>
        <a href="<?php echo SITE_URL; ?>/products.php" class="btn btn-primary btn-large">Shop Collection</a>
    </div>
</section>

<!-- Featured Products -->
<section class="products-section">
    <div class="container">
        <div class="section-header">
            <h2 class="section-title">Latest Collection</h2>
            <a href="<?php echo SITE_URL; ?>/products.php" class="btn btn-secondary">View All</a>
        </div>
        
        <div class="product-grid">
            <?php foreach ($products as $product): ?>
                <div class="product-card">
                    <a href="<?php echo SITE_URL; ?>/product.php?id=<?php echo $product['id']; ?>">
                        <div class="product-image">
                            <img src="<?php echo htmlspecialchars($product['image_url']); ?>" alt="<?php echo htmlspecialchars($product['name']); ?>">
                            <div class="product-overlay">
                                <span class="btn btn-primary">View Details</span>
                            </div>
                        </div>
                        <div class="product-info">
                            <div class="product-category"><?php echo htmlspecialchars($product['category']); ?></div>
                            <h3 class="product-name"><?php echo htmlspecialchars($product['name']); ?></h3>
                            <div class="product-price"><?php echo formatPrice($product['price']); ?></div>
                        </div>
                    </a>
                </div>
            <?php endforeach; ?>
        </div>
    </div>
</section>

<!-- Categories Section -->
<section class="products-section" style="background: var(--off-white);">
    <div class="container">
        <div class="section-header">
            <h2 class="section-title">Shop by Category</h2>
        </div>
        
        <div class="product-grid">
            <?php foreach ($categories as $category): ?>
                <div class="product-card">
                    <a href="<?php echo SITE_URL; ?>/products.php?category=<?php echo urlencode($category); ?>">
                        <div class="product-image" style="background: var(--primary-black); display: flex; align-items: center; justify-content: center;">
                            <h3 style="color: var(--pure-white); font-size: 1.5rem; letter-spacing: 4px; text-transform: uppercase;"><?php echo htmlspecialchars($category); ?></h3>
                        </div>
                        <div class="product-info" style="text-align: center;">
                            <span class="btn btn-secondary btn-block">Shop <?php echo htmlspecialchars($category); ?></span>
                        </div>
                    </a>
                </div>
            <?php endforeach; ?>
        </div>
    </div>
</section>

<!-- About Section -->
<section class="products-section">
    <div class="container">
        <div style="max-width: 800px; margin: 0 auto; text-align: center;">
            <h2 class="section-title" style="margin-bottom: var(--spacing-lg);">Our Philosophy</h2>
            <p style="font-size: 1.125rem; color: var(--medium-gray); line-height: 1.8; margin-bottom: var(--spacing-xl);">
                At Rorschach Co., we believe in the power of simplicity. Our collections are designed for those who appreciate clean lines, quality materials, and timeless aesthetics. Each piece is crafted with meticulous attention to detail, ensuring both comfort and durability.
            </p>
            <a href="<?php echo SITE_URL; ?>/about.php" class="btn btn-secondary">Learn More</a>
        </div>
    </div>
</section>

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