/* ==========================================================================
   ВОССТАНОВЛЕННЫЙ FORUM_TOPIC.CSS
   ========================================================================== */

/* 1. СТРУКТУРА СООБЩЕНИЯ */
.message-container { margin-bottom: 20px; }
.message-block { display: flex; background: var(--bg-card); border: 1px solid var(--border-color); overflow: hidden; border-radius: var(--radius); }

.user-info { 
    width: 220px; flex-shrink: 0; background: var(--bg-hover); 
    border-right: 1px solid var(--border-color); padding: 20px 15px; 
    text-align: center; display: flex; flex-direction: column; align-items: center; 
}
.user-info .username { font-weight: 700; margin-bottom: 5px; font-size: 14px; word-break: break-word; color: var(--text-main); }

/* Аватары */
.user-avatar { 
    width: var(--avatar-size-topic); 
    height: var(--avatar-size-topic); 
    margin: 0 auto 15px auto; 
    position: relative; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
}

.user-avatar img { 
    width: 100%; 
    height: 100%; 
    object-fit: cover; 
    border-radius: var(--avatar-radius); 
    display: block;
    /* Контур, который подстраивается под тему */
    box-shadow: 0 0 0 1px var(--avatar-border);
    transition: box-shadow 0.3s ease;
}

/* Заглушка (теперь с адаптивным контуром) */
.default-avatar-placeholder {
    width: 100%; height: 100%; 
    display: flex; align-items: center; justify-content: center; 
    box-sizing: border-box; 
    transition: all 0.3s ease;
    border-radius: var(--avatar-radius);
    background-color: var(--bg-secondary);
    color: var(--text-muted);
    /* Тот же контур, что и у обычной картинки */
    box-shadow: 0 0 0 1px var(--avatar-border);
}


/* Светлая тема */
:root {
    --avatar-border: rgba(0, 0, 0, 0.1); /* Тонкий темный контур */
    --bg-secondary: #f1f5f9;
    --border-color: #e2e8f0;
}

/* 2. ТЕЛО СООБЩЕНИЯ */
.message-body { flex-grow: 1; display: flex; flex-direction: column; min-width: 0; }
.message-header { background: var(--bg-hover); padding: 10px 20px; border-bottom: 1px solid var(--border-color); font-size: 12px; color: var(--text-muted); display: flex; justify-content: space-between; align-items: center; }
.message-content { padding: 25px; font-size: 15px; line-height: 1.6; min-height: 100px; color: var(--text-main); }
.message-footer { margin-top: auto; padding: 8px 20px !important; border-top: 1px solid var(--border-color); background: var(--bg-card); display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 45px; }

blockquote { 
    border-left: 4px solid var(--primary-color) !important; background: rgba(255,255,255,0.03) !important; 
    color: var(--text-main) !important; margin: 15px 0; padding: 12px 15px; border-radius: var(--radius);
}

/* 3. ВЛОЖЕНИЯ */
.post-att-box { margin: 15px 0; display: block; }
.post-attachment {
    max-width: 100%; max-height: 550px; border: 1px solid var(--border-color);
    border-radius: 4px; box-shadow: 0 2px 5px rgba(0,0,0,0.2); display: inline-block; transition: all 0.2s;
}
.post-attachment:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0,0,0,0.3); }

/* 4. НИЖНИЙ БЛОК (ИЗМЕНЕНО И ИСТОРИЯ) — КОМПАКТНО */
.post-edit-info {
    font-size: 10px !important; /* Еще чуть мельче */
    color: #64748b !important; 
    margin-top: 15px;
    display: flex !important;
    flex-wrap: wrap;           /* Чтобы на мобилках переносилось аккуратно */
    align-items: center !important;
    gap: 8px !important;
    opacity: 0.6;              /* Делаем тусклее (было 0.8) */
    border-top: 1px solid rgba(255, 255, 255, 0.03); /* Едва заметная линия-разделитель */
    padding-top: 5px;
}

.edit-reason {
    font-style: italic;
    opacity: 0.9;
}

