/* CHAT-CHANNEL-MSG */
.chatDiv{
    overflow-y: auto;
    padding-bottom: 6rem;
    background-color: #F1F1F1;
    height: 100%;
    flex: 1 1 auto;
    min-height: 0;
    box-sizing: border-box;
}
.chatMsgs{
    width: 420px;
    margin-left: 10%;
}
.chatMsgImg{
    display: flex;
    width: 100%;
    border-radius: 12px 12px 0 0;
    overflow: hidden;
    border: 1px solid #E4E4E4;
}
.chatMsgImg img{
    width: 100%;
}
.chatMsgTxt{
    position: relative;
    padding: 1rem;
    border-radius: 0 0 12px;
    background-color: #fff;
}
.chatMsgTxt::after{
    content: "";
    position: absolute;
    left: -12px;
    bottom: 0;
    width: 0;
    height: 0;
    border:8px solid;
    border-color: transparent #fff #fff transparent;
}
.chatMsgTxt p{
    margin: .8rem 0;
    text-align: justify;
    color: var(--c19);
}
.chatMsgStat{
    justify-content: end;
    margin: 1.2rem 0;
    color:#666878;
}

/* CHAT-DISCUSSION */
div.chatMsgsDiscus{
    min-height: 90vh;
    margin-left: 1rem;
    padding-right: 20px;
    margin-top: 5rem;
}
.chatMsgsDiscus .chatMsgStat{margin-bottom: 0}
.xcvh.chatTopStripe{
    inset:0 0 auto 97px;
    background-color: #fff;
    padding: 1.6rem;
    height: 70px;
    box-sizing: border-box;
}
.chatUserMsg {
    display: flex;
    gap:.5rem;
    margin: 1rem 0;
}
.chatUserMsgTxt{
    position: relative;
    padding: 1rem;
    margin-right: -60px;
    border-radius: 10px;
    background-color: #fff;
    border: 1px solid #E4E4E4;
    box-sizing: border-box;
}
.chatUserMsgTxt p{
    overflow-wrap: anywhere;
}
.chatUserMsgTxt p:first-of-type{margin-top: 0}
.chatUserMsg .chatUserMsgImg{
    position: sticky;
    z-index: 2;
    inset: 8rem auto 6rem auto;
    margin: auto 0 .6rem 0;
}
.chatUserMsg .chatUserMsgImg img{
    border-radius: 50%;
    width: 50px;
    height: 50px;
    min-width: 50px;
    min-height: 50px;
    object-fit: cover;
}
.chatUserMsg .chatUserMsgImg::after{
    content: "";
    position: absolute;
    inset: auto -14px 15px auto;
    width: 8px;
    height: 8px;
    background-color: #fff;
    transform: rotate(45deg);
    border: 1px solid;
    border-color: transparent transparent #E4E4E4 #E4E4E4;
    border-radius: 0 0 0 4px;
}
.btnBack{padding: .5rem;}

/* Кнопка трех точек и контекстное меню комментария */
.msg-menu-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin-left: 6px;
}

.msg-menu-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    padding: 2px 4px;
    margin: 0;
    border-radius: 6px;
    color: #9a9a9a;
    cursor: pointer;
    line-height: 1;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.msg-menu-trigger:hover,
.msg-menu-wrap.active .msg-menu-trigger {
    color: #2b2b2b;
    background-color: #f0f1f3;
}

.msg-menu-trigger svg {
    display: block;
}

/* Выпадающее меню действий */
.msg-menu-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.08);
    min-width: 230px;
    max-width: calc(100vw - 32px);
    z-index: 1000;
    overflow: hidden;
    animation: msgMenuFadeIn 0.15s ease-out;
}

.msg-menu-wrap.active .msg-menu-dropdown {
    display: flex;
    flex-direction: column;
}

@keyframes msgMenuFadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.msg-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 18px;
    background: transparent;
    border: none;
    color: #404040;
    font-size: 14px;
    font-family: inherit;
    font-weight: 400;
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.15s ease, color 0.15s ease;
    box-sizing: border-box;
}

.msg-menu-item:hover {
    background-color: #f6f7f9;
    color: #1a1a1a;
}

.msg-menu-item:active {
    background-color: #edf0f4;
}

.msg-menu-item + .msg-menu-item {
    border-top: 1px solid #f0f1f4;
}

.msg-menu-icon {
    flex-shrink: 0;
    color: #737373;
    transition: color 0.15s ease;
}

.msg-menu-item:hover .msg-menu-icon {
    color: #222222;
}

/* Общий контейнер-обертка для выравнивания */
.rw {
    display: inline-flex;
    align-items: center;
}

