<!DOCTYPE html>
<html>
<head>
<!-----------------------------------------------------------------------
- Copyright (C) 2025, iwyxdxl
- Licensed under GNU GPL-3.0 or higher, see the LICENSE file for details.
- 
- This file is part of WeChatBot.
- WeChatBot is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- 
- WeChatBot is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- GNU General Public License for more details.
- 
- You should have received a copy of the GNU General Public License
- along with WeChatBot.  If not, see <http://www.gnu.org/licenses/>.
------------------------------------------------------------------------>
    <title>Prompt管理</title>
    <style>
        body { 
            display: flex;
            flex-direction: column;
            min-height: 100vh;
            max-width: 800px; 
            margin: 20px auto; 
            padding: 20px;
            background-color: #f5f5f5;
            font-family: Arial, sans-serif;
        }
        .header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
        }
        h1 {
            margin: 0;
        }
        .btn {
            background-color: #4caf50;
            color: white;
            padding: 10px 20px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
            transition: background-color 0.3s;
            text-decoration: none;
        }
        .btn:hover {
            background-color: #45a049;
        }
        .file-list {
            list-style: none;
            padding: 0;
            flex-grow: 1;
            margin-bottom: 40px; /* 增加底部间距 */
        }
        .file-item {
            background: white;
            padding: 15px;
            margin-bottom: 10px;
            border-radius: 8px;
            box-shadow: 0 2px 5px rgba(0,0,0,0.1);
            display: flex;
            justify-content: space-between;
            align-items: center;
            transition: transform 0.2s, box-shadow 0.2s;
        }
        .file-item:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 10px rgba(0,0,0,0.15);
        }
        .actions a {
            text-decoration: none;
            color: #333;
            margin-left: 40px;
            transition: color 0.3s;
        }
        .actions a:hover {
            color: #777;
        }
        .delete-btn {
            color: #f44336;
            cursor: pointer;
            transition: color 0.3s;
        }
        .delete-btn:hover {
            color: #d32f2f;
        }
        /* 法律声明：仅切换文字使用绿色，其余部分保持与页面一致 */
        .legal-notice {
            margin-top: 40px;
            padding: 10px 20px;
            background-color: #f5f5f5; /* 与页面整体背景一致 */
            border-top: 2px solid #dee2e6;
            text-align: center;
            font-size: 0.9em;
            color: #6c757d;
            line-height: 1.6;
        }
        .legal-notice .legal-toggle {
            cursor: pointer;
            color: #4caf50; /* 切换文字设为绿色 */
            font-weight: bold;
            margin-bottom: 10px;
        }
        .legal-notice .legal-content {
            display: none;
            text-align: left;
        }
        .legal-notice .legal-content a {
            color: #4caf50;
            text-decoration: none;
        }
        .legal-notice .legal-content a:hover {
            text-decoration: underline;
        }

        .btn {
            background-color: #4caf50;
            color: white;
            padding: 10px 20px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
            transition: background-color 0.3s;
            text-decoration: none;
            width: fit-content; /* 新增关键属性 */
            align-self: flex-start; /* 防止在flex容器中被拉伸 */
        }
    </style>
</head>
<body>
    <div class="header">
        <h1>Prompt管理</h1>
        <a href="/" class="btn">返回配置</a>
    </div>
    <a href="{{ url_for('create_prompt') }}" class="btn">新建Prompt</a>
    
    <ul class="file-list">
        {% for file in files %}
        <li class="file-item">
            <span>{{ file }}</span>
            <div class="actions">
                <a href="{{ url_for('edit_prompt', filename=file) }}">编辑</a>
                <span class="delete-btn" onclick="confirmDelete('{{ file }}')">删除</span>
            </div>
        </li>
        {% endfor %}
    </ul>

    <script>
        function confirmDelete(filename) {
            if (confirm('确定要删除文件 “' + filename + '” 吗？')) {
                fetch(`/delete_prompt/${encodeURIComponent(filename)}`, { method: 'POST' })
                    .then(response => {
                        if (response.ok) location.reload();
                        else alert('删除失败');
                });
            }
        }
    </script>
    <div class="legal-notice">
        <div class="legal-toggle" id="toggleLegal">显示法律声明</div>
        <div class="legal-content" id="legalContent">
            <p>
                Modified based on the <strong>KouriChat</strong> project.<br>
                原项目版权: Copyright (C) 2025, umaru<br>
                修改版本版权: Copyright (C) 2025, iwyxdxl
            </p>
            <p>
                本软件是自由软件，您可以根据 <a href="https://www.gnu.org/licenses/gpl-3.0.zh-cn.html" target="_blank">
                GNU 通用公共许可证 第3版（或更高版本）</a> 的条款重新发布和修改本软件。
            </p>
            <p>
                本软件按“现状”提供，不提供任何明示或暗示的担保（包括适销性或特定用途适用性）。<br>
                如您未收到完整的许可证副本，请访问 <a href="https://www.gnu.org/licenses/gpl-3.0.zh-cn.html" target="_blank">
                GNU GPL 3.0 中文版</a> 获取。
            </p>
            <p>
                源代码获取：<br>
                原项目源代码：<a href="https://github.com/KouriChat/KouriChat" target="_blank">https://github.com/KouriChat/KouriChat</a><br>
                本项目源代码：<a href="https://github.com/iwyxdxl/WeChatBot_WXAUTO_SE" target="_blank">https://github.com/iwyxdxl/WeChatBot_WXAUTO_SE</a>
            </p>
            <p>
                本软件仅供学习和娱乐使用，请勿用于违法用途，否则产生的一切法律责任均与任何作者无关。
            </p>
        </div>
    </div>
    <script>
        document.getElementById('toggleLegal').addEventListener('click', function() {
            var content = document.getElementById('legalContent');
            if (content.style.display === 'none' || content.style.display === '') {
                content.style.display = 'block';
                this.textContent = '隐藏法律声明';
            } else {
                content.style.display = 'none';
                this.textContent = '显示法律声明';
            }
        });
    </script>
</body>
</html>