/* Основные глобальные стили */
:root {
    --primary-color: #0088cc;
    --secondary-color: #2a2f32;
    --sidebar-bg: #131c21;
    --chat-bg: #0d1418;
    --border-color: #2d3134;
    --text-primary: #e1e1e1;
    --text-secondary: #a6a8ab;
    --message-out-bg: #0088cc;
    --message-in-bg: #2a2f32;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--chat-bg);
    color: var(--text-primary);
}

.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* Сайдбар */
.sidebar {
    width: 360px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: relative;
    z-index: 100; /* Важно: сайдбар должен быть выше */
}

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

.sidebar-search {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.search-input {
    width: 100%;
    padding: 12px 15px;
    background: #2a2f32;
    border: none;
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 14px;
}

.search-input:focus {
    outline: none;
    background: #33383b;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
}

.chat-list::-webkit-scrollbar {
    width: 6px;
}

.chat-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

/* Главная область чата */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--chat-bg);
    position: relative;
    z-index: 1;
}

.chat-header {
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.chat-avatar {
    position: relative;
}

.avatar-circle {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
    color: white;
}

.online-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background: #00d046;
    border: 2px solid var(--sidebar-bg);
    border-radius: 50%;
}

.chat-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 3px;
}

.chat-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Сообщения */
.messages-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm29 22c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zM32 63c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm57-13c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-9-21c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM60 91c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM35 41c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM12 60c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2z' fill='%232d3134' fill-opacity='0.1' fill-rule='evenodd'/%3E%3C/svg%3E");
}

.message-bubble {
    max-width: 65%;
    padding: 8px 12px;
    border-radius: 18px;
    margin-bottom: 4px;
    word-wrap: break-word;
    position: relative;
    animation: fadeIn 0.3s ease-out;
}

.message-bubble.outgoing {
    background: var(--message-out-bg);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    color: white;
}

.message-bubble.incoming {
    background: var(--message-in-bg);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.message-content {
    line-height: 1.4;
}

.message-meta {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-top: 4px;
    font-size: 11px;
    opacity: 0.8;
}

.message-time {
    margin-right: 5px;
}

.message-status {
    font-size: 12px;
}

/* Форма ввода */
.message-input-container {
    background: var(--sidebar-bg);
    border-top: 1px solid var(--border-color);
    padding: 15px 20px;
}

.message-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.message-attachments {
    display: flex;
    gap: 5px;
}

.attach-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.attach-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.message-input {
    flex: 1;
    background: #2a2f32;
    border: none;
    border-radius: 20px;
    padding: 12px 20px;
    color: var(--text-primary);
    font-size: 15px;
    resize: none;
    min-height: 25px;
    max-height: 150px;
    font-family: inherit;
}

.message-input:focus {
    outline: none;
    background: #33383b;
}

.send-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.send-btn:hover {
    background: #0077b3;
}

/* Анимации */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Адаптивность */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: 60vh;
    }

    .message-bubble {
        max-width: 85%;
    }
}

    /* Страница чата - исправленная версия */
.chat-page {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    position: relative;
    z-index: 1;
}

.chat-header {
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.chat-header-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.chat-header-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 5px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-type {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    text-transform: uppercase;
}

.chat-header-actions {
    display: flex;
    gap: 10px;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.btn-icon:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.online-status {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
}

.online-status.online {
    background: rgba(0, 208, 70, 0.2);
    color: #00d046;
}

.online-status.offline {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    min-height: 0;
    position: relative;
    z-index: 1;
}

.message-input-container {
    flex-shrink: 0;
    background: var(--sidebar-bg);
    border-top: 1px solid var(--border-color);
    padding: 15px 20px;
    position: relative;
    z-index: 10;
}

/* В начало main.css */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden; /* Предотвращает двойной скролл */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--chat-bg);
    color: var(--text-primary);
}

/* Исправление перекрытия элементов */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--chat-bg);
    color: var(--text-primary);
    position: relative;
}

/* Убедитесь, что элементы не перекрывают друг друга */
* {
    box-sizing: border-box;
}

/* Исправление для пустых сообщений */
.empty-messages {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px 20px;
}

.empty-messages i {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.empty-messages p {
    margin: 0 0 10px 0;
}

.empty-messages-hint {
    font-size: 14px;
    opacity: 0.7;
}

/* Сообщения в чате */
.message-bubble {
    max-width: 65%;
    padding: 8px 12px;
    border-radius: 18px;
    margin-bottom: 4px;
    word-wrap: break-word;
    position: relative;
    animation: fadeIn 0.3s ease-out;
}

.message-bubble.outgoing {
    background: var(--message-out-bg);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    color: white;
}

.message-bubble.incoming {
    background: var(--message-in-bg);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    color: white;
}

.message-sender {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
    opacity: 0.8;
}

.message-content {
    line-height: 1.4;
    word-break: break-word;
}

.message-meta {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-top: 4px;
    font-size: 11px;
    opacity: 0.8;
}

.message-time {
    margin-right: 5px;
}

.message-edited {
    margin-left: 5px;
    font-size: 10px;
}

/* Форма ввода сообщений */
.message-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.message-attachments {
    display: flex;
    gap: 5px;
}

.attach-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.attach-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.message-input {
    flex: 1;
    background: #2a2f32;
    border: none;
    border-radius: 20px;
    padding: 12px 20px;
    color: var(--text-primary);
    font-size: 15px;
    resize: none;
    min-height: 25px;
    max-height: 150px;
    font-family: inherit;
    line-height: 1.4;
}

.message-input:focus {
    outline: none;
    background: #33383b;
}

.send-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.send-btn:hover {
    background: #0077b3;
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
    font-size: 12px;
    color: var(--text-secondary);
}

.typing-dots {
    display: flex;
    gap: 3px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { opacity: 0.3; }
    30% { opacity: 1; }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}