/* ============================================
   NexChat — Discord-like Dark Theme
   Полный CSS для всех страниц
   ============================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg-primary: #36393f;          /* основной фон */
    --bg-secondary: #2f3136;        /* фон панелей, карточек */
    --bg-tertiary: #202225;         /* фон боковой панели */
    --bg-input: #40444b;            /* фон полей ввода */
    --text-primary: #dcddde;        /* основной текст */
    --text-secondary: #b9bbbe;      /* вторичный текст */
    --text-muted: #72767d;          /* приглушённый текст */
    --accent: #5865f2;              /* основной акцент (Discord blurple) */
    --accent-hover: #4752c4;
    --danger: #ed4245;
    --danger-hover: #c03537;
    --success: #3ba55d;
    --warning: #faa81a;
    --border: #40444b;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    --radius: 8px;
    --sidebar-width: 220px;
}

body {
    font-family: 'Whitney', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
}

/* ---------- Основная структура приложения ---------- */
.app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ---------- Боковая панель навигации ---------- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-tertiary);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-primary);
    white-space: nowrap;
}

.nav-links {
    list-style: none;
    padding: 10px 0;
    flex: 1;
    overflow-y: auto;
}

.nav-links li a {
    display: block;
    padding: 10px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
    border-radius: 0;
    font-size: 0.95rem;
}

.nav-links li a:hover {
    background: #3c3f45;
    color: var(--text-primary);
}

.nav-links li a.active {
    background: #3c3f45;
    color: var(--text-primary);
}

/* ---------- Контентная область ---------- */
.content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* ---------- Карточки и секции ---------- */
.card {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.card h2 {
    color: var(--text-primary);
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}

/* ---------- Кнопки ---------- */
button,
.btn {
    display: inline-block;
    background: var(--accent);
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 1rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
    text-align: center;
    text-decoration: none;
}

button:hover,
.btn:hover {
    background: var(--accent-hover);
    color: white;
    text-decoration: none;
}

button:active,
.btn:active {
    transform: scale(0.98);
}

.btn-secondary {
    background: #747f8d;
}
.btn-secondary:hover {
    background: #5b6775;
}

.btn-danger {
    background: var(--danger);
}
.btn-danger:hover {
    background: var(--danger-hover);
}

.btn-success {
    background: var(--success);
}
.btn-success:hover {
    background: #2d7d46;
}

/* ---------- Формы ---------- */
form {
    margin: 15px 0;
}

label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(88, 101, 242, 0.3);
}

textarea {
    min-height: 80px;
    resize: vertical;
}

/* ---------- Таблицы ---------- */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

th,
td {
    padding: 10px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: #2f3136;
    color: var(--text-secondary);
    font-weight: 600;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: #3a3c42;
}

/* ---------- Списки ---------- */
ul,
ol {
    list-style: none;
    padding: 0;
}

li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

li:last-child {
    border-bottom: none;
}

/* ---------- Общий чат ---------- */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 120px);
    background: var(--bg-primary);
    border-radius: var(--radius);
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: var(--bg-primary);
}

.chat-message {
    margin-bottom: 10px;
    padding: 8px 12px;
    border-radius: 4px;
    background: var(--bg-secondary);
    word-wrap: break-word;
}

.chat-message .author {
    font-weight: bold;
    color: var(--accent);
    margin-right: 8px;
}

.chat-message .text {
    color: var(--text-primary);
}

.chat-input {
    display: flex;
    padding: 10px;
    background: var(--bg-secondary);
    gap: 10px;
    border-top: 1px solid var(--border);
}

.chat-input input {
    flex: 1;
    margin: 0;
}

.chat-input button {
    white-space: nowrap;
}

