@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;600;800&display=swap');

:root {
    --bg: #F8F5F0;
    --panel: #FFFFFF;
    --border: rgba(62, 91, 119, 0.15);
    --text: #2C2C2C;
    --text-soft: #5D4037;
    --accent: #B03A2E;
    --accent-light: #FBE9E7;
    --accent-blue: #3E5B77;
    --hover: #F2EFE9;
    --active: #EBE7DF;
    --radius: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Manrope', sans-serif;
    background: var(--bg);
    color: var(--text);
}

.app { display: flex; height: 100vh; height: 100dvh; }

/* Сайдбар */
.sidebar {
    width: 280px;
    background: var(--panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 15px rgba(0,0,0,0.02);
}

.sidebar-header {
    padding: 20px 16px;
    border-bottom: 1px solid var(--border);
}

.brand {
    font-weight: 800;
    font-size: 1.4rem;
    color: var(--accent);
    letter-spacing: -1px;
}

.expansion {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent-blue);
    display: block;
    margin-top: 2px;
}

.users-list { flex: 1; overflow-y: auto; padding: 12px; }

.user-item {
    padding: 12px;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    transition: all 0.2s ease;
}

.user-item:hover { background: var(--hover); }
.user-item.selected {
    background: var(--active);
    font-weight: 700;
    box-shadow: inset 0 0 0 1px var(--border);
}

.online-indicator {
    font-size: 10px;
    background: #4CAF50;
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
}

/* Чат */
.chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-image: radial-gradient(var(--border) 1px, transparent 1px);
    background-size: 20px 20px;
}

.chat-header {
    padding: 16px 20px;
    background: rgba(255,255,255,0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

/* Бабблы сообщений */
.message {
    margin-bottom: 12px;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    max-width: 65%;
    width: fit-content;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}

.message.from {
    margin-left: auto;
    background: var(--accent-light);
    border-color: rgba(176, 58, 46, 0.1);
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 4px;
}

.message .author {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--accent-blue);
    margin-bottom: 4px;
    cursor: pointer;
}

.message .time {
    font-size: 0.65rem;
    color: var(--text-soft);
    margin-top: 6px;
    text-align: right;
}

/* Поле ввода */
.composer {
    padding: 20px;
    background: var(--panel);
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
    align-items: center;
}

.composer textarea {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 18px;
    font-family: inherit;
    resize: none;
    background: var(--bg);
    transition: border-color 0.2s;
}

.composer textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.file-attach {
    background: var(--hover);
    color: var(--accent-blue);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.file-attach:hover { background: var(--active); }

#sendBtn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
}

#sendBtn:hover {
    box-shadow: 0 4px 12px rgba(176, 58, 46, 0.3);
}

#sendBtn:active { transform: scale(0.96); }

/* Мобильная адаптация */
@media (max-width: 700px) {
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        z-index: 1000;
        transition: left 0.2s ease;
    }
    .sidebar.open {
        left: 0;
    }
    .chat {
        width: 100%;
    }
    .message {
        max-width: 85%;
        font-size: 14px;
    }
    .composer textarea {
        font-size: 16px;
    }
    .menu-toggle {
        display: block;
        background: var(--accent);
        border: none;
        border-radius: 8px;
        width: 36px;
        height: 36px;
        font-size: 20px;
        cursor: pointer;
        color: white;
    }
}

@media (min-width: 701px) {
    .menu-toggle {
        display: none;
    }
}

/* Аватарки */
.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: #ddd;
}

.online-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    background: #4caf50;
    border-radius: 50%;
    border: 2px solid var(--panel);
}

/* Кнопка логаута */
#logoutBtn {
    background: none;
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 4px 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

#logoutBtn:hover {
    background: var(--accent);
    color: white;
}

/* Прогресс-бар */
.progress-bar {
    width: 100%;
    height: 4px;
    background: #ddd;
    border-radius: 2px;
    margin-top: 8px;
}

.progress-fill {
    width: 0%;
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.2s;
}

/* Анимация для тостов */
@keyframes fadeInOut {
    0% { opacity: 0; transform: translateY(20px); }
    10% { opacity: 1; transform: translateY(0); }
    90% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(20px); }
}

/* Предпросмотр изображений */
.image-preview {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    margin-top: 8px;
}

.preview-img {
    max-width: 400px;
    max-height: 400px;
    border-radius: 12px;
    cursor: pointer;
    object-fit: cover;
    background: #ddd;
}

/* На телефонах картинки поменьше */
@media (max-width: 700px) {
    .preview-img {
        max-width: 200px;
        max-height: 200px;
    }
}

/* Аудиоплеер */
.audio-preview {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    margin-top: 8px;
}

audio {
    max-width: 250px;
    border-radius: 20px;
}

