* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: Arial, sans-serif;
}

body {
    height: 100vh;
    display: flex;
    flex-direction: column;
    margin: 0; /* Добавляем для надёжности */
}

#app {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.header {
    background-color: #022175;
    padding: 7px 15px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.content {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
    background-color: white;
}

/* Мобильный режим (по умолчанию) */
.list, .conversation, .details {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    background-color: white;
    overflow-y: auto;
    display: none;
}

.list {
    background-color: #f9faff;
}

.conversation {
    overflow-y: clip;
}

.details {
    width: 90%;
    z-index: 100;
    right: 0;
    left: auto;
    box-shadow: 0 0 15px #777;
}

.mode-list-visible .list {
    display: block;
}

.mode-conversation-visible .conversation {
    display: block;
}

.mode-details-visible .details {
    display: block;
}

.mode-details-visible .conversation {
    display: block;
}

/* Десктопный режим */
@media (min-width: 800px) {
    .content {
        flex-direction: row;
    }

    .list, .conversation {
        position: relative;
        display: block !important;
        height: 100%;
    }

    .list {
        width: 30%;
        border-right: 1px solid #e0e0e0;
    }

    .conversation {
        width: 70%;
    }

    .details {
        width: 50%;
        right: 0;
        left: auto;
        box-shadow: -5px 0 5px rgba(0,0,0,0.2);
        display: none;
    }

    .mode-details-visible .details {
        display: block;
    }

    .btn-back {
        display: none !important;
    }
}

/* Стили для списка чатов */
.list-header {
    position: sticky;
    top: 0;
    background-color: white;
    padding: 10px;
    border-bottom: 1px solid #e0e0e0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-box {
    flex: 1;
}

.search-box input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.list-actions {
    display: flex;
    gap: 10px;
}

.list-actions button {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f5f5f5;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
}

.chat-item {
    padding: 5px;
    border-bottom: 1px solid #ddd;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between; /* Добавлено для распределения пространства */
}


.chat-item:hover {
    background-color: #fffbeb;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #ddd;
    margin-right: 10px;
}


.chat-info {
    overflow: hidden;
    flex-grow: 1; /* Добавлено для заполнения доступного пространства */
}

.chat-name {
    font-weight: bold;
    margin-bottom: 3px;
    white-space: nowrap;
}

.chat-last-message {
    font-size: 0.9em;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-type-icon {
    margin-right: 5px;
    color: #666;
}

/* Стили для бейджей */
.chat-badges {
    display: flex;
    gap: 5px;
    margin-left: 10px;
}


.badge {
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    font-size: 8pt;
    font-weight: bold;
    color: white;
}

.badge-gray {
    background-color: #ccc;
    color: #000;
}

.badge-red {
    background-color: #ff6b6b;
    color: #fff;
}

.badge-blue {
    background-color: #1326ff;
    color: #fff;
}

/* Стили для переписки */
.conversation-header {
    position: sticky;
    top: 0;
    background-color: white;
    padding: 10px 15px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    z-index: 10;
}

.conversation-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #ddd;
    margin-right: 10px;
}

.conversation-title {
    flex: 1;
    font-weight: bold;
}

.conversation-menu {
    position: relative;
    cursor: pointer;
    padding: 8px;
}

.conversation-dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    min-width: 200px;
    z-index: 1000;
}

.conversation-dropdown-menu.show {
    display: block;
}

.dropdown-item {
    display: block;
    padding: 8px 16px;
    color: #333;
    text-decoration: none;
}

.dropdown-item:hover {
    background-color: #f5f5f5;
}

.messages-container {
    padding: 15px;
    overflow-y: auto;
    height: calc(100% - 120px);

    background: url('/images/msg_back7.jpg') repeat;
}

.message {
    margin-bottom: 15px;
    display: flex;
}

.message-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background-color: #eee;
    margin-right: 10px;
}

.message-content {
    max-width: 70%;
}

.message-header {
    font-size: 0.8em;
    color: #aaa;
    margin-bottom: 3px;
    padding-right: 10px;
}

.message-header-name {
    cursor: pointer;
    color: #333;
    font-weight: bold;
}

.message-header-username {
    font-weight: normal;
}

.message-text {
    background-color: #e3f2fd;
    padding: 8px 12px;
    border-radius: 15px;
    display: inline-block;
    text-align: left;
    box-shadow: 0 1px 1px #bbb;
    font-size: 0.8em;
}

.message-outgoing {
    justify-content: flex-end;
}

.message-outgoing .message-content {
    text-align: right;
}

.message-outgoing .message-text {
    background-color: #dcf8c6;
}

.input-area {
    position: sticky;
    bottom: 0;
    background-color: white;
    padding: 10px;
    border-top: 1px solid #e0e0e0;
}

.input-container {
    display: flex;
    align-items: center;
}

.attach-button {
    padding: 15px;
    background-color: #f5f5f5;
    border: 1px solid #ccc;
    border-radius: 30px;
    margin-right: 10px;
    cursor: pointer;
    font-size: 1em;
}

.message-input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 9px;
    resize: none;
    max-height: 100px;
}

.send-button {
    margin-left: 10px;
    padding: 15px;
    background-color: #4CAF50;
    color: white;
    font-size: 1em;
    border: none;
    border-radius: 30px;
    cursor: pointer;
}

/* Стили для деталей */
.details-header {
    position: sticky;
    top: 0;
    background-color: white;
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
    font-weight: bold;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.details-content {
    padding: 15px;
}

.detail-item {
    margin-bottom: 15px;
}

.detail-title {
    font-weight: bold;
    margin-bottom: 5px;
    color: #555;
}

.detail-value {
    padding-left: 10px;
}

.participants-list {
    list-style: none;
}

.participant {
    display: flex;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

.participant-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #ddd;
    margin-right: 10px;
}

/* Стиль для кнопки установки */
#installButton {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 10px 15px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    display: none;
    z-index: 1000;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.topbar-item {
    color: #777;
    text-decoration: none;
    padding: 0 10px;
}


.popup-menu {
    position: absolute;
    top: calc(100% + 7px);
    left: 0;
    background-color: #fff;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 1000;
    min-width: 150px;
    padding: 5px 0;
    font-size: 12pt;
    font-weight: normal;
}

.popup-item {
    display: block;
    padding: 8px 15px;
    color: #000;
    text-decoration: none;
    white-space: nowrap;
}

.popup-item:hover {
    background-color: #aaccff;
}

.popup-item i {
    margin-right: 8px;
}


.btn-back {
    display: inline-block;
    padding: 12px 12px;
    background-color: transparent;
    border: 1px solid #eee;
    border-radius: 7px;
    color: #000;
    margin-right: 5px !important;
    cursor: pointer;
}
.btn-back:hover {
    background-color: #f5f5f5;
}
