<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}墨水屏管理系统{% endblock %}</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
    <link rel="stylesheet" href="/static/admin/css/admin-enhanced.css">
</head>
<body>
    <nav class="navbar navbar-expand-lg navbar-dark bg-primary">
        <div class="container-fluid">
            <a class="navbar-brand d-flex align-items-center" href="/admin">
                <i class="fas fa-desktop me-2"></i>
                墨水屏管理系统
            </a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav me-auto">
                    <li class="nav-item">
                        <a class="nav-link {% if request.url.path == '/admin' %}active{% endif %}" href="/admin">
                            <i class="fas fa-tachometer-alt me-1"></i>仪表盘
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link {% if '/admin/devices' in request.url.path %}active{% endif %}" href="/admin/devices">
                            <i class="fas fa-mobile-alt me-1"></i>设备管理
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link {% if '/admin/contents' in request.url.path %}active{% endif %}" href="/admin/contents">
                            <i class="fas fa-file-image me-1"></i>内容管理
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link {% if '/admin/todos' in request.url.path %}active{% endif %}" href="/admin/todos">
                            <i class="fas fa-tasks me-1"></i>待办事项
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link {% if '/admin/upload' in request.url.path %}active{% endif %}" href="/admin/upload">
                            <i class="fas fa-upload me-1"></i>图片上传
                        </a>
                    </li>
                </ul>
                <div class="d-flex">
                    <button class="btn btn-outline-light me-2" id="themeToggle" title="切换主题">
                        <i class="fas fa-palette"></i>
                    </button>
                    <div class="dropdown">
                        <button class="btn btn-outline-light dropdown-toggle" type="button" id="userDropdown" data-bs-toggle="dropdown" aria-expanded="false">
                            <i class="fas fa-user-circle me-1"></i>
                            {% if request.session.get('username') %}
                                {{ request.session.get('username') }}
                            {% else %}
                                管理员
                            {% endif %}
                        </button>
                        <ul class="dropdown-menu dropdown-menu-end" aria-labelledby="userDropdown">
                            <li><a class="dropdown-item" href="/admin/logout">
                                <i class="fas fa-sign-out-alt me-1"></i>登出
                            </a></li>
                        </ul>
                    </div>
                    <span class="navbar-text text-light ms-2">
                        <i class="far fa-clock me-1"></i>
                        <span id="currentTime"></span>
                    </span>
                </div>
            </div>
        </div>
    </nav>

    <div class="container-fluid mt-4">
        <div class="row">
            <div class="col-12">
                {% block content %}{% endblock %}
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <script src="/static/admin/js/admin-enhanced.js"></script>
    {% block scripts %}{% endblock %}
    
    <script>
        // 更新当前时间
        function updateTime() {
            const now = new Date();
            document.getElementById('currentTime').textContent = now.toLocaleTimeString('zh-CN');
        }
        updateTime();
        setInterval(updateTime, 1000);
    </script>
</body>
</html>