/* ======================================================================
   ЗАЩИТА ОТ КОПИРОВАНИЯ (НЕ ВЛИЯЕТ НА ПОИСКОВЫЕ СИСТЕМЫ)
   ====================================================================== */

/* Запрет выделения текста пользователем */
.no-select,
.message-text.no-select,
.no-select *,
.message-text.no-select * {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Блокировка drag & drop текста */
.no-select,
.message-text.no-select {
    -webkit-user-drag: none;
    user-drag: none;
}

/* Защита текста сообщений */
.protect-layer {
    position: relative;
}

.protect-layer.no-pointer {
    pointer-events: none; /* для псевдоэлемента, чтобы не блокировал клики */
}

.protect-layer:after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none; /* НЕ блокирует клики по цитатам вне блока */
    background: rgba(255, 255, 255, 0);
}

/* Блокировка сохранения изображений */
img {
    -webkit-user-drag: none;
    user-drag: none;
    pointer-events: none;
}

/* Контекстное меню выключено через JS (но стили на всякий случай) */
body.no-context {
    -webkit-touch-callout: none;
}

/* ======================================================================
   СТИЛИ ТЕКСТА СООБЩЕНИЙ (обновлено для цитат)
   ====================================================================== */

.message-text {
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 1rem;
    font-size: 1.05rem;
    line-height: 1.55;
    color: inherit;
}

/* Цитаты в светлой теме */
.message-text blockquote,
.light-theme .message-text blockquote {
    border-left: 3px solid #ccc;
    margin-left: 0;
    padding-left: 0.75rem;
    color: #666;
    background-color: rgba(0, 0, 0, 0.03);
    border-radius: 0 4px 4px 0;
    padding: 8px 12px;
    margin: 8px 0;
}

/* Цитаты в темной теме */
.dark-theme .message-text blockquote {
    border-left: 3px solid #5a5a5a;
    color: #b0b3b8;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 0 4px 4px 0;
    padding: 8px 12px;
    margin: 8px 0;
}

/* Улучшенные цвета для ссылок в цитатах в темной теме */
.dark-theme .message-text blockquote a {
    color: #aecbfa;
    text-decoration: underline;
    text-decoration-color: rgba(174, 203, 250, 0.4);
}

.dark-theme .message-text blockquote a:hover {
    color: #d4e3fc;
    text-decoration-color: rgba(212, 227, 252, 0.7);
}

/* Код внутри цитат в темной теме */
.dark-theme .message-text blockquote code {
    background-color: rgba(0, 0, 0, 0.3);
    color: #e3e3e3;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.9em;
}

/* ======================================================================
   КАРТОЧКИ СООБЩЕНИЙ
   ====================================================================== */

.card {
    border-radius: 12px;
    color: inherit; /* Наследует цвет текста */
}

.card-body {
    padding: 1.25rem 1.4rem;
    color: inherit; /* Наследует цвет текста */
}

.media-list img {
    border-radius: 10px;
    max-width: 100%;
    height: auto;
}

/* ======================================================================
   НАВИГАЦИОННЫЕ КНОПКИ
   ====================================================================== */

.btn {
    border-radius: 8px !important;
}

.btn-sm {
    padding: 4px 10px;
}

.btn-primary {
    transition: 0.2s;
}

/* ======================================================================
   СВЕТЛАЯ ТЕМА (по умолчанию)
   ====================================================================== */

body.light-theme {
    background: #ffffff;
    color: #212529; /* Темный цвет текста для светлой темы */
}

.light-theme .card,
.light-theme .card-body {
    background: #ffffff;
    border-color: #dee2e6;
    color: #212529; /* Темный текст в карточках */
}

.light-theme .text-muted {
    color: #6c757d !important;
}

.light-theme .message-text {
    color: #212529; /* Темный текст сообщений */
}

.light-theme .message-text blockquote {
    border-color: #ccc;
    color: #666;
}

