<?php
$page_title = 'Subscriptions & Repeat Orders';
require_once __DIR__ . '/header.php';
?>
<div style="display:flex; justify-content:space-between; align-items:center; margin-bottom:24px;">
    <div>
        <h2 style="font-family:'Outfit',sans-serif; font-size:1.8rem; color:#0f172a; margin:0;"><i class="fas fa-sync-alt" style="color:#10b981; margin-right:10px;"></i>Subscriptions & Repeat Orders</h2>
        <p style="color:#64748b; font-size:0.95rem; margin-top:5px;">Auto-refill, monthly reorders, consumable subscriptions, and standing POs.</p>
    </div>
</div>
<div class="grid-3" style="margin-bottom:24px;">
    <div class="card" style="margin-bottom:0; border-top:4px solid #10b981;">
        <div style="color:#64748b; font-size:0.8rem; font-weight:600; margin-bottom:8px;">ACTIVE SUBSCRIPTIONS</div>
        <div style="font-size:1.4rem; font-weight:700; color:#0f172a;">3</div>
        <div style="color:#10b981; font-size:0.8rem; margin-top:5px;"><i class="fas fa-redo"></i> Auto-renewing</div>
    </div>
    <div class="card" style="margin-bottom:0; border-top:4px solid #3b82f6;">
        <div style="color:#64748b; font-size:0.8rem; font-weight:600; margin-bottom:8px;">MONTHLY SPEND</div>
        <div style="font-size:1.4rem; font-weight:700; color:#0f172a;">₹42,800</div>
        <div style="color:#3b82f6; font-size:0.8rem; margin-top:5px;"><i class="fas fa-chart-line"></i> Avg/month</div>
    </div>
    <div class="card" style="margin-bottom:0; border-top:4px solid #f59e0b;">
        <div style="color:#64748b; font-size:0.8rem; font-weight:600; margin-bottom:8px;">NEXT DELIVERY</div>
        <div style="font-size:1.4rem; font-weight:700; color:#0f172a;">May 5</div>
        <div style="color:#f59e0b; font-size:0.8rem; margin-top:5px;"><i class="fas fa-calendar"></i> In 5 Days</div>
    </div>
</div>
<div class="grid-2">
    <div class="card">
        <h3 style="margin:0 0 15px; font-size:1.15rem; color:#0f172a;"><i class="fas fa-redo" style="color:#10b981; margin-right:8px;"></i>Active Subscriptions</h3>
        <?php
        $subs = [
            ['Cleaning Supplies Kit', 'Monthly', '₹2,400/mo', 'May 5', '#10b981', 'Active'],
            ['Drain Filters (10-pack)', 'Quarterly', '₹1,800/qtr', 'Jun 15', '#3b82f6', 'Active'],
            ['Polish & Care Set', 'Monthly', '₹950/mo', 'May 5', '#f59e0b', 'Active'],
        ];
        foreach ($subs as $s): ?>
        <div style="border:1px solid #e2e8f0; border-radius:8px; padding:15px; margin-bottom:10px;">
            <div style="display:flex; justify-content:space-between; margin-bottom:5px;">
                <div style="font-weight:600; font-size:0.9rem;"><?= $s[0] ?></div>
                <span style="background:#dcfce7; color:#166534; padding:3px 8px; border-radius:6px; font-size:0.7rem; font-weight:bold;"><?= $s[5] ?></span>
            </div>
            <div style="display:flex; justify-content:space-between; font-size:0.8rem; color:#64748b;">
                <span><?= $s[1] ?> · <?= $s[2] ?></span>
                <span>Next: <?= $s[3] ?></span>
            </div>
        </div>
        <?php endforeach; ?>
        <button style="background:#10b981; color:#fff; border:none; padding:10px 20px; border-radius:8px; font-size:0.85rem; cursor:pointer; width:100%; font-weight:600;"><i class="fas fa-plus"></i> New Subscription</button>
    </div>
    <div class="card">
        <h3 style="margin:0 0 15px; font-size:1.15rem; color:#0f172a;"><i class="fas fa-history" style="color:#8b5cf6; margin-right:8px;"></i>Quick Reorder</h3>
        <p style="font-size:0.85rem; color:#64748b; margin-bottom:15px;">Repeat your last orders with one click.</p>
        <?php
        $reorders = [
            ['Order #BM-24521', 'Double Bowl Sink ×2, Faucet ×2', '₹25,300', '15 Apr'],
            ['Order #BM-24480', 'Single Bowl Sink ×5', '₹28,750', '2 Apr'],
            ['Order #BM-24412', 'Accessories Kit ×10', '₹12,400', '18 Mar'],
        ];
        foreach ($reorders as $r): ?>
        <div style="border:1px solid #e2e8f0; border-radius:8px; padding:12px; margin-bottom:8px; display:flex; justify-content:space-between; align-items:center;">
            <div>
                <div style="font-weight:600; font-size:0.85rem;"><?= $r[0] ?></div>
                <div style="font-size:0.75rem; color:#94a3b8;"><?= $r[1] ?> · <?= $r[3] ?></div>
            </div>
            <button style="background:#2563eb; color:#fff; border:none; padding:6px 12px; border-radius:6px; font-size:0.75rem; cursor:pointer; white-space:nowrap;"><i class="fas fa-redo"></i> Reorder <?= $r[2] ?></button>
        </div>
        <?php endforeach; ?>
    </div>
</div>
<?php require_once __DIR__ . '/../includes/footer.php'; ?>