.post-history-link {
    font-size: 10px !important;
    color: var(--primary-color) !important;
    text-decoration: none !important;
    display: inline-flex !important;
    align-items: center !important;
    border-left: 1px solid rgba(255, 255, 255, 0.1); /* Маленькая черточка перед "История" */
    padding-left: 8px;
}

.post-history-link:hover { 
    text-decoration: underline !important; 
    opacity: 1; 
}

/* Шапка страницы истории */
.page-header-flex {
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 20px;
}

/* Блоки истории */
.history-current-block, .history-item {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 25px;
    background: var(--bg-card); /* Используем фон карточек из темы */
}

.history-current-block {
    border: 2px solid var(--primary-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Заголовки блоков */
.history-header {
    background: var(--primary-color);
    color: #fff;
    padding: 10px 20px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
}

.history-item-info {
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.05); /* Легкое затемнение для шапки архива */
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Тело сообщения */
.history-body {
    padding: 25px;
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-main);
}

.history-body.archived {
    font-size: 14px;
    opacity: 0.9;
}

/* Элементы декора */
.status-tag { font-size: 0.85em; opacity: 0.8; font-weight: normal; }
.history-archive-title {
    margin: 30px 0 15px 5px;
    padding-left: 10px;
    border-left: 4px solid var(--border-color);
    color: var(--text-main);
}

.history-empty {
    padding: 40px;
    background: var(--bg-card);
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    color: var(--text-muted);
    text-align: center;
}

.history-empty i { font-size: 32px; display: block; margin-bottom: 10px; opacity: 0.4; }

.reason-tag {
    color: #f87171; /* Светло-красный для темной темы */
    background: rgba(248, 113, 113, 0.1);
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 11px;
    border: 1px solid rgba(248, 113, 113, 0.2);
}

.info-left .divider { margin: 0 8px; color: var(--border-color); }
.info-left .author { color: var(--text-main); }

/* 5. МОДЕРАЦИЯ И ДРОПДАУН — ЭСТЕТИЧНО */
.admin-controls { position: relative; display: inline-block; margin-left: 10px; }
.admin-menu-btn { background: transparent; border: none; color: var(--text-muted); cursor: pointer; padding: 5px 10px; font-size: 16px; }

.admin-dropdown { 
    display: none; 
    position: absolute; 
    right: 0; 
    top: 100%; 
    background-color: #1e293b !important; 
    min-width: 190px; 
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5) !important; 
    border: 1px solid var(--border-color) !important; 
    z-index: 1000; 
    border-radius: 8px !important;
    padding: 6px 0 !important;
}

.admin-controls.open .admin-dropdown { display: block !important; }

.admin-dropdown a, 
.admin-dropdown button {
    display: flex !important;
    align-items: center !important;
    padding: 10px 16px !important;
    color: #e2e8f0 !important;
    font-size: 13px !important;
    text-decoration: none !important;
    background: transparent !important;
    border: none !important;
    width: 100% !important;
    text-align: left !important;
    transition: background 0.2s !important;
}

.admin-dropdown a:hover, 
.admin-dropdown button:hover {
    background-color: var(--primary-color) !important;
    color: #fff !important;
}

.admin-dropdown i {
    margin-right: 12px !important;
    width: 18px !important;
    text-align: center !important;
    font-size: 14px !important;
    opacity: 0.7 !important;
}

.admin-dropdown a[onclick*="delete"]:hover,
.admin-dropdown button.text-danger:hover {
    background-color: #ef4444 !important;
}

/* Стиль для склеенных сообщений */
.merge-separator {
    display: block;
    /* Отступы: 25px сверху и 15px снизу, чтобы текст не слипался */
    margin: 25px 0 15px 0; 
    padding-top: 10px;
    
    /* Тонкая пунктирная линия сверху */
    border-top: 1px dashed var(--border-color); 
    
    /* Мелкий шрифт и серый цвет */
    font-size: 11px;
    color: var(--text-muted); 
    
    /* Чтобы не бросалось в глаза, делаем чуть прозрачнее */
    opacity: 0.7; 
    line-height: 1;
}

/* Иконка часов чуть левее */
.merge-separator i {
    margin-right: 5px;
}

