<!DOCTYPE html>
<html lang="{{ session.get('language', 'zh') }}">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}高可用学习平台{% endblock %}</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">

    <style>
        :root {
            --primary-color: #4a89dc;
            --primary-hover: #3b78c4;
            --secondary-color: #5cb85c;
            --text-color: #333;
            --light-text: #666;
            --bg-color: #f5f7fa;
            --card-bg: #ffffff;
            --border-color: #ddd;
            --error-color: #e74c3c;
            --success-color: #2ecc71;
        }

        body.theme-dark {
            --primary-color: #5a9aed;
            --primary-hover: #4a89dc;
            --secondary-color: #6bc76b;
            --text-color: #f1f1f1;
            --light-text: #aaa;
            --bg-color: #1a1a1a;
            --card-bg: #2c2c2c;
            --border-color: #444;
        }
    </style>

    <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">

    {% if session.get('theme', 'light') == 'dark' %}
    <link rel="stylesheet" href="{{ url_for('static', filename='css/dark.css') }}" id="theme-css">
    {% else %}
    <link rel="stylesheet" href="{{ url_for('static', filename='css/light.css') }}" id="theme-css">
    {% endif %}

    {% block extra_css %}{% endblock %}
</head>
<body class="theme-{{ session.get('theme', 'light') }}">
    {% block full_content %}
    <div class="container">
        {% if not hide_language_switch|default(false) %}
        <div class="language-switch">
            <a href="{{ url_for('main.set_language', lang='zh', next=request.path) }}">中文</a> |
            <a href="{{ url_for('main.set_language', lang='en', next=request.path) }}">English</a>
        </div>
        {% endif %}

        {% if not hide_theme_switch|default(false) %}
        <div class="theme-switch">
            {% if session.get('theme', 'light') == 'light' %}
            <a href="{{ url_for('main.set_theme', theme='dark', next=request.path) }}">暗色模式</a>
            {% else %}
            <a href="{{ url_for('main.set_theme', theme='light', next=request.path) }}">亮色模式</a>
            {% endif %}
        </div>
        {% endif %}

        {% with messages = get_flashed_messages() %}
        {% if messages %}
        <div class="flashes">
            {% for message in messages %}
            <div class="alert alert-info">{{ message }}</div>
            {% endfor %}
        </div>
        {% endif %}
        {% endwith %}

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

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <script src="{{ url_for('static', filename='js/main.js') }}"></script>
    {% block extra_js %}{% endblock %}
</body>
</html>