<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}紫金·稷下薪火·云枢智海师生成果共创系统{% endblock %}</title>
    <style>
        :root {
            --primary: #4361ee;
            --primary-light: #4895ef;
            --secondary: #3f37c9;
            --accent: #f72585;
            --light: #f8f9fa;
            --dark: #212529;
            --success: #4cc9f0;
            --warning: #fcaa18;
            --radius: 8px;
            --shadow: 0 4px 12px rgba(0,0,0,0.1);
            --transition: all 0.3s ease;
        }

        body {
            font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f5f7fb;
            color: #333;
            line-height: 1.6;
        }

        .header {
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            color: white;
            padding: 15px 20px;
            box-shadow: var(--shadow);
            position: relative;
            overflow: hidden;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .header:before {
            content: "";
            position: absolute;
            top: -50%;
            left: -50%;
            width: 200%;
            height: 200%;
            background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 60%);
            pointer-events: none;
        }

        .header h1 {
            margin: 0;
            display: flex;
            align-items: center;
            font-size: 24px;
            position: relative;
            z-index: 1;
        }

        .header h1 span {
            color: #ffcc00;
            text-shadow: 0 0 5px rgba(0,0,0,0.2);
        }

        .user-info {
            position: relative;
            z-index: 1;
            display: flex;
            align-items: center;
            gap: 15px;
        }

        .user-info .username {
            font-size: 14px;
            opacity: 0.9;
        }

        .user-info .permission-badge {
            background: rgba(255, 255, 255, 0.2);
            padding: 4px 8px;
            border-radius: 12px;
            font-size: 12px;
            font-weight: 500;
        }

        .user-info .permission-badge.admin {
            background: var(--accent);
        }

        .user-info .permission-badge.user {
            background: var(--success);
        }

        .logout-btn {
            background: rgba(255, 255, 255, 0.2);
            border: 1px solid rgba(255, 255, 255, 0.3);
            color: white;
            padding: 6px 12px;
            border-radius: 4px;
            text-decoration: none;
            font-size: 12px;
            transition: var(--transition);
        }

        .logout-btn:hover {
            background: rgba(255, 255, 255, 0.3);
            color: white;
        }

        .sidebar {
            width: 240px;
            height: calc(100vh - 60px);
            float: left;
            background: linear-gradient(to bottom, #ffffff, #f5f7fb);
            padding: 20px 0;
            box-shadow: 2px 0 10px rgba(0,0,0,0.05);
            transition: var(--transition);
        }

        .sidebar a {
            display: flex;
            align-items: center;
            padding: 15px 25px;
            text-decoration: none;
            color: var(--dark);
            font-size: 16px;
            transition: var(--transition);
            border-left: 3px solid transparent;
        }

        .sidebar a:hover {
            background-color: rgba(67, 97, 238, 0.08);
            border-left-color: var(--primary);
        }

        .sidebar a.active {
            background-color: rgba(67, 97, 238, 0.15);
            border-left-color: var(--primary);
            font-weight: 500;
        }

        .sidebar a i {
            margin-right: 12px;
            font-size: 18px;
        }

        .content {
            margin-left: 240px;
            padding: 30px;
            background-color: white;
            min-height: calc(100vh - 60px);
            box-shadow: -2px 0 10px rgba(0,0,0,0.05);
        }

        .card {
            background: white;
            border-radius: var(--radius);
            box-shadow: var(--shadow);
            padding: 25px;
            margin-bottom: 20px;
        }

        @media (max-width: 768px) {
            .sidebar {
                width: 100%;
                height: auto;
                position: fixed;
                bottom: 0;
                left: 0;
                display: flex;
                justify-content: space-around;
                padding: 10px 0;
                z-index: 100;
            }

            .sidebar a {
                padding: 12px 15px;
                border-left: none;
                text-align: center;
                font-size: 14px;
            }

            .sidebar a i {
                display: block;
                margin-right: 0;
                margin-bottom: 5px;
            }

            .content {
                margin-left: 0;
                padding: 20px 15px;
                min-height: calc(100vh - 110px);
            }
        }
    </style>
</head>
<body>
    <div class="header">
        <h1><span>紫金</span> 稷下薪火·云枢智海师生成果共创系统</h1>
        <div class="user-info">
            <span class="username">{{ session.username }}</span>
            {% if session.permission == 0 %}
                <span class="permission-badge admin">管理员</span>
            {% elif session.permission == 1 %}
                <span class="permission-badge user">普通用户</span>
            {% endif %}
            <a href="{{ url_for('logout') }}" class="logout-btn">登出</a>
        </div>
    </div>

    <div class="sidebar">
        <a href="{{ url_for('index') }}" {% if request.endpoint == 'index' %}class="active"{% endif %}>
            <i>📊</i> 录入成果
        </a>
        <a href="{{ url_for('results_page') }}" {% if request.endpoint == 'results_page' %}class="active"{% endif %}>
            <i>📈</i> 查询统计
        </a>
        <a href="{{ url_for('my_data') }}" {% if request.endpoint == 'my_data' or request.endpoint == 'edit_entry' %}class="active"{% endif %}>
            <i>📋</i> 我的数据
        </a>
        {% if session.permission == 0 %}
        <a href="{{ url_for('show_all') }}" {% if request.endpoint == 'show_all' %}class="active"{% endif %}>
            <i>📁</i> 数据操作
        </a>
        {% endif %}
        <a href="{{ url_for('profile') }}" {% if request.endpoint == 'profile' %}class="active"{% endif %}>
            <i>⚙️</i> 个人设置
        </a>
        {% if session.permission == 0 %}
        <a href="{{ url_for('user_management') }}" {% if request.endpoint == 'user_management' or request.endpoint == 'register' %}class="active"{% endif %}>
            <i>👥</i> 用户管理
        </a>
        {% endif %}
    </div>

    <div class="content">
        <!-- Flash消息显示 -->
        {% with messages = get_flashed_messages(with_categories=true) %}
            {% if messages %}
                <div class="flash-messages" style="margin-bottom: 20px;">
                    {% for category, message in messages %}
                        <div class="flash-message {{ category }}" style="padding: 10px; border-radius: 5px; margin-bottom: 10px;">{{ message }}</div>
                    {% endfor %}
                </div>
                <style>
                    .flash-message.error {
                        background-color: #f8d7da;
                        color: #721c24;
                        border: 1px solid #f5c6cb;
                    }
                    .flash-message.success {
                        background-color: #d4edda;
                        color: #155724;
                        border: 1px solid #c3e6cb;
                    }
                    .flash-message.info {
                        background-color: #d1ecf1;
                        color: #0c5460;
                        border: 1px solid #bee5eb;
                    }
                </style>
            {% endif %}
        {% endwith %}
        
        {% block content %}
        {% endblock %}
    </div>

    <!-- 添加字体图标库 -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
</body>
</html>