<?php
/** @var yii\web\View $this */
/** @var int $totalTestimonials */
/** @var int $activeTestimonials */
/** @var int $totalContent */
/** @var int $totalPlans */
/** @var int $activePlans */

use yii\helpers\Url;

$this->title = 'Dashboard';
?>

<div style="margin-bottom:2rem">
    <h2 style="font-size:1.5rem;font-weight:700;color:#0f172a;margin:0">Welcome back 👋</h2>
    <p style="color:#64748b;margin:.3rem 0 0;font-size:.9rem">Manage your website content from here.</p>
</div>

<!-- Stat Cards -->
<div style="display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:1rem;margin-bottom:2.5rem">
    <div class="cms-stat-card">
        <div class="cms-stat-icon" style="background:#f0fdf4">
            <i class="bi bi-chat-quote" style="color:#2d6a4f"></i>
        </div>
        <div>
            <div style="font-size:1.8rem;font-weight:700;color:#0f172a;line-height:1"><?= $totalTestimonials ?></div>
            <div style="font-size:.8rem;color:#64748b;margin-top:.2rem">Total Testimonials</div>
        </div>
    </div>
    <div class="cms-stat-card">
        <div class="cms-stat-icon" style="background:#dcfce7">
            <i class="bi bi-eye" style="color:#16a34a"></i>
        </div>
        <div>
            <div style="font-size:1.8rem;font-weight:700;color:#0f172a;line-height:1"><?= $activeTestimonials ?></div>
            <div style="font-size:.8rem;color:#64748b;margin-top:.2rem">Visible on Website</div>
        </div>
    </div>
    <div class="cms-stat-card">
        <div class="cms-stat-icon" style="background:#eff6ff">
            <i class="bi bi-file-text" style="color:#2563eb"></i>
        </div>
        <div>
            <div style="font-size:1.8rem;font-weight:700;color:#0f172a;line-height:1"><?= $totalContent ?></div>
            <div style="font-size:.8rem;color:#64748b;margin-top:.2rem">Content Blocks</div>
        </div>
    </div>
    <div class="cms-stat-card">
        <div class="cms-stat-icon" style="background:#fff7ed">
            <i class="bi bi-tag" style="color:#ea580c"></i>
        </div>
        <div>
            <div style="font-size:1.8rem;font-weight:700;color:#0f172a;line-height:1"><?= $activePlans ?> <span style="font-size:1rem;color:#94a3b8">/ <?= $totalPlans ?></span></div>
            <div style="font-size:.8rem;color:#64748b;margin-top:.2rem">Active Plans</div>
        </div>
    </div>
</div>

<!-- Quick Actions -->
<div class="cms-card" style="margin-bottom:2rem">
    <div class="cms-card-header"><h5>Quick Actions</h5></div>
    <div class="cms-card-body">
        <div style="display:flex;flex-wrap:wrap;gap:.75rem">
            <a href="<?= Url::to(['/webcms/default/content']) ?>" class="btn-cms-primary" style="display:inline-flex;align-items:center;gap:.4rem;text-decoration:none">
                <i class="bi bi-pencil-square"></i> Edit Text Content
            </a>
            <a href="<?= Url::to(['/webcms/testimonial/create']) ?>" class="btn-cms-primary" style="display:inline-flex;align-items:center;gap:.4rem;text-decoration:none">
                <i class="bi bi-plus-circle"></i> Add Testimonial
            </a>
            <a href="<?= Url::to(['/webcms/testimonial/index']) ?>" class="btn-cms-secondary">
                <i class="bi bi-list-ul"></i> Manage Testimonials
            </a>
            <a href="<?= Url::to(['/webcms/plan/index']) ?>" class="btn-cms-secondary">
                <i class="bi bi-tag"></i> Manage Plans
            </a>
            <a href="<?= Url::to(['/webcms/plan/create']) ?>" class="btn-cms-secondary">
                <i class="bi bi-plus-circle"></i> Add Plan
            </a>
            <a href="<?= Url::to(['/site/index']) ?>" target="_blank" class="btn-cms-secondary">
                <i class="bi bi-box-arrow-up-right"></i> View Website
            </a>
        </div>
    </div>
</div>

<!-- Help -->
<div class="cms-card">
    <div class="cms-card-header"><h5>What can I manage here?</h5></div>
    <div class="cms-card-body">
        <div style="display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:1rem">
            <?php foreach ([
                ['bi-file-text',   '#2563eb', '#eff6ff',   'Text Content',
                 'Edit the hero headline, subtext, about bio, philosophy quote, and contact settings shown across your website.'],
                ['bi-chat-quote',  '#2d6a4f', '#f0fdf4',   'Testimonials',
                 'Add, edit, reorder, or hide client testimonials that appear on the homepage and about page.'],
                ['bi-tag',         '#ea580c', '#fff7ed',   'Pricing & Plans',
                 'Add, edit, or hide subscription and one-time plans. Changes reflect instantly on the pricing page.'],
                ['bi-eye',         '#7c3aed', '#f5f3ff',   'Live Preview',
                 'Click "View Website" at any time to see exactly how your changes look to visitors.'],
            ] as $h): ?>
            <div style="display:flex;gap:.85rem;padding:1rem;background:#f8fafc;border-radius:12px">
                <div style="width:40px;height:40px;border-radius:10px;background:<?= $h[2] ?>;display:flex;align-items:center;justify-content:center;flex-shrink:0">
                    <i class="bi <?= $h[0] ?>" style="color:<?= $h[1] ?>"></i>
                </div>
                <div>
                    <div style="font-weight:600;font-size:.9rem;color:#0f172a;margin-bottom:.25rem"><?= $h[3] ?></div>
                    <div style="font-size:.8rem;color:#64748b;line-height:1.55"><?= $h[4] ?></div>
                </div>
            </div>
            <?php endforeach; ?>
        </div>
    </div>
</div>
