{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}UniChat | Secure Unified Messaging{% endblock %}</title>
    <meta name="description" content="UniChat - The secure central hub for all your messaging services.">
    
    <!-- Fonts -->
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Lexend:wght@400;600;700&display=swap" rel="stylesheet">
    
    <!-- Bootstrap 5 CSS CDN -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    
    <!-- Custom CSS -->
    <link rel="stylesheet" href="{% static 'css/custom.css' %}?v={% now 'U' %}">
    
    {% block extra_css %}{% endblock %}
</head>
<body>
    <div class="app-container">
        <!-- Sidebar -->
        <aside class="app-sidebar">
            <div class="sidebar-header">
                <h1 class="brand-name">UniChat</h1>
            </div>
            <nav class="sidebar-nav">
                <a href="{% url 'home' %}" class="nav-link {% if request.resolver_match.url_name == 'home' %}active{% endif %}">
                    <span class="icon">⊞</span> Hub
                </a>
                <a href="{% url 'integrations' %}" class="nav-link {% if request.resolver_match.url_name == 'integrations' %}active{% endif %}">
                    <span class="icon">⚙</span> Integrations
                </a>
                <div class="sidebar-divider">CONNECTED CHANNELS</div>
                {% for channel in active_channels %}
                <div class="nav-channel">
                    <span class="status-dot online"></span> {{ channel.get_name_display }}
                </div>
                {% empty %}
                <div class="nav-empty">No active channels</div>
                {% endfor %}
            </nav>
            <div class="sidebar-footer">
                <form action="{% url 'wipe_data' %}" method="post" onsubmit="return confirm('WARNING: This will wipe all data. Proceed?')">
                    {% csrf_token %}
                    <button type="submit" class="btn-wipe">DEADMAN SWITCH</button>
                </form>
            </div>
        </aside>

        <!-- Main Content -->
        <main class="app-main">
            <header class="main-header">
                <div class="container-fluid">
                    {% if messages %}
                        {% for message in messages %}
                            <div class="alert alert-{{ message.tags }} alert-dismissible fade show" role="alert">
                                {{ message }}
                                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                            </div>
                        {% endfor %}
                    {% endif %}
                </div>
            </header>
            <section class="main-content">
                {% block content %}{% endblock %}
            </section>
        </main>
    </div>

    <!-- Bootstrap 5 JS Bundle CDN -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    {% block extra_js %}{% endblock %}
</body>
</html>