<% layout('admin/layout') -%>

<div class="space-y-6">
    <!-- Header -->
    <div class="bg-white shadow rounded-lg p-6">
        <h1 class="text-2xl font-bold text-gray-900 flex items-center">
            <i class="fas fa-tachometer-alt mr-3 text-blue-600"></i>
            Панель управления
        </h1>
        <p class="mt-2 text-gray-600">Обзор основных показателей сайта</p>
    </div>

    <!-- Stats Grid -->
    <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
        <!-- Portfolio Projects -->
        <div class="bg-white overflow-hidden shadow rounded-lg">
            <div class="p-5">
                <div class="flex items-center">
                    <div class="flex-shrink-0">
                        <i class="fas fa-briefcase text-blue-600 text-2xl"></i>
                    </div>
                    <div class="ml-5 w-0 flex-1">
                        <dl>
                            <dt class="text-sm font-medium text-gray-500 truncate">
                                Проекты
                            </dt>
                            <dd class="text-lg font-medium text-gray-900">
                                <%= stats.portfolioCount || 0 %>
                            </dd>
                        </dl>
                    </div>
                </div>
            </div>
            <div class="bg-gray-50 px-5 py-3">
                <div class="text-sm">
                    <a href="/admin/portfolio" class="font-medium text-blue-600 hover:text-blue-500">
                        Посмотреть всё
                    </a>
                </div>
            </div>
        </div>

        <!-- Services -->
        <div class="bg-white overflow-hidden shadow rounded-lg">
            <div class="p-5">
                <div class="flex items-center">
                    <div class="flex-shrink-0">
                        <i class="fas fa-cog text-green-600 text-2xl"></i>
                    </div>
                    <div class="ml-5 w-0 flex-1">
                        <dl>
                            <dt class="text-sm font-medium text-gray-500 truncate">
                                Услуги
                            </dt>
                            <dd class="text-lg font-medium text-gray-900">
                                <%= stats.servicesCount || 0 %>
                            </dd>
                        </dl>
                    </div>
                </div>
            </div>
            <div class="bg-gray-50 px-5 py-3">
                <div class="text-sm">
                    <a href="/admin/services" class="font-medium text-green-600 hover:text-green-500">
                        Посмотреть всё
                    </a>
                </div>
            </div>
        </div>

        <!-- Contact Messages -->
        <div class="bg-white overflow-hidden shadow rounded-lg">
            <div class="p-5">
                <div class="flex items-center">
                    <div class="flex-shrink-0">
                        <i class="fas fa-envelope text-purple-600 text-2xl"></i>
                    </div>
                    <div class="ml-5 w-0 flex-1">
                        <dl>
                            <dt class="text-sm font-medium text-gray-500 truncate">
                                Сообщения
                            </dt>
                            <dd class="text-lg font-medium text-gray-900">
                                <%= stats.contactsCount || 0 %>
                            </dd>
                        </dl>
                    </div>
                </div>
            </div>
            <div class="bg-gray-50 px-5 py-3">
                <div class="text-sm">
                    <a href="/admin/contacts" class="font-medium text-purple-600 hover:text-purple-500">
                        Посмотреть всё
                    </a>
                </div>
            </div>
        </div>

        <!-- Users -->
        <div class="bg-white overflow-hidden shadow rounded-lg">
            <div class="p-5">
                <div class="flex items-center">
                    <div class="flex-shrink-0">
                        <i class="fas fa-users text-orange-600 text-2xl"></i>
                    </div>
                    <div class="ml-5 w-0 flex-1">
                        <dl>
                            <dt class="text-sm font-medium text-gray-500 truncate">
                                Пользователи
                            </dt>
                            <dd class="text-lg font-medium text-gray-900">
                                <%= stats.usersCount || 0 %>
                            </dd>
                        </dl>
                    </div>
                </div>
            </div>
            <div class="bg-gray-50 px-5 py-3">
                <div class="text-sm">
                    <a href="/admin/users" class="font-medium text-orange-600 hover:text-orange-500">
                        Посмотреть всё
                    </a>
                </div>
            </div>
        </div>
    </div>

    <!-- Recent Activity -->
    <div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
        <!-- Recent Portfolio Projects -->
        <div class="bg-white shadow rounded-lg">
            <div class="px-6 py-4 border-b border-gray-200">
                <h3 class="text-lg font-medium text-gray-900">
                    Последние проекты
                </h3>
            </div>
            <div class="p-6">
                <% if (recentPortfolio && recentPortfolio.length > 0) { %>
                    <div class="space-y-4">
                        <% recentPortfolio.forEach(function(project) { %>
                            <div class="flex items-center space-x-4">
                                <div class="flex-shrink-0">
                                    <i class="fas fa-briefcase text-blue-600"></i>
                                </div>
                                <div class="flex-1 min-w-0">
                                    <p class="text-sm font-medium text-gray-900 truncate">
                                        <%= project.title %>
                                    </p>
                                    <p class="text-sm text-gray-500">
                                        <%= project.category %>
                                    </p>
                                </div>
                                <div class="flex-shrink-0">
                                    <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">
                                        <%= project.status %>
                                    </span>
                                </div>
                            </div>
                        <% }); %>
                    </div>
                <% } else { %>
                    <p class="text-gray-500 text-sm">Нет недавних проектов</p>
                <% } %>
            </div>
        </div>

        <!-- Recent Contact Messages -->
        <div class="bg-white shadow rounded-lg">
            <div class="px-6 py-4 border-b border-gray-200">
                <h3 class="text-lg font-medium text-gray-900">
                    Последние сообщения
                </h3>
            </div>
            <div class="p-6">
                <% if (recentContacts && recentContacts.length > 0) { %>
                    <div class="space-y-4">
                        <% recentContacts.forEach(function(contact) { %>
                            <div class="flex items-center space-x-4">
                                <div class="flex-shrink-0">
                                    <i class="fas fa-envelope text-purple-600"></i>
                                </div>
                                <div class="flex-1 min-w-0">
                                    <p class="text-sm font-medium text-gray-900 truncate">
                                        <%= contact.name %>
                                    </p>
                                    <p class="text-sm text-gray-500 truncate">
                                        <%= contact.email %>
                                    </p>
                                </div>
                                <div class="flex-shrink-0">
                                    <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-yellow-100 text-yellow-800">
                                        <%= contact.status %>
                                    </span>
                                </div>
                            </div>
                        <% }); %>
                    </div>
                <% } else { %>
                    <p class="text-gray-500 text-sm"><%= t('admin.no_recent_contacts') %></p>
                <% } %>
            </div>
        </div>
    </div>

    <!-- Quick Actions -->
    <div class="bg-white shadow rounded-lg p-6">
        <h3 class="text-lg font-medium text-gray-900 mb-4">
            <%= t('admin.quick_actions') %>
        </h3>
        <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
            <a href="/admin/portfolio/new" 
               class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700">
                <i class="fas fa-plus mr-2"></i>
                <%= t('admin.add_portfolio') %>
            </a>
            <a href="/admin/services/new" 
               class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-green-600 hover:bg-green-700">
                <i class="fas fa-plus mr-2"></i>
                <%= t('admin.add_service') %>
            </a>
            <a href="/admin/settings" 
               class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-gray-600 hover:bg-gray-700">
                <i class="fas fa-cogs mr-2"></i>
                <%= t('admin.site_settings') %>
            </a>
        </div>
    </div>
</div>