/**
 * Messages / Chat – mobile-first, minimal, responsive
 */

/* ---- Container ---- */
.msg-app {
    display: flex;
    flex-direction: row;
    margin-bottom: 2rem;
    background: #f8f9fa;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

/* Desktop: fixed height range so list/chat don't overlap footer */
@media (min-width: 992px) {
    .msg-app {
        min-height: 420px;
        max-height: calc(100vh - 200px);
    }
}

/* ---- List pane ---- */
.msg-list-pane {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
    background: #fff;
    border-right: 1px solid #e9ecef;
}

@media (min-width: 992px) {
    .msg-list-pane {
        max-width: 380px;
        flex-shrink: 0;
    }
}

.msg-list-header {
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e9ecef;
    background: #fff;
    box-shadow: 0 1px 0 0 #e9ecef;
}

.msg-list-header h5 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: #1a1a1a;
}

.msg-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.msg-list-item {
    display: block;
    padding: 0.875rem 1.25rem;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid #f1f3f5;
    transition: background 0.15s ease;
}

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

.msg-list-item.selected-chat {
    background: rgba(var(--primary-rgb, 55, 125, 255), 0.08);
    border-left: 3px solid var(--primary, #377dff);
}

.msg-list-item .media {
    align-items: center;
}

.msg-list-item .avatar {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
}

.msg-list-item .avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.msg-list-item .badge-status {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    border: 2px solid #fff;
    border-radius: 50%;
}

.msg-list-item .avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.msg-list-item .name {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 2px;
}

.msg-list-item .preview {
    font-size: 0.8125rem;
    color: #6c757d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msg-list-item .meta {
    flex-shrink: 0;
    text-align: right;
}

.msg-list-item .time {
    font-size: 0.75rem;
    color: #868e96;
    display: block;
    margin-bottom: 4px;
}

.msg-list-item .unread {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    font-size: 0.6875rem;
    font-weight: 600;
    color: #fff;
    background: var(--primary, #377dff);
    border-radius: 10px;
}

.msg-list-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    color: #868e96;
}

.msg-list-empty .icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.msg-list-empty h5 {
    font-size: 1rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.25rem;
}

/* ---- Chat pane ---- */
.msg-chat-pane {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    background: #fff;
}

.msg-chat-pane .chat-box-wrap {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    padding: 0;
}

.msg-chat-pane .chat-header {
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e9ecef;
    background: #fff;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 1px 0 0 #e9ecef;
}

.msg-chat-pane .chat-header .msg-back-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #495057;
    font-size: 1.25rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.msg-chat-pane .chat-header .msg-back-btn:hover {
    background: #f1f3f5;
    color: #1a1a1a;
}

.msg-chat-pane .chat-list-wrap {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* padding: 1rem; */
}

.msg-chat-pane .chat-footer {
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    z-index: 5;
    padding: 0.75rem 1rem;
    border-top: 1px solid #e9ecef;
    background: #fff;
    box-shadow: 0 -1px 0 0 #e9ecef;
}

.msg-chat-pane .chat-footer .input-group {
    border-radius: 24px;
    background: #f1f3f5;
    border: 1px solid #e9ecef;
}

.msg-chat-pane .chat-footer .form-control {
    border: none;
    background: transparent;
    padding-left: 1.25rem;
}

.msg-chat-pane .chat-coversation {
    max-width: 60%;
}

.msg-chat-pane .chat-coversation .text {
    padding: 0.625rem 1rem;
    border-radius: 16px;
    font-size: 0.9375rem;
    line-height: 1.45;
}

.msg-chat-pane .chat-coversation:not(.right) .text {
    background: #f1f3f5;
    color: #1a1a1a;
    border-bottom-left-radius: 4px;
}

.msg-chat-pane .chat-coversation.right .text {
    background: var(--primary, #377dff);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.msg-chat-pane .chat-coversation .time {
    font-size: 0.6875rem;
    color: #868e96;
    margin-top: 4px;
}

/* Empty state in chat pane */
.msg-chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    background: #f8f9fa;
}

.msg-chat-empty .icon {
    font-size: 3.5rem;
    color: var(--primary, #377dff);
    opacity: 0.7;
    margin-bottom: 1rem;
}

.msg-chat-empty h5 {
    font-size: 1rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.25rem;
}

.msg-chat-empty p {
    font-size: 0.875rem;
    color: #868e96;
    margin: 0;
}

/* ---- Mobile: list first, then chat; height fits viewport above footer ---- */
@media (max-width: 991.98px) {
    .msg-app {
        position: relative;
        min-height: calc(100svh - 160px);
        max-height: calc(100vh - 180px);
        max-height: calc(100svh - 160px);
        margin-bottom: 2rem;
    }

    .msg-list-pane {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1;
        transition: transform 0.25s ease, opacity 0.25s ease;
    }

    .msg-chat-pane {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        height: 100%;
        min-height: 280px;
        max-height: 100%;
        z-index: 0;
        transform: translateX(100%);
        opacity: 0;
        pointer-events: none;
        transition: transform 0.25s ease, opacity 0.25s ease;
        background: #fff;
        display: flex;
        flex-direction: column;
    }

    .msg-app.msg-mobile-chat-open .msg-list-pane {
        transform: translateX(-100%);
        opacity: 0;
        pointer-events: none;
    }

    .msg-app.msg-mobile-chat-open .msg-chat-pane {
        transform: translateX(0);
        opacity: 1;
        pointer-events: auto;
        z-index: 2;
    }

    /* Mobile chat inner: header + scrollable messages + footer */
    .msg-chat-pane .chat-box-wrap {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
        height: 100%;
        overflow: hidden;
    }

    .msg-chat-pane .chat-list-wrap {
        flex: 1 1 0;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .msg-chat-pane .chat-header .msg-back-btn {
        display: inline-flex;
    }
}

/* ---- Chat info sidebar (existing) ---- */
.msg-chat-pane .chat-info-wrap {
    height: 100%;
}

.msg-chat-pane .chat-info-wrap .chat-info {
    width: 100%;
    max-width: 320px;
}