/* Кнопка скачивания у картинок и аудио */
.download-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 4px 12px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s;
}

.download-btn:hover {
    background: #922f25;
}

.composer textarea.drag-over {
    border: 2px solid var(--accent);
    background: var(--accent-light);
    box-shadow: 0 0 0 2px rgba(176, 58, 46, 0.2);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.new-message {
    animation: fadeInUp 0.2s ease-out;
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

#profileModal, #settingsModal {
    animation: zoomIn 0.2s ease-out;
}

#profileModal.closing, #settingsModal.closing {
    animation: fadeOut 0.15s ease-out forwards;
}

/* Плавное появление просмотрщика */
#imageViewer {
    transition: background 0.2s ease;
}
#imageViewer img {
    transition: opacity 0.2s ease, transform 0.2s ease;
}

/* ===== СТРАНИЦЫ АВТОРИЗАЦИИ (логин / регистрация) ===== */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
    padding: 20px;
}

.auth-card {
    background: #FFFFFF;
    padding: 40px;
    border-radius: 24px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 10px 40px rgba(0,0,0,0.05);
    border: 1px solid var(--border);
    text-align: center;
}

.auth-logo {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--accent);
    margin-bottom: 4px;
    letter-spacing: -2px;
}

.auth-subtitle {
    font-size: 0.8rem;
    color: var(--accent-blue);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 30px;
}

.input-group {
    margin-bottom: 15px;
    text-align: left;
    position: relative;
}

.auth-form input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-family: inherit;
    font-size: 1rem;
    background: var(--bg);
    transition: border-color 0.2s;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.pass-toggle {
    position: absolute;
    right: 14px;
    top: 14px;
    cursor: pointer;
    color: var(--text-soft);
    user-select: none;
}

.consent-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    text-align: left;
    margin: 20px 0;
    font-size: 0.85rem;
    color: var(--text-soft);
}

.consent-wrapper input {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    flex-shrink: 0;
}

.consent-wrapper a {
    color: var(--accent-blue);
    text-decoration: none;
}

.consent-wrapper a:hover {
    text-decoration: underline;
}

.auth-btn {
    width: 100%;
    background: var(--accent);
    color: white;
    padding: 16px;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 10px;
}

.auth-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(176, 58, 46, 0.2);
}

.auth-footer {
    margin-top: 25px;
    font-size: 0.9rem;
    color: var(--text-soft);
}

.auth-link {
    color: var(--accent-blue);
    text-decoration: none;
    font-weight: 700;
}

.auth-link:hover {
    text-decoration: underline;
}

.error-msg {
    color: #B03A2E;
    font-size: 0.85rem;
    margin-top: 15px;
    text-align: center;
}/* ============================================================
   public/app2/style2.css
   Стили специфичные для LightNet 1.5
   Основные переменные и базовые стили — в /style.css
   ============================================================ */

/* ── Layout ──────────────────────────────────────────────── */
.chat-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* ── Сайдбар: профиль пользователя ──────────────────────── */
.sidebar-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.sidebar-user-info .brand {
    display: block;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-info .expansion {
    font-size: 0.7rem;
}

/* ── Статус соединения ───────────────────────────────────── */
.connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
}

.connection-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9e9e9e;
    flex-shrink: 0;
    transition: background 0.3s;
}

.connection-text {
    font-size: 0.7rem;
    color: var(--text-soft);
}

/* ── Действия в сайдбаре ────────────────────────────────── */
.sidebar-actions {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}

.btn-create-group {
    width: 100%;
    background: var(--accent);
    color: white;
    border: none;
    padding: 10px;
    border-radius: var(--radius);
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.btn-create-group:hover { background: #963228; }

/* ── Метки секций ───────────────────────────────────────── */
.sidebar-section-label {
    padding: 10px 16px 4px;
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent-blue);
}

/* ── Элемент контакта ───────────────────────────────────── */
.contact-item {
    padding: 10px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 2px;
    transition: background 0.15s;
    position: relative;
}

.contact-item:hover    { background: var(--hover); }
.contact-item.selected { background: var(--active); font-weight: 700; }

.contact-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.contact-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.contact-name {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-last-msg {
    font-size: 0.72rem;
    color: var(--text-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Заглушка аватара */
.avatar-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-blue);
    color: white;
    font-weight: 800;
    font-size: 0.9rem;
}

.avatar-group {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: white;
    font-weight: 800;
    font-size: 1rem;
}

/* Счётчик непрочитанных */
.unread-badge {
    background: var(--accent);
    color: white;
    font-size: 0.7rem;
    font-weight: 800;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    flex-shrink: 0;
}

/* ── Шапка чата ─────────────────────────────────────────── */
.chat-title {
    font-weight: 700;
    font-size: 1rem;
}

.chat-header-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* ── Разделитель дат ─────────────────────────────────────── */
.date-separator {
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-soft);
    margin: 16px 0 8px;
    position: relative;
}

.date-separator::before,
.date-separator::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 30%;
    height: 1px;
    background: var(--border);
}