/* Базовое состояние панели реакций */
.chatMsgRcts {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

/* На всякий случай: если внутри тега <b> пусто (кол-во 0), уберем лишние отступы */
.react-btn b:empty {
    display: none;
}
.chatMsgRcts .chatMsgRctsActive {
    background-color: #3255C9;
    color: #AABBE8;
}
.chatMsgRcts button {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2px;
    background-color: #EDEDED;
    border-radius: 14px;
    padding: 2px 6px;
    font-size: 12px;
    color: #5F5F5F;
    cursor: pointer;
    border: none;
    transition: background-color 0.2s, color 0.2s;
}

/* Кнопка перехода к комментариям поста в ленте */
.postMsgAction {
    position: relative;
    border-top: 1px solid #f0f1f4;
    padding-top: .8rem;
    margin-top: .6rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}
.postMsgActionBtn {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    cursor: pointer;
    z-index: 2;
}
.postMsgActionArrw {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-top: 2px solid #1b612a;
    border-right: 2px solid #1b612a;
    transform: rotate(45deg);
    margin-right: 6px;
}

/*USER WRITE*/
.chatUserWrite{
    inset: auto 0 0 0;
    height: 86px;
    padding: 1.6rem 1rem;
    transform: translateY(96px);
    padding-bottom: max(1.6rem, env(safe-area-inset-bottom, 0px));
    background-color: #f3f3f3cc;
    backdrop-filter: blur(10px);
    border-top: 1px solid #DBDBDF;
    box-sizing: border-box;
}
.chatUserWriteImg img{
    width:30px;
    height:30px;
    border-radius: 50%;
}
#userWrite{
    font-size: 16px !important;
    padding: .8rem 3rem .8rem 1rem;
    box-sizing: border-box;
}
#userAddFileBtn{
    right: .3rem;
    top: .6rem;
}
/* \ USER WRITE*/
#replyBanner{
    display:none;
    inset: -61px auto auto 61px;
    height: 60px;
    min-width:30%;
    margin-bottom:10px;
    padding:0 12px;
    background-color:#C5D4C8;
    border-left: 2px solid #21612E;
}
#replyBannerText{
    overflow:hidden;
    white-space:nowrap;
    text-overflow:ellipsis;
}
#chatPreviewContainer{
    position: absolute;
    top: -96px;
    left: 2%;
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    border: 1px solid #E8E8E8;
    z-index: 20;
    transition: opacity 0.2s ease, transform 0.2s ease;
}
#chatPreviewContainer.dn{
    display: none !important;
}
.chatPreviewThumb{
    position: relative;
    width: 100px;
    height: 100px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    background-color: #f0f0f0;
}
#imagePreview{
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
#previewLoader{
    position: absolute;
    inset:0;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(2px);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #21612E;
    font-weight: 700;
    text-align: center;
    padding: 2px;
    line-height: 1.2;
}
#removePreviewBtn{
    position: absolute;
    z-index: 5;
    top: 4px;
    right: 4px;
    width: 30px;
    height: 30px;
    border-radius: 4px;
    background-color: rgba(255 255 255/0.4);
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    line-height: 1;
    transition: background-color 0.2s, transform 0.15s;
    backdrop-filter: blur(6px);
}
#removePreviewBtn:hover{
    background-color: #ff3b30;
    transform: scale(1.1);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.commentsContainer {
    width: 100%;
    display: block;
    margin-top: 1rem;
}

/* Навигация обсуждения: новые ответы и переход в низ страницы. */
.chatRepliesBtn,
.chatDownBtn {
    position: fixed;
    bottom: 110px;
    z-index: 30;
    width: 50px;
    height: 50px;
    border: 1px solid #e1e3e8;
    border-radius: 50%;
    background-color: #fff;
    color: #4a4a52;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    outline: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.chatRepliesBtn { right: 86px; }
.chatDownBtn { right: 28px; }

.chatRepliesBtn:hover,
.chatDownBtn:hover {
    background-color: #f7f8fa;
    color: #1b612a;
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.16);
}

.chatRepliesBtn:active,
.chatDownBtn:active {
    transform: translateY(0) scale(0.95);
}

.chatRepliesBtn.has-unread {
    background-color: #1b612a;
    color: #fff;
}

/* Когда кнопка «вниз» не нужна, ответы занимают её место. */
.chatRepliesBtn.down-btn-hidden { right: 28px; }

.chatUnreadBadge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 8px;
    height: 18px;
    padding: 0 5px;
    border: 2px solid #fff;
    border-radius: 50%;
    background-color: #141414;
    color: #fff;
    font-family: Arial, sans-serif;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.8;
    text-align: center;
    box-shadow: 0 2px 6px rgba(27, 97, 42, 0.4);
}

.chatRepliesBtn.dn,
.chatDownBtn.dn { display: none; }

