:root {
    --bg-body: #141414;
    --bg-panel: #1e1e1e;
    --bg-header: #1a1a1a;
    --bg-input: #252525;
    --border: #333;
    --accent: #B266FF;
    --accent-hover: #9b4dca;
    --text-main: #eee;
    --text-muted: #aaa;
    
    --status-open: #4caf50;
    --status-review: #ff9800;
    --status-rejected: #f44336;
    --status-solved: #2196f3;
    
    --header-height: 70px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: var(--bg-body); color: var(--text-main); line-height: 1.5; font-size: 16px; -webkit-font-smoothing: antialiased; }
a { text-decoration: none; color: inherit; transition: 0.2s; }
ul { list-style: none; }

/* --- LAYOUT & CONTAINER --- */
.container { 
    max-width: 1200px; 
    margin: 0 auto; 
    padding: 0 15px; 
}

/* Основная сетка страницы: Сайдбар + Контент */
.main-content {
    display: grid;
    grid-template-columns: 300px 1fr; /* Сайдбар слева, контент справа */
    gap: 30px;
    margin-top: 30px;
    margin-bottom: 50px;
    align-items: start;
}

/* Меняем порядок: Сайдбар слева (как в коде base.html он идет первым, но лучше визуально контролировать) */
/* Если в HTML <aside> идет ПЕРВЫМ, то grid-template-columns: 300px 1fr - ок. */

/* --- HEADER --- */
.header { 
    background: var(--bg-header); 
    border-bottom: 2px solid var(--accent); 
    height: var(--header-height);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5); 
}

.nav-wrapper { 
    height: 100%; 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
}

.logo { 
    font-size: 24px; 
    font-weight: 900; 
    color: var(--accent); 
    text-transform: uppercase; 
    letter-spacing: 1px; 
    z-index: 1002;
}

/* Навигация (Desktop) */
.nav-links { display: flex; align-items: center; gap: 20px; }
.nav-links a { color: var(--text-muted); font-weight: 600; font-size: 15px; }
.nav-links a:hover { color: #fff; text-shadow: 0 0 10px rgba(255,255,255,0.3); }

/* Кнопки авторизации */
.auth-buttons { display: flex; align-items: center; gap: 10px; z-index: 1002; }

/* Гамбургер (скрыт на ПК) */
.burger-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    flex-direction: column;
    gap: 5px;
    z-index: 1002;
    padding: 10px;
}
.burger-btn span {
    display: block;
    width: 25px;
    height: 3px;
    background-color: var(--text-main);
    border-radius: 3px;
    transition: 0.3s;
}

