/* Messaging module */

.msg-shell {
    display: grid;
    grid-template-columns: minmax(240px, 300px) 1fr;
    min-height: 560px;
    padding: 0;
    overflow: hidden;
}

.msg-sidebar {
    border-right: 1px solid var(--ent-border);
    display: flex;
    flex-direction: column;
    background: #fafafa;
    min-height: 560px;
}

.msg-sidebar__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: 1rem 1rem .75rem;
    border-bottom: 1px solid var(--ent-border);
}

.msg-sidebar__title {
    margin: 0;
    font-size: .95rem;
    font-weight: 600;
}

.msg-sidebar__list {
    flex: 1;
    overflow-y: auto;
    padding: .5rem;
}

.msg-empty {
    color: var(--ent-text-muted);
    font-size: .875rem;
    padding: 1rem;
    margin: 0;
}

.msg-conv {
    display: flex;
    gap: .75rem;
    align-items: flex-start;
    padding: .7rem .75rem;
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    transition: background .15s ease;
}

.msg-conv:hover {
    background: rgba(31, 41, 55, 0.05);
}

.msg-conv.is-active {
    background: #fff;
    box-shadow: var(--ent-shadow);
    border: 1px solid var(--ent-border);
}

.msg-conv__icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: .85rem;
    background: #e5e7eb;
    color: #374151;
}

.msg-conv__icon--public {
    background: #dbeafe;
    color: #1d4ed8;
}

.msg-conv__icon--group {
    background: #dcfce7;
    color: #15803d;
}

.msg-conv__icon--direct {
    background: #f3f4f6;
    color: #4b5563;
}

.msg-conv__body {
    min-width: 0;
    flex: 1;
}

.msg-conv__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
}

.msg-conv__name {
    font-weight: 600;
    font-size: .875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msg-conv__badge {
    background: #1f2937;
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 .35rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.msg-conv__preview {
    display: block;
    font-size: .75rem;
    color: var(--ent-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: .15rem;
}

.msg-thread {
    display: flex;
    flex-direction: column;
    min-height: 560px;
    background: #fff;
}

.msg-thread__empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    color: var(--ent-text-muted);
    padding: 2rem;
}

.msg-thread__empty i {
    font-size: 2rem;
    opacity: .5;
}

.msg-thread__head {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--ent-border);
}

.msg-thread__title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
}

.msg-thread__meta {
    margin: .2rem 0 0;
    font-size: .8rem;
    color: var(--ent-text-muted);
}

.msg-thread__messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: .75rem;
    background:
        linear-gradient(180deg, #f9fafb 0%, #ffffff 40%);
    max-height: 420px;
    min-height: 320px;
}

.msg-bubble {
    max-width: min(72%, 520px);
    align-self: flex-start;
}

.msg-bubble--mine {
    align-self: flex-end;
}

.msg-bubble__sender {
    font-size: .7rem;
    font-weight: 600;
    color: var(--ent-text-secondary);
    margin-bottom: .2rem;
    padding-left: .15rem;
}

.msg-bubble__body {
    background: #f3f4f6;
    border: 1px solid var(--ent-border);
    border-radius: 12px 12px 12px 4px;
    padding: .65rem .85rem;
    font-size: .9rem;
    line-height: 1.45;
    word-break: break-word;
}

.msg-bubble--mine .msg-bubble__body {
    background: #1f2937;
    border-color: #1f2937;
    color: #fff;
    border-radius: 12px 12px 4px 12px;
}

.msg-bubble__time {
    font-size: .65rem;
    color: var(--ent-text-muted);
    margin-top: .25rem;
    padding: 0 .15rem;
}

.msg-bubble--mine .msg-bubble__time {
    text-align: right;
}

.msg-composer {
    display: flex;
    gap: .75rem;
    align-items: flex-end;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--ent-border);
    background: #fff;
}

.msg-composer textarea {
    resize: none;
    min-height: 56px;
}

.msg-composer__send {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    white-space: nowrap;
    height: 42px;
}

@media (max-width: 768px) {
    .msg-shell {
        grid-template-columns: 1fr;
    }

    .msg-sidebar {
        min-height: auto;
        max-height: 240px;
        border-right: 0;
        border-bottom: 1px solid var(--ent-border);
    }

    .msg-thread {
        min-height: 420px;
    }

    .msg-bubble {
        max-width: 88%;
    }
}
