From cf4285e1e0ac8e76dc02729e64beb7cb28511fa1 Mon Sep 17 00:00:00 2001
From: Roman Sergienko <romasergienko@outlook.com>
Date: Sat, 10 Oct 2026 14:32:29 +0000
Subject: [PATCH] feat web: мобильное меню-шторка и адаптивные таблицы

---
 web/templates/base.html    |   70 +++++++++++++++++++++++++----------
 web/templates/log.html     |    4 +-
 web/templates/captcha.html |    4 +-
 web/templates/chats.html   |    4 +-
 4 files changed, 56 insertions(+), 26 deletions(-)

diff --git a/web/templates/base.html b/web/templates/base.html
index 81474a4..a30081c 100644
--- a/web/templates/base.html
+++ b/web/templates/base.html
@@ -2,7 +2,7 @@
 <html lang="ru" class="dark">
 <head>
     <meta charset="utf-8">
-    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
     <title>{% block title %}Amadeus{% endblock %}</title>
     <script>
         // Применяем сохранённую тему до отрисовки, чтобы не мигало.
@@ -32,15 +32,24 @@
 </head>
 <body class="min-h-screen bg-gray-50 text-gray-900 dark:bg-gray-950 dark:text-gray-100 font-sans antialiased">
 <div class="flex min-h-screen">
-    <aside class="hidden md:flex w-64 shrink-0 flex-col border-r border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900">
-        <div class="h-16 flex items-center gap-2 px-5 border-b border-gray-200 dark:border-gray-800">
-            <span class="relative inline-flex h-8 w-8 items-center justify-center overflow-hidden rounded-lg bg-brand-600 text-white font-bold">
-                A
-                <img src="/avatar/bot" alt="" class="absolute inset-0 h-full w-full object-cover" onerror="this.remove()">
-            </span>
-            <span class="text-lg font-semibold">Amadeus</span>
+    <!-- Затемнение под мобильным меню -->
+    <div id="backdrop" class="fixed inset-0 z-30 hidden bg-black/50 md:hidden"></div>
+
+    <aside id="sidebar"
+           class="fixed inset-y-0 left-0 z-40 flex w-64 shrink-0 -translate-x-full flex-col border-r border-gray-200 bg-white transition-transform duration-200 dark:border-gray-800 dark:bg-gray-900 md:static md:translate-x-0">
+        <div class="flex h-16 items-center justify-between gap-2 border-b border-gray-200 px-5 dark:border-gray-800">
+            <div class="flex items-center gap-2">
+                <span class="relative inline-flex h-8 w-8 items-center justify-center overflow-hidden rounded-lg bg-brand-600 font-bold text-white">
+                    A
+                    <img src="/avatar/bot" alt="" class="absolute inset-0 h-full w-full object-cover" onerror="this.remove()">
+                </span>
+                <span class="text-lg font-semibold">Amadeus</span>
+            </div>
+            <button id="sidebar-close" class="rounded-lg p-1.5 text-gray-500 hover:bg-gray-100 dark:hover:bg-gray-800 md:hidden" aria-label="Закрыть меню">
+                <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M6 6l12 12M18 6L6 18"/></svg>
+            </button>
         </div>
-        <nav class="flex-1 p-3 space-y-1 text-sm">
+        <nav class="flex-1 space-y-1 overflow-y-auto p-3 text-sm">
             {% set items = [
                 ("dash", "/", "Дашборд"),
                 ("chats", "/chats", "Чаты"),
@@ -49,19 +58,19 @@
                 ("log", "/log", "Журнал")
             ] %}
             {% for key, href, label in items %}
-            <a href="{{ href }}"
-               class="flex items-center rounded-lg px-3 py-2 transition
+            <a href="{{ href }}" onclick="closeSidebar()"
+               class="flex items-center rounded-lg px-3 py-2.5 transition
                {% if active == key %}bg-brand-600 text-white shadow{% else %}text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-800{% endif %}">
                 {{ label }}
             </a>
             {% endfor %}
         </nav>
-        <div class="p-3 border-t border-gray-200 dark:border-gray-800">
+        <div class="border-t border-gray-200 p-3 dark:border-gray-800">
             <div class="flex items-center gap-3">
                 {% if user and user.photo_url %}
                 <img src="{{ user.photo_url }}" class="h-9 w-9 rounded-full object-cover" alt="">
                 {% else %}
-                <span class="inline-flex h-9 w-9 items-center justify-center rounded-full bg-gray-200 dark:bg-gray-700 text-sm font-medium">
+                <span class="inline-flex h-9 w-9 items-center justify-center rounded-full bg-gray-200 text-sm font-medium dark:bg-gray-700">
                     {{ (user.first_name or "?")[:1] }}
                 </span>
                 {% endif %}
@@ -70,19 +79,24 @@
                     <div class="truncate text-xs text-gray-500">{% if user.username %}@{{ user.username }}{% else %}id {{ user.user_id }}{% endif %}</div>
                 </div>
             </div>
-            <a href="/logout" class="mt-3 block text-center rounded-lg border border-gray-200 dark:border-gray-700 px-3 py-1.5 text-sm hover:bg-gray-100 dark:hover:bg-gray-800">Выйти</a>
+            <a href="/logout" class="mt-3 block rounded-lg border border-gray-200 px-3 py-1.5 text-center text-sm hover:bg-gray-100 dark:border-gray-700 dark:hover:bg-gray-800">Выйти</a>
         </div>
     </aside>
 