.light-theme .navbar {
    background-color: #ffffff !important;
    border-bottom-color: #dee2e6 !important;
    color: #212529; /* Темный текст в навбаре */
}

/* Заголовки в светлой теме */
.light-theme h1,
.light-theme h2,
.light-theme h3,
.light-theme h4,
.light-theme h5,
.light-theme h6,
.light-theme .h1,
.light-theme .h2,
.light-theme .h3,
.light-theme .h4,
.light-theme .h5,
.light-theme .h6 {
    color: #212529;
}

/* ======================================================================
   ТЕМНАЯ ТЕМА
   ====================================================================== */

body.dark-theme {
    background: #121212;
    color: #e8eaed; /* Светлый цвет текста для темной темы */
}

.dark-theme .card,
.dark-theme .card-body {
    background: #1e1e1e;
    border-color: #333;
    color: #e8eaed; /* Светлый текст в карточках */
}

.dark-theme .text-muted {
    color: #aaa !important;
}

.dark-theme .message-text {
    color: #e8eaed; /* Светлый текст сообщений */
}

.dark-theme .message-text blockquote {
    border-color: #444;
    color: #b0b3b8; /* Немного более светлый цвет для цитат */
}

.dark-theme .navbar {
    background-color: #1e1e1e !important;
    border-bottom-color: #333 !important;
    color: #e8eaed; /* Светлый текст в навбаре */
}

.dark-theme img {
    opacity: 0.95;
}

/* Заголовки в темной теме */
.dark-theme h1,
.dark-theme h2,
.dark-theme h3,
.dark-theme h4,
.dark-theme h5,
.dark-theme h6,
.dark-theme .h1,
.dark-theme .h2,
.dark-theme .h3,
.dark-theme .h4,
.dark-theme .h5,
.dark-theme .h6 {
    color: #e8eaed;
}

/* Ссылки в темной теме */
.dark-theme a {
    color: #8ab4f8;
}

.dark-theme a:hover {
    color: #aecbfa;
}

/* Подвал в темной теме */
.dark-theme footer {
    display: none;
}

/* ======================================================================
   МЕЛКИЕ УЛУЧШЕНИЯ UX
   ====================================================================== */

.fade-in {
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Плавная тень под карточками */
.shadow-sm {
    transition: box-shadow .25s ease;
}
.shadow-sm:hover {
    box-shadow: 0 0.55rem 1.25rem rgba(0,0,0,0.12)!important;
}

.dark-theme .shadow-sm:hover {
    box-shadow: 0 0.55rem 1.25rem rgba(0,0,0,0.3)!important;
}

/* ======================================================================
   ИСКЛЮЧЕНИЕ БЛОКИРОВКИ ДЛЯ РОБОТОВ
   ====================================================================== */

@media screen and (max-width: 1px) { /* Для SEO-ботов */
    .no-select,
    .message-text.no-select {
        user-select: auto !important;
        -webkit-user-select: auto !important;
    }
}

html, body {
    height: 100%;
    margin: 0;
    overflow: hidden; /* ❗ запрещаем скролл страницы */
}

/* ОСНОВНОЙ КАРКАС */
.main-layout {
    display: flex;
    height: calc(100vh - 56px); /* navbar */
    overflow: hidden;           /* ❗ важно */
}

/* ЛЕВАЯ КОЛОНКА */
.messages {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    padding-left: 12px;
    padding-right: 12px;
    overflow: hidden; /* ❗ запрещаем лишний скролл */
}

/* СКРОЛЛ СООБЩЕНИЙ */
#messages-container {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* Карточки сообщений — на всю ширину */
#messages-container .card,
#messages-container .card-body {
    width: 100%;
}

/* ПРАВАЯ КОЛОНКА */
.right-column {
    width: 340px;
    display: flex;
    flex-direction: column;
    overflow-y: auto; /* ✅ отдельный скролл */
    padding: 12px;
    border-left: 1px solid #ddd;
}

