<!DOCTYPE html>
<html lang="ru">
<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.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.0/font/bootstrap-icons.css" rel="stylesheet">
    <style>
        :root {
            --primary-color: #2c3e50;
            --secondary-color: #3498db;
            --success-color: #27ae60;
            --warning-color: #f39c12;
            --danger-color: #e74c3c;
        }

        body {
            background-color: #f8f9fa;
        }

        .sidebar {
            min-height: 100vh;
            background: linear-gradient(180deg, var(--primary-color) 0%, #1a252f 100%);
            position: sticky;
            top: 0;
        }

        .sidebar .nav-link {
            color: rgba(255,255,255,0.8);
            padding: 0.8rem 1rem;
            transition: all 0.3s;
            border-left: 3px solid transparent;
        }

        .sidebar .nav-link:hover {
            color: white;
            background-color: rgba(255,255,255,0.1);
            border-left-color: var(--secondary-color);
        }

        .sidebar .nav-link.active {
            color: white;
            background-color: rgba(255,255,255,0.15);
            border-left-color: var(--secondary-color);
            font-weight: 500;
        }

        .sidebar .nav-link i {
            margin-right: 0.5rem;
            width: 20px;
            text-align: center;
        }

        .sidebar .nav-link .badge {
            float: right;
            margin-top: 2px;
        }

        .content {
            padding: 2rem;
        }

        {% block extra_style %}{% endblock %}
    </style>
</head>
<body>
    <div class="container-fluid">
        <div class="row">
            <!-- Sidebar - ЕДИНОЕ МЕНЮ ДЛЯ ВСЕХ СТРАНИЦ -->
            <div class="col-md-2 sidebar p-0">
                <div class="p-3 text-white text-center border-bottom border-secondary">
                    <h4 class="mb-1"><i class="bi bi-house-door"></i> Домовой</h4>
                    <small class="text-white-50">Админ Панель v3.1</small>
                </div>
                <nav class="nav flex-column mt-3">
                    <!-- ОСНОВНОЕ -->
                    <a class="nav-link {% block nav_dashboard %}{% endblock %}" href="/">
                        <i class="bi bi-speedometer2"></i> Дашборд
                    </a>

                    <!-- ПОЛЬЗОВАТЕЛИ -->
                    <div class="nav-item mt-3 px-3">
                        <small class="text-white-50 text-uppercase" style="font-size: 0.7em; letter-spacing: 1px;">ПОЛЬЗОВАТЕЛИ</small>
                    </div>
                    <a class="nav-link {% block nav_users %}{% endblock %}" href="/users">
                        <i class="bi bi-people"></i> Все жильцы
                    </a>
                    <a class="nav-link {% block nav_verification %}{% endblock %}" href="/verification">
                        <i class="bi bi-shield-check"></i> Верификация
                        {% if pending_count and pending_count > 0 %}
                        <span class="badge bg-danger">{{ pending_count }}</span>
                        {% endif %}
                    </a>
                    <a class="nav-link {% block nav_phones %}{% endblock %}" href="/phones">
                        <i class="bi bi-telephone"></i> Телефоны
                    </a>

                    <!-- КОММУНИКАЦИИ -->
                    <div class="nav-item mt-3 px-3">
                        <small class="text-white-50 text-uppercase" style="font-size: 0.7em; letter-spacing: 1px;">КОММУНИКАЦИИ</small>
                    </div>
                    <a class="nav-link {% block nav_broadcast %}{% endblock %}" href="/broadcast">
                        <i class="bi bi-broadcast"></i> Рассылки
                    </a>
                    <a class="nav-link {% block nav_scheduled_posts %}{% endblock %}" href="/scheduled_posts">
                        <i class="bi bi-calendar2-plus"></i> Запланированные посты
                    </a>
                    <a class="nav-link {% block nav_digests %}{% endblock %}" href="/digests">
                        <i class="bi bi-newspaper"></i> Еженедельные дайджесты
                    </a>
                    <a class="nav-link {% block nav_digest_settings %}{% endblock %}" href="/digest_settings">
                        <i class="bi bi-gear"></i> Настройки дайджеста
                    </a>
                    <a class="nav-link {% block nav_polls %}{% endblock %}" href="/polls">
                        <i class="bi bi-bar-chart"></i> Опросы
                    </a>
                    <a class="nav-link {% block nav_ads %}{% endblock %}" href="/ads">
                        <i class="bi bi-megaphone"></i> Объявления
                    </a>

                    <!-- КОНТЕНТ -->
                    <div class="nav-item mt-3 px-3">
                        <small class="text-white-50 text-uppercase" style="font-size: 0.7em; letter-spacing: 1px;">КОНТЕНТ</small>
                    </div>
                    <a class="nav-link {% block nav_events %}{% endblock %}" href="/events">
                        <i class="bi bi-calendar-event"></i> События
                    </a>
                    <a class="nav-link {% block nav_schedules %}{% endblock %}" href="/schedules">
                        <i class="bi bi-clock"></i> Расписания отключений
                    </a>

                    <!-- СИСТЕМА -->
                    <div class="nav-item mt-3 px-3">
                        <small class="text-white-50 text-uppercase" style="font-size: 0.7em; letter-spacing: 1px;">СИСТЕМА</small>
                    </div>
                    <a class="nav-link {% block nav_export %}{% endblock %}" href="/export">
                        <i class="bi bi-download"></i> Экспорт данных
                    </a>
                </nav>
            </div>

            <!-- Main Content -->
            <div class="col-md-10 content">
                {% block content %}{% endblock %}
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    {% block extra_script %}{% endblock %}
</body>
</html>
