<!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.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <style>
        body { background-color: #f8f9fa; }
        .navbar { margin-bottom: 2rem; }
        .tree ul { padding-top: 20px; position: relative; transition: all 0.5s; }
        .tree li { float: left; text-align: center; list-style-type: none; position: relative; padding: 20px 5px 0 5px; transition: all 0.5s; }
        .tree li::before, .tree li::after { content: ''; position: absolute; top: 0; right: 50%; border-top: 1px solid #ccc; width: 50%; height: 20px; }
        .tree li::after { right: auto; left: 50%; border-left: 1px solid #ccc; }
        .tree li:only-child::after, .tree li:only-child::before { display: none; }
        .tree li:only-child { padding-top: 0; }
        .tree li:first-child::before, .tree li:last-child::after { border: 0 none; }
        .tree li:last-child::before { border-right: 1px solid #ccc; border-radius: 0 5px 0 0; }
        .tree li:first-child::after { border-radius: 5px 0 0 0; }
        .tree ul ul::before { content: ''; position: absolute; top: 0; left: 50%; border-left: 1px solid #ccc; width: 0; height: 20px; }
        .tree li div { border: 1px solid #ccc; padding: 5px 10px; text-decoration: none; color: #666; font-family: arial, verdana, tahoma; font-size: 11px; display: inline-block; border-radius: 5px; transition: all 0.5s; background: #fff; }
        .tree li div:hover { background: #c8e4f8; color: #000; border: 1px solid #94a0b4; }
        .split-container { display: flex; height: calc(100vh - 150px); }
        .form-panel { flex: 1; padding: 20px; overflow-y: auto; border-right: 1px solid #dee2e6; background: #fff; }
        .image-panel { flex: 1; padding: 20px; background: #e9ecef; overflow-y: auto; position: relative; }
        .image-viewer { text-align: center; }
        .image-viewer img { max-width: 100%; height: auto; border: 1px solid #ccc; }
        .page-nav { margin-bottom: 10px; display: flex; gap: 10px; }
    </style>
</head>
<body>
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
        <div class="container">
            <a class="navbar-brand" href="{{ url_for('index') }}">家谱管理系统</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" href="{{ url_for('index') }}">首页</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="{{ url_for('members') }}">成员管理</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="{{ url_for('tree') }}">关系树</a>
                    </li>
                </ul>
                <div class="navbar-nav">
                    {% if session.get('user_id') %}
                        <span class="nav-item nav-link text-white">您好, {{ session['username'] }}</span>
                        <a class="nav-item nav-link" href="{{ url_for('logout') }}">退出</a>
                    {% else %}
                        <a class="nav-item nav-link" href="{{ url_for('login') }}">登录</a>
                    {% endif %}
                </div>
            </div>
        </div>
    </nav>

    <div class="container-fluid">
        {% with messages = get_flashed_messages() %}
          {% if messages %}
            {% for message in messages %}
              <div class="alert alert-info alert-dismissible fade show" role="alert">
                {{ message }}
                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
              </div>
            {% endfor %}
          {% endif %}
        {% endwith %}

        {% block content %}{% endblock %}
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
