<?php
require_once 'config.php';

// Fetch some medicines to display as featured (e.g., first 6)
$stmt = $pdo->query("SELECT id, name FROM medicines ORDER BY id LIMIT 6");
$featured = $stmt->fetchAll(PDO::FETCH_ASSOC);

// Get some stats
$medicineCount = $pdo->query("SELECT COUNT(*) FROM medicines")->fetchColumn();
$orderCount = $pdo->query("SELECT COUNT(*) FROM orders")->fetchColumn();
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>HomoeoCare – Natural Healing, Homeopathic Remedies</title>
    <link rel="stylesheet" href="style.css">
    <style>
        /* Additional hero-specific styles */
        .hero {
            background: linear-gradient(135deg, #2c5e2e 0%, #4a8c4c 100%);
            color: white;
            border-radius: 32px;
            padding: 60px 40px;
            margin-bottom: 48px;
            text-align: center;
            position: relative;
            overflow: hidden;
        }
        .hero h1 {
            font-size: 3rem;
            margin-bottom: 16px;
            font-weight: 700;
        }
        .hero p {
            font-size: 1.2rem;
            margin-bottom: 32px;
            opacity: 0.95;
        }
        .hero .btn-hero {
            background: white;
            color: #2c5e2e;
            padding: 14px 32px;
            font-size: 1.1rem;
            font-weight: bold;
            border-radius: 60px;
            text-decoration: none;
            display: inline-block;
            transition: 0.2s;
        }
        .hero .btn-hero:hover {
            transform: scale(1.02);
            background: #f8f8f8;
        }
        .stats {
            display: flex;
            justify-content: center;
            gap: 40px;
            margin-top: 40px;
            flex-wrap: wrap;
        }
        .stat-item {
            background: rgba(255,255,255,0.2);
            backdrop-filter: blur(4px);
            border-radius: 60px;
            padding: 12px 28px;
            font-weight: bold;
        }
        .featured-section {
            margin-top: 40px;
        }
        .featured-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(220px,1fr));
            gap: 24px;
            margin-top: 24px;
        }
        .featured-card {
            background: #fefdf8;
            border-radius: 24px;
            padding: 18px;
            text-align: center;
            border: 1px solid #daecda;
            transition: 0.2s;
        }
        .featured-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 8px 20px rgba(0,0,0,0.1);
        }
        .featured-card h3 {
            font-size: 1.3rem;
            color: #1a3a1a;
            margin-bottom: 12px;
        }
        .btn-small {
            background: #2c5e2e;
            color: white;
            padding: 8px 20px;
            border-radius: 40px;
            text-decoration: none;
            display: inline-block;
            font-weight: 500;
        }
        .info-row {
            display: flex;
            gap: 30px;
            justify-content: space-between;
            margin: 40px 0;
            flex-wrap: wrap;
        }
        .info-box {
            flex: 1;
            background: #f9fff9;
            border-radius: 24px;
            padding: 24px;
            text-align: center;
            border: 1px solid #cfe3cf;
        }
        @media (max-width: 700px) {
            .hero h1 { font-size: 2rem; }
            .hero { padding: 40px 20px; }
            .stats { gap: 16px; }
        }
    </style>
</head>
<body>
<div class="container">
    <header>
        <h1>🌿 HomoeoCare</h1>
        <nav>
            <a href="index.php" class="active">Home</a>
            <a href="shop.php">Shop</a>
            <a href="cart.php">🛒 Cart</a>
            <a href="admin.php">Admin</a>
        </nav>
    </header>

    <!-- Hero Section -->
    <div class="hero">
        <h1>Welcome to HomoeoCare</h1>
        <p>Pure, potent, personalized homeopathic remedies – M/1 to M/30 potencies with exclusive combo savings.</p>
        <a href="shop.php" class="btn-hero">🌱 Start Shopping →</a>
        <div class="stats">
            <div class="stat-item">📚 <?= $medicineCount ?>+ Remedies</div>
            <div class="stat-item">📦 <?= $orderCount ?>+ Orders Delivered</div>
            <div class="stat-item">💊 M/1 – M/30 Potencies</div>
        </div>
    </div>

    <!-- Dynamic Featured Medicines -->
    <div class="featured-section">
        <h2>✨ Featured Remedies</h2>
        <div class="featured-grid">
            <?php if (empty($featured)): ?>
                <p>No medicines yet. <a href="admin.php">Add some via admin panel</a>.</p>
            <?php else: ?>
                <?php foreach ($featured as $med): ?>
                    <div class="featured-card">
                        <h3><?= htmlspecialchars($med['name']) ?></h3>
                        <p>Available in M/1 to M/30</p>
                        <a href="shop.php?search=<?= urlencode($med['name']) ?>" class="btn-small">Order Now</a>
                    </div>
                <?php endforeach; ?>
            <?php endif; ?>
        </div>
    </div>

    <!-- Information / How it works -->
    <div class="info-row">
        <div class="info-box">
            <h3>📲 Order via WhatsApp</h3>
            <p>Add medicines to cart, checkout, and your order is instantly sent to our admin via WhatsApp. Fast & reliable.</p>
        </div>
        <div class="info-box">
            <h3>💰 Local Payments</h3>
            <p>Cash on Delivery, bKash, Nagad – pay the way you like. Transparent pricing with combo discounts.</p>
        </div>
        <div class="info-box">
            <h3>📦 Order Tracking</h3>
            <p>Admin updates your order status (confirmed, shipped, delivered). Complete visibility from purchase to door.</p>
        </div>
    </div>

    <!-- Call to action -->
    <div style="text-align: center; margin: 40px 0 20px;">
        <a href="shop.php" class="btn-hero" style="background:#2c5e2e; color:white; border:2px solid white;">Browse All Medicines →</a>
    </div>
</div>
</body>
</html>