/* =========================================
   1. ГЛАВНАЯ (Список разделов)
   ========================================= */
.section-block {
    background: var(--bg-card); border-radius: var(--radius);
    box-shadow: var(--shadow-sm); margin-bottom: 20px;
    border: 1px solid var(--border-color); overflow: hidden;
    
    /* --- ДОБАВЛЯЕМ СИНЮЮ ПОЛОСКУ СВЕРХУ ДЛЯ ВСЕХ БЛОКОВ --- */
    border-top: 4px solid var(--primary-color);
}

.section-header {
    background: linear-gradient(to right, #fff, #f8fafc);
    padding: 12px 20px; font-size: 16px; font-weight: 700;
    border-bottom: 1px solid var(--border-color);
    
    /* --- УБИРАЕМ ПОЛОСКУ СЛЕВА (она теперь сверху) --- */
    border-left: none; 
    
    display: flex; align-items: center;
}

.subsection-row {
    display: flex; align-items: center; gap: 15px;
    padding: 15px 20px; border-bottom: 1px solid var(--border-color);
    transition: background 0.1s;
    
    /* --- НОВОЕ: Для кликабельности всей строки --- */
    position: relative; 
    cursor: pointer;
}
.subsection-row:last-child { border-bottom: none; }
.subsection-row:hover { background-color: var(--bg-hover); }

/* --- НОВЫЙ КЛАСС: Растягивает ссылку на весь родительский блок (.subsection-row) --- */
.stretched-link::after {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1;
    content: "";
}

/* Остальные стили иконок и текста оставляем как были */
.icon-wrapper { font-size: 24px; min-width: 40px; text-align: center; }

/* Анимация пульсации */
.icon-pulse { 
    animation: pulse-fade 2s infinite ease-in-out; 
    color: var(--primary-color); 
}
@keyframes pulse-fade { 
    0% { opacity: 1; } 
    50% { opacity: 0.6; } 
    100% { opacity: 1; } 
}

.subsection-info h3 { margin: 0 0 4px 0; font-size: 15px; }

/* Добавляем цвет inherit, чтобы ссылка не становилась синей при наведении на строку, 
   а менялась только при наведении на сам текст (опционально, но так чище) */
.subsection-info h3 a { color: var(--text-main); font-weight: 600; text-decoration: none; }
.subsection-info h3 a:hover { color: var(--primary-color); }

.subsection-meta { margin-left: auto; font-size: 12px; color: var(--text-muted); text-align: right; min-width: 140px; }

/* =========================================
   2. МОДУЛИ СТАТИСТИКИ (Главная)
   ========================================= */
.stats-grid-compact {
    display: grid; grid-template-columns: minmax(250px, 1fr) 250px 3fr;
    gap: 20px; margin-bottom: 40px;
}
.stat-col {
    background: #fff; border: 1px solid var(--border-color);
    border-radius: var(--radius); overflow: hidden;
}
.stat-header {
    background: #f8fafc; padding: 10px 15px; font-weight: 700; font-size: 12px;
    border-bottom: 1px solid var(--border-color); color: var(--text-muted); text-transform: uppercase;
}

/* Таблица статистики */
.stat-table-compact { width: 100%; border-collapse: collapse; table-layout: fixed; }

/* ЗАГОЛОВКИ ТАБЛИЦЫ */
.stat-table-compact th {
    background: #fcfcfc; 
    padding: 8px 10px; 
    font-size: 11px;
    border-bottom: 1px solid #eee; 
    color: #94a3b8; 
    font-weight: 700;
    text-transform: uppercase;
    
    /* ГЛАВНОЕ ИЗМЕНЕНИЕ: Всё строго влево */
    text-align: left !important;
}

/* ЯЧЕЙКИ ТАБЛИЦЫ */
.stat-table-compact td {
    padding: 8px 10px; font-size: 13px; border-bottom: 1px solid #f1f5f9;
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; /* Троеточие для длинного текста */
    vertical-align: middle;
    
    /* ГЛАВНОЕ ИЗМЕНЕНИЕ: Всё строго влево */
    text-align: left !important;
}
.stat-table-compact tr:last-child td { border-bottom: none; }


/* ПЕРЕОПРЕДЕЛЕНИЕ КЛАССОВ (Чтобы сбросить text-center из HTML) */
.stat-table-compact th.text-center, 
.stat-table-compact td.text-center,
.stat-table-compact th.text-right, 
.stat-table-compact td.text-right {
    text-align: left !important;
}

/* ИСКЛЮЧЕНИЕ: Для цифр и дат убираем троеточие, чтобы они были видны целиком */
.stat-table-compact td.text-center,
.stat-table-compact td.text-right,
.stat-table-compact td.no-overflow {
    text-overflow: clip;
    overflow: visible;
}

/* Ссылки внутри статистики */
.stat-topic-link { color: var(--text-main); font-weight: 500; display: block; overflow: hidden; text-overflow: ellipsis; }
.stat-topic-link:hover { color: var(--primary-color); }

.author-link { font-weight: 600; color: #475569; }
.author-link:hover { color: var(--primary-color); text-decoration: underline; }

.text-truncate-cell { display: block; overflow: hidden; text-overflow: ellipsis; }

.badge-gray { background: #f1f5f9; color: var(--text-muted); font-size: 10px; padding: 2px 8px; border-radius: 10px; font-weight: bold; }
.small-font { font-size: 12px; }

/* =========================================
   3. СПИСОК ТЕМ (Подфорум)
   ========================================= */
.subforum-title-area {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 20px; border-bottom: 1px solid transparent; padding-bottom: 5px;
}
.subforum-title-area h1 { margin: 0; font-size: 22px; }

.topic-list-container {
    background: #fff; border: 1px solid var(--border-color);
    border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm);
}
.topic-list-header {
    display: grid; grid-template-columns: 50px 1fr 180px 180px;
    background: #f8fafc; padding: 10px 15px;
    border-bottom: 1px solid var(--border-color);
    font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-muted);
}
.topic-row {
    display: grid; grid-template-columns: 50px 1fr 180px 180px;
    align-items: center; padding: 12px 15px;
    border-bottom: 1px solid #f1f5f9; background: #fff; transition: background 0.1s;
    
    /* --- НОВОЕ: Делаем строку базой для ссылки --- */
    position: relative;
    cursor: pointer;
}
.topic-row:hover { background: var(--bg-hover); }
.topic-author a,
.topic-last-post a {
    position: relative;
    z-index: 2; /* Они будут поверх главной ссылки */
}

/* Статусы тем */
.sticky-row { background-color: #fffbeb !important; border-left: 3px solid #f59e0b; }
.locked-row { background-color: #fef2f2 !important; border-left: 3px solid #ef4444; }
.unread { font-weight: bold; }

.topic-icon { text-align: center; font-size: 18px; }
.sticky-icon { color: #d97706; transform: rotate(45deg); }
.locked-icon { color: #ef4444; }
.new-msg-icon { color: var(--primary-color); }
.read-icon { color: #cbd5e1; }

.topic-title a { font-size: 15px; color: var(--text-main); font-weight: 600; display: flex; align-items: center; }
.topic-stats { font-size: 12px; color: var(--text-muted); display: flex; flex-direction: column; }
.stat-row { display: flex; justify-content: space-between; width: 80%; }
.topic-last-post { font-size: 12px; text-align: right; }

/* =========================================
   4. ПРОСМОТР ТЕМЫ (Сообщения)
   ========================================= */
.message-container { margin-bottom: 20px; }
.message-block {
    display: flex; background: #fff; border: 1px solid var(--border-color);
    border-radius: var(--radius); overflow: hidden;
}

/* Юзер слева */
.user-info {
    width: 180px; flex-shrink: 0; background: #fcfcfc;
    border-right: 1px solid var(--border-color); padding: 20px 10px;
    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; }
.user-info .avatar {
    width: 90px; height: 90px; border-radius: 50%; overflow: hidden;
    margin: 10px 0; border: 3px solid #fff; box-shadow: var(--shadow-sm);
}
.user-info .badge {
    font-size: 10px; padding: 3px 8px; border-radius: 10px;
    background: #e2e8f0; color: var(--text-muted); font-weight: bold;
    text-transform: uppercase;
}
.user-info .badge.admin { background: #fee2e2; color: var(--danger-color); }

.user-stats-list { width: 100%; text-align: left; font-size: 11px; color: var(--text-muted); margin-top: 15px; }

/* Тело сообщения */
.message-body { flex-grow: 1; display: flex; flex-direction: column; min-width: 0; }
.message-header {
    background: #f8fafc; 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: #334155; }
.message-content img { max-width: 100%; border-radius: 4px; }
.message-content blockquote {
    border-left: 3px solid var(--primary-color); background: #f8fafc;
    margin: 10px 0; padding: 10px 15px; color: var(--text-muted); font-style: italic;
}
.message-footer {
    margin-top: auto; padding: 10px 20px; border-top: 1px solid #f1f5f9;
    background: #fff; display: flex; justify-content: flex-end; gap: 8px;
}

/* Форма ответа */
.reply-form-container { margin-top: 30px; }

/* АДАПТИВ */
@media (max-width: 900px) {
    .stats-grid-compact { grid-template-columns: 1fr; }
    .stat-col.wide { grid-column: 1; }
}
@media (max-width: 768px) {
    .topic-list-header { display: none; }
    .topic-row {
        grid-template-columns: 40px 1fr;
        grid-template-areas: "icon main" "icon stats" "icon last";
        gap: 10px; padding: 15px;
    }
    .topic-icon { grid-area: icon; align-self: start; }
    .topic-title { grid-area: main; }
    .topic-stats { grid-area: stats; flex-direction: row; gap: 15px; }
    .topic-last-post { grid-area: last; text-align: left; border-top: 1px dashed #eee; padding-top: 5px; }
    
    .message-block { flex-direction: column; }
    .user-info { width: 100%; border-right: none; border-bottom: 1px solid var(--border-color); flex-direction: row; text-align: left; padding: 10px 15px; }
    .user-info .avatar { width: 40px; height: 40px; margin: 0 15px 0 0; }
    .user-stats-list { display: none; }
}

/* Статус пользователя (точка) */
.user-status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-left: 6px;
    vertical-align: middle;
    border: 2px solid #fff; /* Белая обводка, чтобы отделить от фона */
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.user-status-dot.online {
    background-color: #10b981; /* Зеленый */
    animation: status-pulse 2s infinite;
}

.user-status-dot.offline {
    background-color: #cbd5e1; /* Серый (если решите включить) */
}

/* Легкая пульсация для онлайн статуса */
@keyframes status-pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    70% { box-shadow: 0 0 0 4px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}