/* --- BUTTONS --- */
.btn { padding: 10px 20px; border-radius: 6px; font-weight: 600; cursor: pointer; border: none; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; transition: 0.2s; text-align: center;}
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 4px 15px rgba(178, 102, 255, 0.2); }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-muted); }
.btn-outline:hover { border-color: var(--text-main); color: var(--text-main); background: rgba(255,255,255,0.05); }
.btn-danger { background: rgba(244, 67, 54, 0.1); color: #f44336; padding: 6px 12px; font-size: 12px; }
.btn-danger:hover { background: rgba(244, 67, 54, 0.2); }

/* --- PANELS & CARDS --- */
.panel { background: var(--bg-panel); border-radius: 12px; border: 1px solid var(--border); overflow: hidden; margin-bottom: 20px; box-shadow: 0 5px 20px rgba(0,0,0,0.2); }
.panel-header { background: #252525; padding: 15px 20px; font-weight: 700; font-size: 16px; color: #fff; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px;}

/* --- SIDEBAR --- */
.sidebar { grid-column: 1 / 2; } /* Сайдбар в 1 колонке */
.sidebar-card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 12px; padding: 20px; box-shadow: 0 5px 20px rgba(0,0,0,0.2); }
.sidebar-title { font-weight: 700; color: var(--text-muted); text-transform: uppercase; font-size: 12px; margin-bottom: 15px; letter-spacing: 1px; }
.menu-item { display: flex; align-items: center; padding: 12px; border-radius: 8px; color: var(--text-main); margin-bottom: 5px; transition: 0.2s; background: rgba(255,255,255,0.02); }
.menu-item:hover { background: rgba(255,255,255,0.05); transform: translateX(5px); }
.menu-icon { margin-right: 12px; width: 20px; text-align: center; font-size: 18px; }

/* --- FORUM LIST --- */
.forum-node { display: flex; padding: 20px; border-bottom: 1px solid var(--border); cursor: pointer; align-items: center; }
.forum-node:last-child { border-bottom: none; }
.forum-node:hover { background: #232323; }
.node-icon { font-size: 28px; margin-right: 20px; color: var(--accent); opacity: 0.8; }
.node-info { flex: 1; }
.node-title { font-size: 18px; font-weight: 700; color: #fff; margin-bottom: 6px; display: block; }
.node-desc { font-size: 14px; color: var(--text-muted); line-height: 1.4; }
.node-stats { font-size: 13px; color: #666; text-align: right; min-width: 80px; white-space: nowrap; }

/* --- TOPIC LIST --- */
.topic-row { display: flex; padding: 15px 20px; border-bottom: 1px solid var(--border); align-items: center; cursor: pointer; transition: 0.2s; }
.topic-row:hover { background: #232323; }
.topic-avatar { width: 45px; height: 45px; background: #2a2a2a; border-radius: 50%; margin-right: 15px; display: flex; align-items: center; justify-content: center; font-weight: bold; color: #aaa; border: 1px solid #333; flex-shrink: 0;}
.topic-main { flex: 1; min-width: 0; /* Fix flex overflow */ }
.topic-title { font-size: 16px; font-weight: 600; color: #eee; margin-bottom: 6px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topic-meta { font-size: 13px; color: #888; }
.topic-status { font-size: 10px; padding: 3px 8px; border-radius: 4px; margin-right: 8px; text-transform: uppercase; font-weight: 800; letter-spacing: 0.5px; vertical-align: middle; }
.status-open { background: rgba(76, 175, 80, 0.15); color: var(--status-open); }
.status-review { background: rgba(255, 152, 0, 0.15); color: var(--status-review); }
.status-rejected { background: rgba(244, 67, 54, 0.15); color: var(--status-rejected); }
.status-solved { background: rgba(33, 150, 243, 0.15); color: var(--status-solved); }

/* --- POST VIEW (INSIDE TOPIC) --- */
.post { display: flex; border-bottom: 1px solid var(--border); padding: 25px; gap: 25px; }
.post-author { width: 160px; text-align: center; flex-shrink: 0; }
.avatar-large { width: 100px; height: 100px; background: #252525; margin: 0 auto 15px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 36px; color: #666; border: 2px solid #333; }
.author-name { font-weight: 700; color: #fff; display: block; margin-bottom: 8px; word-break: break-all; }
.author-badge { padding: 4px 10px; border-radius: 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; display: inline-block; letter-spacing: 0.5px; }
.badge-admin { background: linear-gradient(45deg, var(--accent), #7a2bb3); color: #fff; box-shadow: 0 2px 10px rgba(178, 102, 255, 0.3); }
.badge-user { background: #333; color: #aaa; }

.post-content { flex: 1; min-width: 0; }
.post-header { display: flex; justify-content: space-between; margin-bottom: 15px; font-size: 13px; color: #666; padding-bottom: 10px; border-bottom: 1px dashed #333; }
.post-text { font-size: 15px; line-height: 1.6; color: #ddd; word-wrap: break-word; }
.post-text img { max-width: 100%; height: auto; border-radius: 6px; }

/* --- FORMS --- */
.form-control { width: 100%; background: var(--bg-input); border: 1px solid var(--border); padding: 14px; color: #fff; border-radius: 6px; margin-bottom: 15px; font-family: inherit; font-size: 15px; transition: 0.2s; }
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(178, 102, 255, 0.1); }
textarea.form-control { min-height: 150px; resize: vertical; }

/* =========================================
   MOBILE RESPONSIVENESS (Media Queries)
   ========================================= */

@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr; /* Одна колонка */
    }
    
    /* Сайдбар перемещаем вниз или вверх по желанию. По умолчанию в гриде он встанет первым, так как в HTML он первый. 
       Если хотим контент первым, а сайдбар внизу: */
    .sidebar { order: 2; }
    main { order: 1; }

    /* Кнопку "Создать тему" в сайдбаре делаем менее кричащей или оставляем как есть */
}

@media (max-width: 768px) {
    /* -- HEADER MOBILE -- */
    .burger-btn { display: flex; } /* Показываем гамбургер */

    .nav-links {
        position: fixed;
        top: var(--header-height);
        left: 0;
        width: 100%;
        height: 0; /* Скрыто */
        background: var(--bg-panel);
        flex-direction: column;
        align-items: center;
        overflow: hidden;
        transition: height 0.3s ease;
        border-bottom: 1px solid var(--accent);
        gap: 0;
    }

    .nav-links.active {
        height: auto;
        padding-bottom: 20px;
        box-shadow: 0 10px 20px rgba(0,0,0,0.5);
    }

    .nav-links a {
        display: block;
        width: 100%;
        text-align: center;
        padding: 15px;
        border-bottom: 1px solid #333;
        font-size: 16px;
    }

    .auth-buttons {
        /* На мобильном можно скрыть кнопки в хедере и перенести в меню, но проще уменьшить */
        font-size: 12px;
    }
    .auth-buttons span { display: none; } /* Скрываем имя юзера, оставляем кнопку выход */
    .btn { padding: 8px 12px; font-size: 13px; }

    /* -- POST MOBILE -- */
    .post { flex-direction: column; padding: 15px; gap: 15px; }
    .post-author { 
        width: 100%; 
        display: flex; 
        align-items: center; 
        justify-content: flex-start; 
        text-align: left; 
        background: #232323;
        padding: 10px;
        border-radius: 6px;
    }
    .avatar-large { 
        width: 50px; 
        height: 50px; 
        font-size: 20px; 
        margin: 0 15px 0 0; 
        border-width: 1px;
    }
    .author-name { margin-bottom: 2px; font-size: 15px; }
    
    /* -- FORUM LIST MOBILE -- */
    .forum-node { padding: 15px; }
    .node-icon { font-size: 22px; margin-right: 15px; }
    .node-title { font-size: 16px; }
    .node-desc { font-size: 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
    .node-stats { display: none; /* Скрываем статистику на очень мелких экранах, чтобы не мешала */ }

    /* -- TOPIC LIST MOBILE -- */
    .topic-row { padding: 12px 15px; }
    .topic-avatar { width: 35px; height: 35px; font-size: 14px; margin-right: 10px; }
    .topic-title { font-size: 14px; white-space: normal; } /* Разрешаем перенос текста */
    .topic-meta { font-size: 11px; margin-top: 4px; }
}