<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <title>{% block title %}AutoMusic 管理面板{% endblock %}</title>
    <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}?v=2">
    <!-- Optional: Add Phosphor icons for modern look -->
    <script src="https://unpkg.com/@phosphor-icons/web"></script>
    <style>
        /* Ambient background orbs for true glassmorphism effect */
        .ambient-bg { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: -1; overflow: hidden; pointer-events: none; background: #f5f7fa; }
        .ambient-orb { position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.6; animation: float 20s infinite ease-in-out alternate; }
        .orb-1 { width: 500px; height: 500px; background: rgba(79, 70, 229, 0.3); top: -10%; left: 40%; animation-delay: 0s; }
        .orb-2 { width: 400px; height: 400px; background: rgba(124, 58, 237, 0.2); bottom: 10%; right: -5%; animation-delay: -5s; }
        .orb-3 { width: 300px; height: 300px; background: rgba(56, 189, 248, 0.3); top: 30%; left: -10%; animation-delay: -10s; }
        @keyframes float { 0% { transform: translate(0, 0) scale(1); } 100% { transform: translate(50px, 50px) scale(1.1); } }
    </style>
</head>
<body>
    <div class="ambient-bg">
        <div class="ambient-orb orb-1"></div>
        <div class="ambient-orb orb-2"></div>
        <div class="ambient-orb orb-3"></div>
    </div>
    <div class="layout">
        <nav class="sidebar">
            <div class="sidebar-header">
                <h2>AutoMusic</h2>
                <span class="subtitle">Studio Manager</span>
            </div>
            <ul class="nav-list">
                <li><a href="{{ url_for('dashboard.index') }}" class="{% if request.endpoint == 'dashboard.index' %}active{% endif %}"><i class="ph ph-chart-pie nav-icon"></i>仪表盘</a></li>
                <li><a href="{{ url_for('accounts.index') }}" class="{% if request.blueprint == 'accounts' %}active{% endif %}"><i class="ph ph-users nav-icon"></i>账号管理</a></li>
                <li><a href="{{ url_for('lyrics.index') }}" class="{% if request.blueprint == 'lyrics' %}active{% endif %}"><i class="ph ph-music-note nav-icon"></i>汽水任务</a></li>
                <li>
                    <a href="{{ url_for('suno.index') }}" class="{% if request.blueprint == 'suno' %}active{% endif %}">
                        <i class="ph ph-waveform nav-icon"></i>Suno 任务
                        {% if not is_authorized %}<i class="ph ph-lock" style="font-size: 11px; margin-left: auto; color: var(--text-muted);"></i>{% endif %}
                    </a>
                </li>
                <li>
                    <a href="{{ url_for('scheduler.index') }}" class="{% if request.blueprint == 'scheduler' %}active{% endif %}">
                        <i class="ph ph-clock nav-icon"></i>定时任务
                        {% if not is_authorized %}<i class="ph ph-lock" style="font-size: 11px; margin-left: auto; color: var(--text-muted);"></i>{% endif %}
                    </a>
                </li>
                <li><a href="{{ url_for('publish.index') }}" class="{% if request.blueprint == 'publish' %}active{% endif %}"><i class="ph ph-paper-plane-tilt nav-icon"></i>发行管理</a></li>
                {% if feature_comments_enabled %}
                <li><a href="{{ url_for('comments.tracks_index') }}" class="{% if request.blueprint == 'comments' %}active{% endif %}"><i class="ph ph-chat-circle nav-icon"></i>歌曲评论</a></li>
                {% endif %}
                {% if feature_env_setup_enabled %}
                <li><a href="{{ url_for('env_setup.index') }}" class="{% if request.blueprint == 'env_setup' %}active{% endif %}"><i class="ph ph-wrench nav-icon"></i>环境管理</a></li>
                {% endif %}
                <li><a href="{{ url_for('license.index') }}" class="{% if request.blueprint == 'license' %}active{% endif %}"><i class="ph ph-shield-check nav-icon"></i>授权管理</a></li>
                {% if feature_logs_enabled %}
                <li><a href="{{ url_for('logs.index') }}" class="{% if request.blueprint == 'logs' %}active{% endif %}"><i class="ph ph-file-text nav-icon"></i>日志</a></li>
                {% endif %}
            </ul>
            <div class="sidebar-footer">
                <div>AutoMusic v2.0</div>
                <div style="font-size: 10px; color: var(--text-muted); margin-top: 4px; display: flex; align-items: center; gap: 4px;">
                    <i class="ph ph-shield-check"></i> 授权到期: {{ license_expiration }}
                </div>
                {% if is_dev_mode %}
                <div style="margin-top: 6px;">
                    <a href="{{ url_for('admin.index') }}" style="color: var(--text-muted); text-decoration: underline;">管理后台</a>
                </div>
                {% endif %}
                <div style="margin-top: 12px; border-top: 1px solid rgba(0,0,0,0.08); padding-top: 8px;">
                    <a href="{{ url_for('dashboard.shutdown') }}" onclick="return confirm('确定要关闭 AutoMusic 后台服务吗？\n关闭后所有正在运行的同步与生成任务都将被中断。')" style="display: flex; align-items: center; gap: 6px; color: #ff4d4f; font-weight: bold; font-size: 12px; text-decoration: none; transition: color 0.2s;">
                        <i class="ph ph-power" style="font-size: 14px;"></i> 关闭系统 / 退出软件
                    </a>
                </div>
            </div>
        </nav>
        <main class="content">
            {% if is_dev_mode %}
            <div class="auth-warning" style="background: #e2e3e5; color: #383d41; padding: 12px; margin-bottom: 20px; border-radius: 4px; border: 1px solid #d6d8db;">
                <span style="font-weight: bold; margin-right: 5px;">🔧 开发者模式：</span>
                当前正运行在开发模式 (WEB_DEBUG=1)，授权校验已自动绕过，所有核心功能均可直接使用。
            </div>
            {% elif not is_authorized %}
            <div class="auth-warning" style="background: #fff3cd; color: #856404; padding: 12px; margin-bottom: 20px; border-radius: 4px; border: 1px solid #ffeeba;">
                <span style="font-weight: bold; margin-right: 5px;">⚠️ 核心未授权：</span>
                当前软件未激活，核心功能（发布作品、查询数据等）已被拦截阻断，仅作为配置外壳运行。
                请前往 <a href="{{ url_for('license.index') }}" style="color: #0056b3; text-decoration: underline;">授权管理</a> 填写并验证授权信息。
            </div>
            {% endif %}
            {% with messages = get_flashed_messages(with_categories=true) %}
            {% if messages %}
            <div class="flash-messages">
                {% for category, message in messages %}
                <div class="flash flash-{{ category }}">{{ message }}</div>
                {% endfor %}
            </div>
            {% endif %}
            {% endwith %}
            {% block content %}{% endblock %}
        </main>
    </div>
    <script src="{{ url_for('static', filename='js/app.js') }}"></script>
    {% block scripts %}{% endblock %}
</body>
</html>