/* подсветка для найденного сообщения */
.search-highlight {
    animation: highlightPulse 2s ease;
    border-radius: 6px;
}
@keyframes highlightPulse {
    0% { box-shadow: 0 0 0 6px rgba(255, 230, 128, 0); }
    10% { box-shadow: 0 0 0 6px rgba(255, 230, 128, 0.65); }
    100% { box-shadow: 0 0 0 0 rgba(255, 230, 128, 0); }
}

/* ======================================================
   REPLIES / REPLY-TO (обновлено для темной темы)
   ====================================================== */

/* Стили сниппетов ответов в светлой теме */
.reply-snippet,
.light-theme .reply-snippet {
    background-color: #f5f5f5;
    border-left: 4px solid #6c757d;
    cursor: pointer;
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: 0 6px 6px 0;
    user-select: text;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    line-height: 1.4;
}

.reply-snippet:hover,
.light-theme .reply-snippet:hover {
    background-color: #e9ecef;
    border-left-color: #495057;
}

/* Стили сниппетов ответов в темной теме */
.dark-theme .reply-snippet {
    background-color: rgba(255, 255, 255, 0.08);
    border-left: 4px solid #555;
    color: #d1d5db;
    cursor: pointer;
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: 0 6px 6px 0;
    user-select: text;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    line-height: 1.4;
}

.dark-theme .reply-snippet:hover {
    background-color: rgba(255, 255, 255, 0.12);
    border-left-color: #777;
    color: #e8eaed;
}

/* Цитаты внутри сниппетов */
.reply-snippet blockquote,
.light-theme .reply-snippet blockquote {
    border-left: 2px solid #adb5bd;
    padding-left: 8px;
    margin: 6px 0;
    color: #6c757d;
    background-color: rgba(0, 0, 0, 0.02);
    font-size: 0.9em;
}

.dark-theme .reply-snippet blockquote {
    border-left: 2px solid #666;
    padding-left: 8px;
    margin: 6px 0;
    color: #a0a4a9;
    background-color: rgba(0, 0, 0, 0.2);
    font-size: 0.9em;
}

/* Мета-информация в сниппетах (автор, дата) */
.reply-snippet .meta-info {
    font-size: 0.8rem;
    opacity: 0.7;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
}

.light-theme .reply-snippet .meta-info {
    color: #6c757d;
}

.dark-theme .reply-snippet .meta-info {
    color: #9aa0a6;
}

/* Логотип */
.site-logo {
    font-size: 1.6rem;
    letter-spacing: 0.5px;
    line-height: 1;
    color: #0d6efd; /* светлая тема */
}

.site-logo:hover {
    color: #368dff; /* при наведении - светлая тема */
}

/* Контейнер логотип + тема */
.site-header-title {
    display: flex;
    align-items: baseline; /* 🔥 ключ */
    gap: 10px;
}

/* Кишечник */
.topic-separator {
    width: 42px;
    height: 28px; /* ⬅️ уменьшили */
    background-image: url("/static/img/gut-icon.svg");
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center bottom; /* 🔥 опускаем вниз */
    opacity: 1;
    transform: translateY(2px); /* микро-коррекция */
}

/* Название темы */
.current-topic {
    font-size: 1.6rem; /* ✅ исправлено */
    letter-spacing: 0.5px;
    font-weight: 300;
    line-height: 1;
    color: #262626;
}

.dark-theme .current-topic {
    color: #e8eaed;
}


/* Можно чуть больше на широких экранах */
@media (min-width: 992px) {
    .site-logo {
        font-size: 1.8rem;
    }
}

/* Счётчик сообщений у тем */
.topics-list .badge {
    font-size: 0.75rem;
    opacity: 0.85;
    white-space: nowrap;
}

/* ======================================================================
   АКТИВНАЯ ТЕМА
   ====================================================================== */

.topic-link.active {
    background-color: rgba(13, 110, 253, 0.12);
    border-left: 8px solid #3CB371;
    padding-left: 12px;
    padding-right: 12px;
    border-radius: 6px;
}