.date-separator::before { left: 0; }
.date-separator::after  { right: 0; }

/* ── Текст сообщения ─────────────────────────────────────── */
.msg-text {
    word-break: break-word;
    white-space: pre-wrap;
    line-height: 1.5;
}

/* ── Галочки readBy ──────────────────────────────────────── */
.read-mark {
    font-size: 0.75rem;
    margin-left: 4px;
}

/* ── Превью файла ────────────────────────────────────────── */
.file-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    padding: 8px 12px;
    background: var(--hover);
    border-radius: 8px;
    font-size: 0.85rem;
}

.file-icon { font-size: 1.2rem; }

.file-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Пустой экран ────────────────────────────────────────── */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    opacity: 0.5;
}

.empty-logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
    opacity: 0.6;
}

.empty-title {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: -1px;
}

.empty-subtitle {
    font-size: 0.9rem;
    color: var(--text-soft);
}

/* ── Кнопка 📡 КУРС ──────────────────────────────────────── */
.node-btn {
    position: fixed;
    bottom: 24px;
    left: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--panel);
    border: 1px solid var(--border);
    font-size: 1.3rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 500;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.node-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

.node-btn.reconnecting {
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(176,58,46,0.4); }
    50%       { box-shadow: 0 0 0 8px rgba(176,58,46,0); }
}

/* ── Панель узлов ────────────────────────────────────────── */
.node-panel {
    position: fixed;
    bottom: 82px;
    left: 24px;
    width: 280px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
    z-index: 500;
    overflow: hidden;
    display: none;
}

.node-panel.open { display: block; }

.node-panel-title {
    padding: 12px 16px;
    font-weight: 800;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
    color: var(--accent);
}

.node-item {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 0.85rem;
}

.node-item:hover    { background: var(--hover); }
.node-item.active   { background: var(--accent-light); }

.node-label  { flex: 1; font-weight: 600; }
.node-region { font-size: 0.7rem; color: var(--text-soft); }

.node-active-mark  { color: #4CAF50; font-size: 0.75rem; font-weight: 700; }
.node-switch-hint  { color: var(--accent-blue); font-size: 0.75rem; }

.node-panel-footer {
    padding: 8px 16px;
    font-size: 0.65rem;
    color: var(--text-soft);
    border-top: 1px solid var(--border);
    text-align: center;
}

/* ── Тост-уведомления ────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--text);
    color: white;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    z-index: 9000;
    animation: fadeInOut 3.5s ease forwards;
    max-width: 320px;
}

.toast-error { background: var(--accent); }
.toast-info  { background: var(--accent-blue); }

/* ── Кнопка выхода ───────────────────────────────────────── */
#btnLogout {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--text-soft);
    padding: 4px;
    border-radius: 6px;
    transition: color 0.2s, background 0.2s;
    flex-shrink: 0;
}

#btnLogout:hover {
    color: var(--accent);
    background: var(--accent-light);
}

/* ── Мобильная адаптация ─────────────────────────────────── */
@media (max-width: 700px) {
    .node-btn { bottom: 80px; }

    .node-panel {
        bottom: 138px;
        left: 12px;
        right: 12px;
        width: auto;
    }

    .toast {
        bottom: auto;
        top: 16px;
        right: 16px;
        left: 16px;
        max-width: none;
    }
}

/* ── Поиск пользователей ─────────────────────────────────── */
.sidebar-search {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    position: relative;
}

.sidebar-search input {
    width: 100%;
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-family: inherit;
    font-size: 0.85rem;
    background: var(--bg);
    transition: border-color 0.2s;
}

.sidebar-search input:focus {
    outline: none;
    border-color: var(--accent);
}

.search-results {
    position: absolute;
    left: 12px;
    right: 12px;
    top: calc(100% - 4px);
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
    z-index: 200;
    overflow: hidden;
}

.search-result-item {
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: background 0.15s;
}

.search-result-item:hover { background: var(--hover); }

.search-open-hint {
    font-size: 0.72rem;
    color: var(--accent);
    font-weight: 700;
    flex-shrink: 0;
}

.search-loading,
.search-not-found {
    padding: 14px 16px;
    font-size: 0.85rem;
    color: var(--text-soft);
    text-align: center;
}

/* Подсказка когда нет контактов */
.sidebar-empty {
    padding: 16px;
    font-size: 0.8rem;
    color: var(--text-soft);
    text-align: center;
    line-height: 1.6;
}