/* Фраза про предыдущее сообщение — делаем курсивом и еще чуть светлее */
.merge-separator i:last-child {
    font-style: italic;
    opacity: 0.8;
}

/* Выделяем верхнюю полоску сообщения (где дата) */
.post-header {
    background: rgba(255, 255, 255, 0.03) !important; /* Делаем чуть светлее общего фона */
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important; /* Тонкая линия снизу */
    padding: 10px 15px;
}

/* Добавляем вертикальную линию между автором и текстом */
.post-author-sidebar {
    border-right: 1px solid rgba(255, 255, 255, 0.05) !important;
    background: rgba(0, 0, 0, 0.1); /* Можно сделать чуть темнее основной карточки */
}

/* Общая обводка всей карточки сообщения, чтобы она не сливалась с фоном страницы */
.post-container {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 20px;
}

/* Разделение шапки и карточки юзера */
.message-header-row {
    background: rgba(0, 0, 0, 0.2) !important; /* Чуть темнее основного фона */
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
    padding: 8px 15px !important;
    margin: -15px -15px 15px -15px !important; /* Компенсируем padding родителя, если он есть */
}

/* Сама карточка юзера (user_card) - если она сливается, добавим ей легкую тень или границу */
.user-sidebar { /* или какой там у тебя класс в user_card.php */
    border-right: 1px solid rgba(255, 255, 255, 0.05) !important;
}

/* Мелкая и тусклая инфо об изменении */
.post-edit-info {
    font-size: 10px !important;
    color: var(--text-muted) !important;
    opacity: 0.5 !important; /* Тусклость */
    margin-top: 15px;
}

.post-history-link {
    color: var(--primary-color) !important;
    text-decoration: underline !important;
    margin-left: 5px;
}

/* Верхняя панель с датой (message-header) */
.message-header-line {
    background: rgba(0, 0, 0, 0.15) !important; /* Делаем чуть темнее/отличным */
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
    margin: -15px -15px 15px -15px !important; /* Убираем отступы родителя */
    padding: 10px 15px !important;
}

/* Сайдбар автора (чтобы не сливался с телом поста) */
.message-sidebar-wrapper {
    background: rgba(255, 255, 255, 0.02) !important; 
    border-right: 1px solid var(--border-color);
}

/* Зона загрузки в форме */
.attachment-upload-zone {
    margin-top: 10px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.2); /* Темный фон под стать теме */
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.reply-action-row {
    border-top: 1px solid var(--border-color);
    padding-top: 15px;
}

.btn-attach {
    background: #f59e0b !important; /* Оранжевый */
    color: #fff !important;
    padding: 8px 15px !important;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-attach:hover {
    background: #d97706 !important;
}

.attach-delete {
    cursor: pointer;
    color: #ef4444;
    font-size: 20px;
    line-height: 1;
    padding: 0 5px;
}

/* Контейнер для вложений */
.attachment-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 15px;
}

/* Карточка вложения */
.attach-card {
    display: flex;
    align-items: center;
    background: #1e293b; /* В тон темной теме */
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 6px;
    width: 220px;
    position: relative;
    transition: transform 0.2s;
}

.attach-card:hover {
    border-color: #3b82f6;
}

/* Квадрат превью */
.attach-preview-wrapper {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    background: rgba(0,0,0,0.4);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-right: 10px;
}

.attach-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.attach-file-icon {
    font-size: 18px;
    color: #94a3b8;
}

/* Текст внутри */
.attach-content {
    flex-grow: 1;
    min-width: 0;
}

.attach-name {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #f1f5f9;
}

.attach-size {
    font-size: 10px;
    color: #64748b;
}

/* Кнопка удаления (крестик) */
.attach-remove-btn {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    opacity: 0.8;
}

.attach-remove-btn:hover { opacity: 1; }

/* --- ЗАКРЫТЫЕ ТЕМЫ И СООБЩЕНИЯ --- */

