body {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
    margin: 0;
    overflow: hidden;
}

.header {
    background: #007bff;
    color: white;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
}

.header a {
    color: white;
    text-decoration: none;
    margin: 0 15px;
}

.burger-menu {
    display: none;
    font-size: 24px;
    cursor: pointer;
}

.nav-links {
    display: flex;
    gap: 20px;
    margin: 0 auto;
    max-width: 1280px;
    width: 100%;
    padding: 0 5px;
}

.nav-links .profile-link {
    margin-left: auto;
}

.main-container {
    flex: 1;
    display: flex;
    gap: 20px;
    max-width: 1280px;
    margin: 0 auto;
    width: 100%;
}

.sidebar {
    width: 100%;
    background: #fff;
    padding: 15px 0;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

.chat-container {
    display: none;
    flex: 1;
    flex-direction: column;
    background: white;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    position: relative;
}

.user-list-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    padding: 0 15px 10px 20px;
    border-bottom: 1px solid #ddd;
}

.user-chat-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    padding: 0 15px 10px 10px;
    border-bottom: 1px solid #ddd;
}

.user-header img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.user-toolbar {
    display: flex;
    gap: 10px;
    padding: 10px 15px;
    border-bottom: 0px solid #ddd;
    justify-content: center;
}

.user-toolbar button {
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
}

.user-toolbar button:hover {
    background: #f1f1f1;
}

.user-toolbar button.active {
    background: #007bff;
    color: white;
}

.room-switcher {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.room-switcher-icon {
    cursor: pointer;
    font-size: 20px;
}

.user-list-container {
    flex: 1;
    overflow-y: auto;
    position: relative;
    padding: 15px;
}

.user-list-container::-webkit-scrollbar,
.messages::-webkit-scrollbar {
    width: 5px;
}

.user-list-container::-webkit-scrollbar-thumb,
.messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 5px;
}

.user-list-container::-webkit-scrollbar-thumb:hover,
.messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

.user-list-container::-webkit-scrollbar-track,
.messages::-webkit-scrollbar-track {
    background: transparent;
}

.list-group-item {
    border-left: none;
    border-right: none;
    padding: 15px;
    font-size: 14px;
    margin-right: 5px;
    cursor: pointer;
    transition: background 0.2s;
}

.list-group-item:hover {
    background: #f8f9fa;
}

.list-group-item.active {
    background: #007bff !important;
    border-radius: 7px;
    color: white !important;
}

.ai-user {
    order: -1;
    background: #f8f9fa !important;
    color: #666;
    font-style: italic;
}

.messages {
    flex-grow: 1;
    overflow-y: auto;
    border: 1px solid #ddd;
    padding: 10px;
    margin-right: 5px;
    height: calc(100vh - 220px);
    scroll-behavior: smooth; /* Плавная прокрутка */
    overscroll-behavior: contain; /* Улучшение поведения на мобильных */
}

.messages p {
    margin: 5px 0;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 5px;
    word-break: break-word;
}

.messages p:last-child {
    scroll-margin-bottom: 20px;
}

.message-input {
    position: relative;
    margin-top: 15px;
}

.message-input .input-group-text {
    cursor: pointer;
}

.emoji-picker {
    display: none;
    position: absolute;
    bottom: 50px;
    left: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 5px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    padding: 10px;
    width: fit-content;
    z-index: 999;
}

.emoji-picker button {
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
}

.back-button {
    background: none;
    border: none;
    font-size: 25px;
    font-family: system-ui;
    color: #007bff;
    cursor: pointer;
    display: none;
}

.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 10000;
}

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 10px;
    width: 300px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.close-modal {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    line-height: 1;
}

@media (max-width: 767px) {
    .burger-menu {
        display: block;
    }

    .nav-links {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        background: #007bff;
        padding: 15px;
        gap: 15px;
    }

    .nav-links.open {
        display: flex;
    }

    .chat-container {
        display: none;
        height: calc(100vh - 105px);
        width: 100%;
    }

    .chat-container.active {
        display: flex !important;
    }

    .sidebar:not(.hidden) {
        display: flex;
        width: 100%;
    }

    .sidebar.hidden {
        display: none;
    }

    .back-button {
        display: block;
    }

    .main-container {
        margin-top: 60px;
        padding: 0;
        height: calc(100vh - 100px);
    }

    #message-input {
        height: 50px !important;
        padding: 12px !important;
        font-size: 16px !important;
    }

    .message-input .btn {
        height: 50px !important;
        min-width: 50px !important;
    }

    .message-input .btn i {
        font-size: 20px !important;
    }
}

@media (min-width: 768px) {
    .main-container {
        padding: 20px;
        margin-top: 60px;
        height: calc(100vh - 100px);
    }

    .sidebar {
        width: 28%;
    }

    .chat-container {
        display: flex;
    }

    .back-button {
        display: none !important;
    }
}

.ai-message {
    color: #666;
    font-style: italic;
}

#registerModal {
    display: none;
}

/* Новые стили для статусов */
.status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: 8px;
    vertical-align: middle;
}

.status-indicator.online { background: #28a745; }
.status-indicator.typing { background: #ffc107; }
.status-indicator.offline { background: #6c757d; }

.status-text {
    font-size: 0.8em;
    color: #6c757d;
    font-weight: normal;
}

.status-text.online { color: #28a745; }
.status-text.typing { color: #ffc107; }
.status-text.offline { color: #6c757d; }