<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}{{ site_title }}{% endblock %}</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-table@1.22.1/dist/bootstrap-table.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css" rel="stylesheet">
    <style>
        body {
            padding-top: 56px;  /* 为固定顶部导航栏留出空间 */
        }
        
        .wrapper {
            display: flex;
            flex-direction: column;
            min-height: 100vh;
        }
        
        .container-fluid {
            flex: 1;
            padding-top: 1rem;
        }
        
        /* 侧边栏样式 */
        .sidebar {
            position: sticky;
            top: 56px;  /* 与顶部导航栏对齐 */
            height: calc(100vh - 56px);
            padding-top: 1rem;
            overflow-x: hidden;
            overflow-y: auto;
            background-color: #343a40;
            z-index: 100;
        }
        
        .sidebar-sticky {
            position: relative;
            top: 0;
            height: calc(100vh - 48px);
            padding-top: .5rem;
            overflow-x: hidden;
            overflow-y: auto;
        }

        /* 菜单组样式 */
        .nav-group {
            margin-bottom: 0.5rem;
        }

        .nav-group-toggle {
            color: rgba(255, 255, 255, 0.8) !important;
            padding: 0.5rem 1rem;
            display: flex;
            align-items: center;
            justify-content: space-between;
            text-decoration: none;
            cursor: pointer;
            transition: all 0.3s;
        }

        .nav-group-toggle:hover {
            color: #fff !important;
            background-color: rgba(255, 255, 255, 0.1);
        }

        .nav-group-toggle::after {
            content: '\F282';
            font-family: 'bootstrap-icons';
            transition: transform 0.3s;
        }

        .nav-group-toggle[aria-expanded="true"]::after {
            transform: rotate(90deg);
        }

        /* 子菜单样式 */
        .nav-group .nav-item .nav-link {
            color: rgba(255, 255, 255, 0.6);
            padding: 0.5rem 1rem 0.5rem 2.5rem;
            font-size: 0.9rem;
            transition: all 0.3s;
        }

        .nav-group .nav-item .nav-link:hover {
            color: #fff;
            background-color: rgba(255, 255, 255, 0.1);
        }

        .nav-group .nav-item .nav-link.active {
            color: #fff;
            background-color: rgba(255, 255, 255, 0.2);
        }

        /* 图标样式 */
        .nav-link i {
            margin-right: 0.5rem;
            font-size: 1.1rem;
            width: 1.5rem;
            text-align: center;
        }

        /* 自定义滚动条 */
        .sidebar-sticky::-webkit-scrollbar {
            width: 6px;
        }

        .sidebar-sticky::-webkit-scrollbar-track {
            background: rgba(255, 255, 255, 0.1);
        }

        .sidebar-sticky::-webkit-scrollbar-thumb {
            background-color: rgba(255, 255, 255, 0.3);
            border-radius: 3px;
        }

        .sidebar-sticky::-webkit-scrollbar-thumb:hover {
            background-color: rgba(255, 255, 255, 0.4);
        }

        /* 页脚样式 */
        .footer {
            padding: 1rem 0;
            background: #f8f9fa;
            border-top: 1px solid #dee2e6;
            margin-top: auto;
        }

        /* 内容区域样式 */
        .main-content {
            padding: 1rem 0;
        }
    </style>
</head>
<body>
    <div class="wrapper">
        {% if user %}
            {% include "admin/components/header.html" %}
        {% endif %}
        
        <div class="container-fluid">
            <div class="row">
                {% if user %}
                    <div class="col-md-3 col-lg-2 px-0">
                        {% include "admin/components/sidebar.html" %}
                    </div>
                    <div class="col-md-9 col-lg-10 px-md-4 main-content">
                        {% block content %}{% endblock %}
                    </div>
                {% else %}
                    <div class="col-12 main-content">
                        {{ self.content() }}
                    </div>
                {% endif %}
            </div>
        </div>
        
        {% if copyright %}
        <footer class="footer">
            <div class="container-fluid">
                <div class="row text-muted">
                    <div class="col-12 text-center">
                        <p class="mb-0">
                            {{ copyright }}
                        </p>
                    </div>
                </div>
            </div>
        </footer>
        {% endif %}
    </div>

    <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.8/dist/umd/popper.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/jquery/dist/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap-table@1.22.1/dist/bootstrap-table.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap-table@1.22.1/dist/locale/bootstrap-table-zh-CN.min.js"></script>
    
    {% block extra_js %}
    <script>
    function setLanguage(lang) {
        $.ajax({
            url: '/admin/set_language',
            method: 'POST',
            data: { language: lang },
            success: function() {
                location.reload();
            },
            error: function() {
                alert('切换语言失败');
            }
        });
    }
    </script>
    {% endblock %}
</body>
</html> 