@extends('admin.layouts.app')

@section('title', '运维工具')

@section('content')
    <div class="bg-white rounded-xl shadow-sm border border-gray-100 overflow-hidden">
        <div class="p-6 border-b border-gray-100 bg-gray-50">
            <h2 class="text-lg font-bold text-gray-800">🛠️ 运维工具</h2>
            <p class="text-xs text-gray-500 mt-1">仅站长可见。每项操作不可撤销，请确认后执行。</p>
        </div>

        <div class="p-6">
            <div class="grid grid-cols-1 md:grid-cols-2 gap-5">

                {{-- 应用缓存清理 --}}
                <div class="border border-gray-200 rounded-xl p-5 hover:shadow-sm transition">
                    <div class="flex items-center gap-3 mb-2">
                        <span class="text-2xl">🗑️</span>
                        <div>
                            <div class="font-bold text-gray-800 text-sm">应用缓存清理</div>
                            <div class="text-xs text-gray-400">config:clear + cache:clear</div>
                        </div>
                    </div>
                    <p class="text-xs text-gray-500 mb-4 leading-relaxed">
                        清除 Laravel 配置和应用缓存。<br>
                        修改 <code class="bg-gray-100 px-1 rounded">.env</code> 后、部署新版本后建议执行。
                    </p>
                    <form action="{{ route('admin.ops.clear-cache') }}" method="POST"
                        onsubmit="return confirm('确定清理应用缓存？')">
                        @csrf
                        <button type="submit"
                            class="px-4 py-2 bg-amber-500 text-white rounded-lg text-sm font-bold hover:bg-amber-600 transition shadow-sm">
                            立即执行
                        </button>
                    </form>
                </div>

                {{-- 路由缓存清理 --}}
                <div class="border border-gray-200 rounded-xl p-5 hover:shadow-sm transition">
                    <div class="flex items-center gap-3 mb-2">
                        <span class="text-2xl">🗺️</span>
                        <div>
                            <div class="font-bold text-gray-800 text-sm">路由缓存清理</div>
                            <div class="text-xs text-gray-400">route:clear</div>
                        </div>
                    </div>
                    <p class="text-xs text-gray-500 mb-4 leading-relaxed">
                        清除路由缓存文件。<br>
                        部署后出现 404 路由错误时执行。
                    </p>
                    <form action="{{ route('admin.ops.clear-routes') }}" method="POST"
                        onsubmit="return confirm('确定清理路由缓存？')">
                        @csrf
                        <button type="submit"
                            class="px-4 py-2 bg-amber-500 text-white rounded-lg text-sm font-bold hover:bg-amber-600 transition shadow-sm">
                            立即执行
                        </button>
                    </form>
                </div>

                {{-- 视图缓存清理 --}}
                <div class="border border-gray-200 rounded-xl p-5 hover:shadow-sm transition">
                    <div class="flex items-center gap-3 mb-2">
                        <span class="text-2xl">🖼️</span>
                        <div>
                            <div class="font-bold text-gray-800 text-sm">视图缓存清理</div>
                            <div class="text-xs text-gray-400">view:clear</div>
                        </div>
                    </div>
                    <p class="text-xs text-gray-500 mb-4 leading-relaxed">
                        清除已编译的 Blade 视图缓存。<br>
                        页面样式或内容更新后未生效时执行。
                    </p>
                    <form action="{{ route('admin.ops.clear-views') }}" method="POST"
                        onsubmit="return confirm('确定清理视图缓存？')">
                        @csrf
                        <button type="submit"
                            class="px-4 py-2 bg-amber-500 text-white rounded-lg text-sm font-bold hover:bg-amber-600 transition shadow-sm">
                            立即执行
                        </button>
                    </form>
                </div>

                {{-- 房间在线名单清理 --}}
                <div class="border border-red-100 rounded-xl p-5 bg-red-50 hover:shadow-sm transition">
                    <div class="flex items-center gap-3 mb-2">
                        <span class="text-2xl">👻</span>
                        <div>
                            <div class="font-bold text-red-700 text-sm">清理幽灵在线名单</div>
                            <div class="text-xs text-red-400">Redis room:*:users</div>
                        </div>
                    </div>
                    <p class="text-xs text-red-500 mb-4 leading-relaxed">
                        清空所有房间的 Redis 在线记录，解决在线人数虚高问题。<br>
                        <strong>执行后在线用户需重新进房才能出现在名单中。</strong>
                    </p>
                    <form action="{{ route('admin.ops.clear-room-online') }}" method="POST"
                        onsubmit="return confirm('确定清理所有房间在线名单？\n在线用户需重进房间才能重新出现在名单！')">
                        @csrf
                        <button type="submit"
                            class="px-4 py-2 bg-red-500 text-white rounded-lg text-sm font-bold hover:bg-red-600 transition shadow-sm">
                            立即执行
                        </button>
                    </form>
                </div>

            </div>
        </div>
    </div>
@endsection