-    <div class="flex-1 flex flex-col min-w-0">
-        <header class="h-16 flex items-center justify-between gap-4 px-6 border-b border-gray-200 dark:border-gray-800 bg-white/70 dark:bg-gray-900/70 backdrop-blur">
-            <h1 class="text-lg font-semibold truncate">{% block header %}{% endblock %}</h1>
+    <div class="flex min-w-0 flex-1 flex-col">
+        <header class="sticky top-0 z-20 flex h-16 items-center justify-between gap-3 border-b border-gray-200 bg-white/80 px-4 backdrop-blur dark:border-gray-800 dark:bg-gray-900/80 md:px-6">
+            <div class="flex min-w-0 items-center gap-3">
+                <button id="sidebar-open" class="rounded-lg border border-gray-200 p-2 text-gray-600 hover:bg-gray-100 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800 md:hidden" aria-label="Открыть меню">
+                    <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M4 6h16M4 12h16M4 18h16"/></svg>
+                </button>
+                <h1 class="truncate text-lg font-semibold">{% block header %}{% endblock %}</h1>
+            </div>
             <div class="flex items-center gap-2">
-                <button id="theme-toggle" class="rounded-lg border border-gray-200 dark:border-gray-700 px-3 py-1.5 text-sm hover:bg-gray-100 dark:hover:bg-gray-800">Тема</button>
-                <a href="/logout" class="md:hidden rounded-lg border border-gray-200 dark:border-gray-700 px-3 py-1.5 text-sm">Выйти</a>
+                <button id="theme-toggle" class="rounded-lg border border-gray-200 px-3 py-1.5 text-sm hover:bg-gray-100 dark:border-gray-700 dark:hover:bg-gray-800">Тема</button>
+                <a href="/logout" class="rounded-lg border border-gray-200 px-3 py-1.5 text-sm hover:bg-gray-100 dark:border-gray-700 dark:hover:bg-gray-800 md:hidden">Выйти</a>
             </div>
         </header>
-        <main class="p-6 space-y-6">
+        <main class="space-y-6 p-4 md:p-6">
             {% block content %}{% endblock %}
         </main>
     </div>
@@ -95,6 +109,22 @@
         root.classList.toggle("dark");
         try { localStorage.setItem("amd-theme", root.classList.contains("dark") ? "dark" : "light"); } catch (e) {}
     });
+
+    // Мобильное меню-«шторка».
+    const sidebar = document.getElementById("sidebar");
+    const backdrop = document.getElementById("backdrop");
+    function openSidebar() {
+        sidebar.classList.remove("-translate-x-full");
+        backdrop.classList.remove("hidden");
+    }
+    function closeSidebar() {
+        sidebar.classList.add("-translate-x-full");
+        backdrop.classList.add("hidden");
+    }
+    document.getElementById("sidebar-open").addEventListener("click", openSidebar);
+    document.getElementById("sidebar-close").addEventListener("click", closeSidebar);
+    backdrop.addEventListener("click", closeSidebar);
+    document.addEventListener("keydown", function (e) { if (e.key === "Escape") closeSidebar(); });
 </script>
 </body>
 </html>
diff --git a/web/templates/captcha.html b/web/templates/captcha.html
index 26a5991..43cd6d2 100644
--- a/web/templates/captcha.html
+++ b/web/templates/captcha.html
@@ -3,8 +3,8 @@
 {% block header %}Активные капчи{% endblock %}
 {% block content %}
 
-<div class="overflow-hidden rounded-xl border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 shadow-sm">
-    <table class="w-full text-sm">
+<div class="overflow-x-auto rounded-xl border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 shadow-sm">
+    <table class="w-full min-w-[420px] text-sm">
         <thead class="bg-gray-50 dark:bg-gray-900/60 text-gray-500 dark:text-gray-400">
             <tr>
                 <th class="px-5 py-3 text-left font-medium">Чат</th>
diff --git a/web/templates/chats.html b/web/templates/chats.html
index a62041a..1b12fb9 100644
--- a/web/templates/chats.html
+++ b/web/templates/chats.html
@@ -3,8 +3,8 @@
 {% block header %}Чаты{% endblock %}
 {% block content %}
 
-<div class="overflow-hidden rounded-xl border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 shadow-sm">
-    <table class="w-full text-sm">
+<div class="overflow-x-auto rounded-xl border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 shadow-sm">
+    <table class="w-full min-w-[640px] text-sm">
         <thead class="bg-gray-50 dark:bg-gray-900/60 text-gray-500 dark:text-gray-400">
             <tr>
                 <th class="px-5 py-3 text-left font-medium">Чат</th>
diff --git a/web/templates/log.html b/web/templates/log.html
index adc286f..2a91af8 100644
--- a/web/templates/log.html
+++ b/web/templates/log.html
@@ -3,8 +3,8 @@
 {% block header %}Журнал модерации{% endblock %}
 {% block content %}
 
-<div class="overflow-hidden rounded-xl border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 shadow-sm">
-    <table class="w-full text-sm">
+<div class="overflow-x-auto rounded-xl border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 shadow-sm">
+    <table class="w-full min-w-[720px] text-sm">
         <thead class="bg-gray-50 dark:bg-gray-900/60 text-gray-500 dark:text-gray-400">
             <tr>
                 <th class="px-5 py-3 text-left font-medium">Время</th>

--
Gitblit v1.9.3