<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>@yield('title', 'SaaSShop 总台管理')</title>
    @php
        // 资产缓存护栏：避免浏览器缓存导致“样式已修复但页面仍旧错位”的体感。
        // 说明：使用 filemtime 作为版本号，不引入构建链；文件更新即自动换 query。
        $cssVerTheme = @filemtime(public_path('css/admin-theme.css')) ?: time();
        $cssVerBase = @filemtime(public_path('css/admin-base.css')) ?: time();
        $cssVerComponents = @filemtime(public_path('css/admin-components.css')) ?: time();
    @endphp
    <link rel="stylesheet" href="/css/admin-theme.css?v={{ $cssVerTheme }}">
    <link rel="stylesheet" href="/css/admin-base.css?v={{ $cssVerBase }}">
    <link rel="stylesheet" href="/css/admin-components.css?v={{ $cssVerComponents }}">
</head>
<body>
<div class="layout layout-topnav">
    <aside class="sidebar topnav">
        <div class="topnav-row">
            <a class="topnav-brand" href="/admin">SaaSShop</a>

            <nav class="topnav-menu" aria-label="总台主导航" data-role="topnav-groups-root">
                <a class="topnav-link" href="/admin">仪表盘</a>

                <details class="topnav-item nav-group" data-role="topnav-group">
                    <summary class="topnav-summary">收费中心</summary>
                    <div class="topnav-dropdown">
                        <a href="/admin/platform-orders" class="topnav-sub nav-item nav-item--sub">平台订单</a>
                        <a href="/admin/site-subscriptions" class="topnav-sub nav-item nav-item--sub">订阅</a>
                        <a href="/admin/plans" class="topnav-sub nav-item nav-item--sub">套餐</a>
                    </div>
                </details>

                <details class="topnav-item nav-group" data-role="topnav-group">
                    <summary class="topnav-summary">站点治理</summary>
                    <div class="topnav-dropdown">
                        <a href="/admin/merchants" class="topnav-sub nav-item nav-item--sub">站点管理</a>
                        <a href="/admin/orders" class="topnav-sub nav-item nav-item--sub">订单监控</a>
                        <a href="/admin/products" class="topnav-sub nav-item nav-item--sub">商品巡检</a>
                        <a href="/admin/product-categories" class="topnav-sub nav-item nav-item--sub">商品分类</a>
                    </div>
                </details>

                <details class="topnav-item nav-group" data-role="topnav-group">
                    <summary class="topnav-summary">增长转化</summary>
                    <div class="topnav-dropdown">
                        <a href="/admin/platform-leads" class="topnav-sub nav-item nav-item--sub">开通线索</a>
                    </div>
                </details>

                <details class="topnav-item nav-group" data-role="topnav-group">
                    <summary class="topnav-summary">客服中心</summary>
                    <div class="topnav-dropdown">
                        <a href="/admin/support-tickets" class="topnav-sub nav-item nav-item--sub">工单</a>
                    </div>
                </details>

                <details class="topnav-item nav-group" data-role="topnav-group">
                    <summary class="topnav-summary">系统</summary>
                    <div class="topnav-dropdown">
                        <a href="/admin/settings/system" class="topnav-sub nav-item nav-item--sub">系统配置</a>
                    </div>
                </details>
            </nav>

            <div class="topnav-actions">
                <form method="post" action="/admin/logout" class="logout-form topnav-logout">@csrf <button type="submit" class="btn btn-secondary btn-sm">退出登录</button></form>
            </div>
        </div>


    </aside>
    <main class="content">
        <div class="toast-container" data-role="toast-container" aria-live="polite" aria-relevant="additions" aria-atomic="true"></div>

        {{-- 页面标题已统一收敛到各页面的 PageHeader 组件，避免重复出现“大标题”。 --}}
        @if(session('success'))
            <div class="flash" data-flash="success">
                <span>{{ session('success') }}</span>
                @if(session('success_link_href'))
                    @php
                        $flashLinkHref = \App\Support\BackUrl::sanitizeForLinks((string) session('success_link_href'));
                        $flashLinkLabel = (string) (session('success_link_label') ?: '查看');
                    @endphp
                    @if($flashLinkHref !== '')
                        <a href="{{ $flashLinkHref }}" class="btn btn-secondary btn-sm" style="margin-left:8px;">{{ $flashLinkLabel }}</a>
                    @endif
                @endif
            </div>
        @endif
        @if(session('warning'))
            <div class="warning" data-flash="warning">
                <span>{{ session('warning') }}</span>
                @if(session('warning_link_href'))
                    @php
                        $flashWarningLinkHref = \App\Support\BackUrl::sanitizeForLinks((string) session('warning_link_href'));
                        $flashWarningLinkLabel = (string) (session('warning_link_label') ?: '查看');
                        $flashWarningCopyText = (string) (session('warning_copy_text') ?: '');
                        $flashWarningCopyLabel = (string) (session('warning_copy_label') ?: '复制');
                    @endphp
                    @if($flashWarningLinkHref !== '')
                        <a href="{{ $flashWarningLinkHref }}" class="btn btn-secondary btn-sm" style="margin-left:8px;">{{ $flashWarningLinkLabel }}</a>
                    @endif
                    @if($flashWarningCopyText !== '')
                        <button type="button" class="btn btn-secondary btn-sm" style="margin-left:8px;" data-action="copy-text" data-copy-text="{{ $flashWarningCopyText }}" data-copy-label="{{ $flashWarningCopyLabel }}">{{ $flashWarningCopyLabel }}</button>
                    @endif
                @endif
            </div>
        @endif
        @if(session('error'))
            <div class="error-box" data-flash="error">{{ session('error') }}</div>
        @endif
        @if($errors->any())
            <div class="error-box">
                <strong>提交失败：</strong>
                <ul class="list-indent">
                    @foreach($errors->all() as $error)
                        <li>{{ $error }}</li>
                    @endforeach
                </ul>
            </div>
        @endif
        @yield('content')
    </main>
</div>
    <script src="/js/admin.js" defer></script>
    <script data-action="topnav-single-open">
        (function(){
            var root = document.querySelector('[data-role="topnav-groups-root"]');
            if(!root){return;}

            var groups = root.querySelectorAll('details[data-role="topnav-group"]');
            if(!groups || groups.length === 0){return;}

            groups.forEach(function(d){
                d.addEventListener('toggle', function(){
                    if(!d.open){return;}
                    groups.forEach(function(other){
                        if(other !== d){
                            other.open = false;
                        }
                    });
                });
            });
        })();
    </script>
</body>
</html>