/* Контейнер сообщения в закрытой теме */
.topic-locked-notice {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #ef4444;
    padding: 10px 20px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

/* --- ГИБРИДНЫЙ СТАТУС: ЗАКРЕП + ЗАКРЫТО (СВЕТЛАЯ) --- */
.subsection-row.sticky.locked {
    background: linear-gradient(90deg, #fffbeb 0%, #fef2f2 100%) !important;
    border-left: 4px solid #f59e0b !important;
    border-bottom: 1px solid #fee2e2;
}

/* Обычный Закреп (Светлая) */
.subsection-row.sticky:not(.locked) {
    background-color: #fffbeb !important;
    border-left: 4px solid #f59e0b !important;
}

/* Обычная Закрытая (Светлая) */
.subsection-row.locked:not(.sticky) {
    background-color: #fef2f2 !important;
    border-left: 4px solid #ef4444 !important;
}

/* Текст в светлой теме */
.subsection-row.sticky h3 a { color: #b45309 !important; }
.subsection-row.locked h3 a { color: #b91c1c !important; }
.subsection-row.sticky.locked h3 a { color: #92400e !important; }

/* Красный замочек в футере или хедере сообщения */
i.fa-lock {
    color: #ef4444 !important;
    text-shadow: 0 0 8px rgba(239, 68, 68, 0.3);
}

/* Специфический стиль для замочка, чтобы он не сливался */
.locked-icon-style {
    color: #ef4444 !important;
    font-size: 1.1em;
    filter: drop-shadow(0 0 2px rgba(239, 68, 68, 0.5));
}

/* Индивидуальное выделение закрытой строки, если классы в CSS файлах вдруг не сработали */
.subsection-row.locked {
    border-left: 3px solid #ef4444 !important;
}

/* --- ФИКС РЕДАКТОРА (СКРУГЛЕНИЕ) --- */
/* Учитываем все основные части CKEditor */
.ck-editor__contained, 
.ck-editor__top, 
.ck-editor__main > .ck-editor__editable {
    border-radius: var(--radius) !important;
}

/* Фикс верхней панели инструментов */
.ck-editor__top {
    border-top-left-radius: var(--radius) !important;
    border-top-right-radius: var(--radius) !important;
}

/* Фикс поля ввода */
.ck-editor__main > .ck-editor__editable {
    border-bottom-left-radius: var(--radius) !important;
    border-bottom-right-radius: var(--radius) !important;
}

/* --- ГЛОБАЛЬНЫЙ КОНТЕЙНЕР ФОРМЫ --- */
.reply-form-container {
    margin-top: 40px !important;
    background: var(--bg-card) !important;
    padding: 25px !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius) !important; /* Настройка из админки */
    box-shadow: 0 2px 15px rgba(0,0,0,0.1) !important;
}

/* --- ФИКС РЕДАКТОРА TINYMCE (СКРУГЛЕНИЕ) --- */
.tox-tinymce {
    border-radius: var(--radius) !important;
    border: 1px solid var(--border-color) !important;
    overflow: hidden !important;
		visibility: hidden;
}

/* --- НИЖНЯЯ ПАНЕЛЬ С КНОПКАМИ --- */
.reply-action-row {
    display: flex !important;
    justify-content: space-between !important; /* Статус слева, кнопки справа */
    align-items: center !important;
    margin-top: 20px !important;
    padding-top: 15px !important;
    border-top: 1px solid var(--border-color) !important;
}

/* --- СТАНДАРТНЫЕ КНОПКИ В ФОРМЕ ОТВЕТА (COMPACT) --- */
.action-buttons {
    display: flex !important;
    gap: 8px !important; /* Уменьшили зазор */
    align-items: center !important;
}

.btn-attach, 
#submit-button.button.success {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    
    /* Убираем гигантскую высоту, делаем стандарт как у Цитаты */
    padding: 6px 14px !important; 
    height: auto !important; 
    min-height: 32px !important; /* Стандартная высота небольших кнопок */
    
    font-size: 13px !important; /* Шрифт чуть меньше и аккуратнее */
    font-weight: 700 !important;
    text-transform: none !important; /* Убираем капс, чтобы не орали */
    letter-spacing: normal !important;
    
    border-radius: var(--radius) !important;
    border: none !important;
    margin: 0 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
}

/* Кнопка "Прикрепить" (в стиле Цитаты, но со своим цветом) */
.btn-attach {
    background: var(--bg-hover) !important;
    color: var(--text-main) !important;
    border: 1px solid var(--border-color) !important;
}

.btn-attach i {
    margin-right: 6px;
    font-size: 14px;
    color: var(--primary-color);
}

.btn-attach:hover {
    background: var(--primary-color) !important;
    color: #fff !important;
    border-color: var(--primary-color) !important;
}

.btn-attach:hover i {
    color: #fff !important;
}

/* Кнопка "Отправить ответ" (чуть ярче, но того же размера) */
#submit-button.button.success {
    background: var(--primary-color) !important;
    color: #fff !important;
}

#submit-button.button.success:hover {
    filter: brightness(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
}

/* Ошибка текста */
.error-text-bold {
    color: #ef4444;
    font-size: 12px;
    margin-top: 10px;
    font-weight: bold;
    display: none;
}

/* --- ПРАВИЛЬНЫЙ ХОВЕР КНОПОК РЕДАКТОРА --- */

/* 1. Цвет фона при наведении (берем твой цвет из админки) */
.tox .tox-tbtn:hover {
    background-color: var(--primary-color) !important;
    transition: background 0.2s ease !important;
}

/* 2. Иконка при наведении должна стать БЕЛОЙ для контраста */
.tox .tox-tbtn:hover svg {
    fill: #fff !important;
}

/* 3. Активные кнопки (когда нажал Жирный/Курсив) тоже красим в твой цвет */
.tox .tox-tbtn--enabled, 
.tox .tox-tbtn--active {
    background-color: var(--primary-color) !important;
}

.tox .tox-tbtn--enabled svg, 
.tox .tox-tbtn--active svg {
    fill: #fff !important;
}

/* 4. Скругление кнопок внутри тулбара (чтобы подходили под общий стиль) */
.tox .tox-tbtn {
    border-radius: var(--radius) !important;
    margin: 0 2px !important;
}

/* ==========================================================================
   MOBILE ADAPTIVE - ФИКС ДЛЯ УЗКИХ ЭКРАНОВ (до 768px)
   ========================================================================== */

@media screen and (max-width: 768px) {
    /* 1. Сообщение становится вертикальным стеком */
    .message-block {
        flex-direction: column !important;
        border-radius: var(--radius) !important;
    }

    /* 2. Сайдбар пользователя сверху */
    .user-info, .topic-card {
        width: 100% !important;
        flex-direction: row !important; /* В ряд: ава слева, инфо справа */
        align-items: center !important;
        justify-content: flex-start !important;
        padding: 10px 15px !important;
        border-right: none !important;
        border-bottom: 1px solid var(--border-color) !important;
        background: var(--bg-hover) !important;
    }

    /* 3. Уменьшаем аватарку для мобилы */
    .user-avatar {
        width: 50px !important;
        height: 50px !important;
        margin: 0 15px 0 0 !important; /* Отступ справа до текста */
    }

    /* 4. Группируем ник и звание в колонку */
    .user-card-header {
        align-items: flex-start !important;
        margin-bottom: 0 !important;
        width: auto !important;
    }

    /* 5. Скрываем тяжелую статистику на мобилках */
    .user-stats-list, 
    .user-rank-text, 
    .user-group-badge {
        display: none !important; 
    }

    /* Показываем только ник и роль (опционально) */
    .user-name-wrapper {
        justify-content: flex-start !important;
    }

    /* 6. Тело сообщения на весь экран */
    .message-body {
        width: 100% !important;
    }

    .message-content {
        padding: 15px !important;
        font-size: 14px !important;
    }

    /* 7. Кнопки в подвале на мобилках */
    .message-footer {
        padding: 10px 15px !important;
        flex-wrap: wrap !important;
    }
    
    /* Форма ответа: кнопки на мобилках делаем на всю ширину */
    .action-buttons {
        width: 100% !important;
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    .btn-attach, #submit-button {
        width: 100% !important;
        justify-content: center !important;
    }
}