#commentsBottomLoader,
#commentsTopLoader {
    padding: 1.5rem 1rem;
    text-align: center;
    color: #888;
    font-size: 14px;
}

/* Полноэкранный просмотр изображений (Lightbox) */
.chatAttachedImg,
.chatUserMsg .pt img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    cursor: zoom-in;
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.22s ease, filter 0.22s ease;
    display: block;
}

.chatAttachedImg:hover,
.chatUserMsg .pt img:hover {
    filter: brightness(0.96);
    transform: scale(1.015);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14);
}

.channelLightbox {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    cursor: zoom-out;
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s ease;
}

.channelLightbox.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.channelLightboxBackdrop {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 15, 29, 0.88);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    cursor: zoom-out;
}

.channelLightboxContent {
    position: relative;
    max-width: 95vw;
    max-height: 92vh;
    max-height: 92dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    user-select: none;
    cursor: zoom-out;
}

.channelLightboxImg {
    max-width: 94vw;
    max-height: 88vh;
    max-height: 88dvh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 25px 60px -10px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1);
    transform: scale(0.92);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    display: block;
}

.channelLightbox.active .channelLightboxImg {
    transform: scale(1);
}

.channelLightboxClose {
    position: fixed;
    top: max(16px, env(safe-area-inset-top, 16px));
    right: max(16px, env(safe-area-inset-right, 16px));
    z-index: 10;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    font-size: 28px;
    line-height: 1;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    transition: background-color 0.2s ease, transform 0.15s ease;
}

.channelLightboxClose:hover {
    background: rgba(255, 255, 255, 0.32);
    transform: scale(1.08);
}

.channelLightboxClose:active {
    transform: scale(0.95);
}

@media (min-width: 1250px){
    .chatMsgs {
        /* width: 400px; */
        transform: translateX(20%);
    }
}
@media (min-width: 1025px){
    .chatMsgs {
        /* width: 400px; */
        transform: translateX(20%);
    }
}

/* Мобильный адаптив для обсуждений и чата */
@media screen and (max-width: 720px){
    .chatDiv {
        padding-top: 63px;
        padding-bottom: 0;
    }
    div.chatMsgsDiscus {
        min-height: auto;
        margin: 0;
        padding-right: 0;
        padding-bottom: 5rem;
    }
    .chatMsgs,
    .chatUserMsg {
        width: 95%;
        margin-left: auto;
        margin-right: auto;
    }
    .chatUserWrite {
        height: auto;
        min-height: 74px;
        padding: 0.8rem 0.6rem;
        padding-bottom: max(0.8rem, env(safe-area-inset-bottom, 0px));
        transform: none !important;
    }
    #userWrite {
        font-size: 16px !important;
        padding: 0.7rem 2.8rem 0.7rem 0.8rem;
    }
    #replyBanner {
        left: 10px;
        right: 10px;
        min-width: auto;
    }
    .chatUserMsgTxt{
        margin-right: -18px;
    }
    .xcvh.chatTopStripe{
        left:0;
        height: 60px;
        padding: 1rem;
    }
    .chatRepliesBtn,
    .chatDownBtn {
        bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    }
}

@media (max-width: 500px){
    .chatMsgs,
    .chatUserMsg {
        width: auto;
    }
    .chatUserWrite {
        padding: .6rem 1rem;
    }
}
@media (max-width: 600px) {
    .channelLightboxImg {
        max-width: 96vw;
        max-height: 85vh;
        max-height: 85dvh;
        border-radius: 6px;
    }
    .channelLightboxClose {
        width: 42px;
        height: 42px;
        font-size: 24px;
    }
    .chatUserMsgTxt {
        margin-right: 0;
    }
    .chatMsgTxt::after{
        display: none;
    }
    .chatMsgTxt,
    .chatMsgImg {
        box-sizing: border-box;
    }
    .chatMsgDiv{
        padding: 0 1rem;
    }
    .chatUserMsg {
        padding: 0 1rem;
    }
    .chatMsgTxt{
        border-radius: 0 0 12px 12px;
    }
    .chatUserMsg .chatUserMsgImg img {
        width: 30px;
        height: 30px;
        min-width: 30px;
        min-height: 30px;
    }
    #replyBanner {
        right: 1rem;
        left: 55px;
    }
    #replyBanner div{
        max-width: 80%;
    }
    #chatPreviewContainer {
        top: -106px;
        left: 62px;
    }
    #head{
        margin-bottom: .8rem;
    }
    #head h1{
        letter-spacing: 10%;
        text-transform: uppercase;
    }
    #head a{
        width: 40px;
        height: 40px;
        border: 1px solid #E7E7E8;
        color:#12121A;
    }
    .chatTopStripe{
        padding: 1rem 1rem 0 1rem;
        background-color: transparent;
        backdrop-filter: blur(8px);
    }

}