.dark-theme .topic-link.active {
    background-color: rgba(138, 180, 248, 0.15);
    border-left-color: #3CB371;
}

/* ======================================================================
   ТЁМНАЯ ТЕМА — ФОН И ЛЕНТА СООБЩЕНИЙ
   ====================================================================== */

.dark-theme #messages-container {
    background-color: #121212;
}

/* чуть контраста между сообщениями */
.dark-theme #messages-container .card {
    background-color: #1e1e1e;
    border-color: #2a2a2a;
}

/* ======================================================================
   SCROLLBAR (ТОЛЬКО ВНУТРЕННИЕ БЛОКИ)
   ====================================================================== */

#messages-container::-webkit-scrollbar,
.right-column::-webkit-scrollbar {
    width: 10px;
}

/* светлая тема */
#messages-container::-webkit-scrollbar-track,
.right-column::-webkit-scrollbar-track {
    background: #f1f1f1;
}

#messages-container::-webkit-scrollbar-thumb,
.right-column::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 6px;
}

/* тёмная тема */
.dark-theme #messages-container::-webkit-scrollbar-track,
.dark-theme .right-column::-webkit-scrollbar-track {
    background: #121212;
}

.dark-theme #messages-container::-webkit-scrollbar-thumb,
.dark-theme .right-column::-webkit-scrollbar-thumb {
    background: #3a3a3a;
}

.dark-theme #messages-container::-webkit-scrollbar-thumb:hover,
.dark-theme .right-column::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* =========================
   СТАТИСТИКА
   ========================= */

.stats-block {
    margin-top: 12px;
}

.stats-block h6 {
    font-size: 0.85rem;
    opacity: 0.85;
    margin-bottom: 6px;
}

.stats-scroll {
    max-height: 150px;
    overflow-y: auto;
    padding-right: 4px;
}

.stats-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    padding: 2px 0;
    opacity: 0.9;
}

.stats-item:hover {
    opacity: 1;
}

.stats-user {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stats-count {
    background: rgba(120,120,120,0.2);
    border-radius: 10px;
    padding: 0 6px;
    font-size: 0.7rem;
}

.dark-theme .stats-item {
    color: #e8eaed;
}

/* ======================================================================
   ФИНАЛЬНЫЙ ФИКС: БЕЛЫЙ ФОН СПИСКА ТЕМ (Bootstrap list-group)
   ====================================================================== */

/* Сам белый прямоугольник */
.dark-theme .topics-list .list-group {
    background-color: #1e1e1e !important;
    border-color: #2a2a2a !important;
}

/* Элементы списка */
.dark-theme .topics-list .list-group-item {
    background-color: transparent !important;
    color: #e6e6e6 !important;
    border-color: #2a2a2a !important;
}

/* Hover */
.dark-theme .topics-list .list-group-item:hover {
    background-color: rgba(255,255,255,0.06) !important;
}

/* Активная тема */
.dark-theme .topics-list .list-group-item.active {
    background-color: rgba(138, 180, 248, 0.18) !important;
    border-left: 4px solid #8ab4f8;
    color: #ffffff !important;
}

/* Счётчики */
.dark-theme .topics-list .badge {
    background-color: rgba(255,255,255,0.12) !important;
    color: #ffffff !important;
}

/* Улучшенная подсветка найденного сообщения */
.search-highlight {
    position: relative;
    z-index: 5;
    animation: highlightFlash 2s ease;
}

.search-highlight::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(255, 230, 128, 0.45);
    border-radius: 6px;
    pointer-events: none;
    animation: highlightFade 2s ease;
}

@keyframes highlightFlash {
    0%   { transform: scale(1.01); }
    50%  { transform: scale(1); }
    100% { transform: scale(1); }
}

@keyframes highlightFade {
    0%   { opacity: 0; }
    10%  { opacity: 1; }
    100% { opacity: 0; }
}