/* ---------- Вложения и кнопки сообщений ---------- */
.attachment {
    margin: 5px 0;
}
.attachment img {
    max-width: 100%;
    max-height: 250px;
    border-radius: 4px;
}
.attachment a {
    color: var(--accent);
    text-decoration: none;
}
.attachment a:hover {
    text-decoration: underline;
}
.msg-actions {
    margin-top: 5px;
}
.btn-small {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0 5px;
    color: var(--text-muted);
}
.btn-small:hover {
    color: var(--text-primary);
}
.edit-input {
    width: auto;
    display: inline-block;
    margin-right: 5px;
}
.edited-mark {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ---------- Трёхколоночный макет сервера ---------- */
.server-layout {
    display: flex;
    gap: 10px;
    height: calc(100vh - 80px);
    margin: -20px;
    padding: 20px;
    background: var(--bg-primary);
}

.channels-sidebar,
.members-sidebar {
    width: 200px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 15px;
    overflow-y: auto;
    flex-shrink: 0;
}

.channels-sidebar h3,
.members-sidebar h3 {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 10px;
}

.channel-item {
    padding: 8px 10px;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
}

.channel-item:hover,
.channel-item.active {
    background: #3c3f45;
    color: var(--text-primary);
}

.members-sidebar ul li {
    padding: 6px 0;
    color: var(--text-secondary);
}

.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-header {
    background: var(--bg-secondary);
    padding: 10px 15px;
    border-radius: var(--radius) var(--radius) 0 0;
    border-bottom: 1px solid var(--border);
}

.chat-header h2 {
    font-size: 1.2rem;
    font-weight: bold;
}

/* ---------- Двухколоночный макет директ ---------- */
.direct-layout {
    display: flex;
    gap: 10px;
    height: calc(100vh - 80px);
    margin: -20px;
    padding: 20px;
}

.dialogs-sidebar {
    width: 220px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 15px;
    overflow-y: auto;
    flex-shrink: 0;
}

.dialogs-sidebar h3 {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 10px;
}

.dialogs-sidebar ul li a {
    display: block;
    padding: 8px 10px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
}

.dialogs-sidebar ul li a:hover {
    background: #3c3f45;
    color: var(--text-primary);
}

.dialogs-sidebar ul li a.active {
    background: #3c3f45;
    color: var(--text-primary);
}

/* ---------- Профиль пользователя ---------- */
.profile-container {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.profile-banner {
    height: 180px;
    background-size: cover;
    background-position: center;
    position: relative;
    background-color: var(--bg-input);
}

.profile-avatar {
    position: absolute;
    bottom: -40px;
    left: 20px;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 4px solid var(--bg-primary);
    overflow: hidden;
    background: var(--bg-tertiary);
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-info {
    padding: 50px 20px 20px 20px;
}

.profile-info h1 {
    margin-bottom: 5px;
    font-size: 2rem;
}

.profile-info p {
    margin: 5px 0;
    color: var(--text-secondary);
}

.profile-edit {
    padding: 20px;
    border-top: 1px solid var(--border);
}

/* ---------- Уведомления ---------- */
.alert {
    padding: 12px 15px;
    border-radius: 4px;
    margin: 10px 0;
    font-weight: 500;
}

.alert-error {
    background: #3b1d1d;
    color: #ffb3b3;
    border-left: 4px solid var(--danger);
}

.alert-success {
    background: #1d3b2a;
    color: #b3ffcc;
    border-left: 4px solid var(--success);
}

.alert-warning {
    background: #3b311d;
    color: #ffe0b3;
    border-left: 4px solid var(--warning);
}

/* ---------- Адаптивность ---------- */
@media (max-width: 900px) {
    .server-layout,
    .direct-layout {
        flex-direction: column;
        height: auto;
    }

    .channels-sidebar,
    .members-sidebar,
    .dialogs-sidebar {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .chat-area {
        width: 100%;
    }

    .chat-container {
        height: 400px;
    }
}

@media (max-width: 600px) {
    .app {
        flex-direction: column;
        overflow-y: auto;
    }

    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
    }

    .sidebar-header {
        padding: 10px;
    }

    .logo {
        font-size: 1.2rem;
    }

    .nav-links {
        display: flex;
        overflow-x: auto;
        padding: 0;
    }

    .nav-links li {
        flex-shrink: 0;
    }

    .content {
        padding: 10px;
    }

    .chat-container {
        height: 300px;
    }
}