/* ==========================================================================
   CHAT — стили чата: список чатов, дискуссия, сообщения, ввод, цитаты,
   превью файлов, кнопка прокрутки
   ========================================================================== */

/* CHAT-MAIN (список чатов) */
.icon {
    width: 100%;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-bottom: 1px solid #2c2c2c;
}

.icon:hover {
    background: #2a2a2a;
}

/* Правая колонка (чаты) */
.chatList {
    flex: 1;
    overflow-y: auto;
    padding: 1.6rem .6rem 10rem 0;
    margin-left: 2rem;
}

.chatItem {
    flex: 0 0 32.8%;
    border: 1px solid #E8E8E8;
    cursor: pointer;
    border-radius: 12px;
    box-sizing: border-box;
}
.chatItem h5{
    margin: 0 0 .6rem;
    line-height: 1.3;
}
.chatItem p{
    color:#444449;
    margin: 0 0 .6rem;
    font-size: 14px;
    line-height: 1.2;
}

.chatItemImg{flex: 0 0 33.3%}
.chatItemImg img{
    border-radius: 12px 0 0 12px;
}
.chatItemTxt{
    padding: .4rem .6rem .4rem 1.4rem;
}
.chatItemAdd{
    background-color: #F1F1F1;
    border-radius: 12px 0 0 12px;
}
.chatItemAdd:before,
.chatItemAdd:after{
    content: "";
    position: absolute;
    width: 1px;
    height: 70px;
    background-color: #C6C6C6;
}
.chatItemAdd:after{
    transform: rotate(90deg);
}

.chatAlert{
    padding: 1rem;
    color: #000;
    background-color: #C0C2C8;
    border-radius: 10px;
    margin-bottom: 5rem;
    h6{
        font-size: 18px;
        margin: .3rem 0;
    }
    a{
        color: #1B612A;
    }
    p{
        margin: .6rem 0 0 0;
        line-height: 1.2;
    }
    .chatAlertBtn{
        position: relative;
        width: 40px;
        height: 40px;
        &::after{
            content: "";
            position: absolute;
            inset: 50% auto 0 -.6rem;
            width: 1px;
            height: 4rem;
            background-color: #AEB1B8;
            transform: translateY(-50%);
        }
    }
}
/* \ CHAT-MAIN */

/* CHAT-DISCUSSION */
div.chatMsgsDiscus{
    min-height: 90vh;
    margin-left: 1rem;
}
.chatMsgsDiscus .chatMsgStat{margin-bottom: 0}
.chatUserMsg {
    margin: 1rem 0;
}
.chatUserMsgTxt{
    position: relative;
    padding: 1rem;
    border-radius: 10px;
    background-color: #fff;
    border: 1px solid #E4E4E4;
    box-sizing: border-box;
}

.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%;
}
.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;
}
.\'::after,
.\'::before{
    display: none;
}
.\'{
    display: block;
    margin: .5rem 0;
    padding: .2rem .5rem;
    font-size: 14px;
    background-color: var(--grnlht);
    border-left: 2px solid var(--cgrn);
    color: var(--c19);
}
.chatUserMsgMedia{
    max-height: 30svh;
    overflow: hidden;
    margin: .6rem 0;
    border-radius: 4px;
}
.chatUserMsgMedia,
.chatUserMsgMedia img{
    display: block;
    width: 100%;
}
span.chatUserMsgMedia img{
    border-radius: 0;
}
/* \ CHAT-DISCUSSION */

/*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*/

/* CHAT-CHANNEL-MSG */
.chatDiv{
    overflow-y: auto;
    padding-bottom: 6rem;
    background-color: #F1F1F1;
}
.chatMsgs{
    width: 400px;
    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;
}

.chatMsgAction{
    position: relative;
    padding: 1rem 0;
}
.chatMsgAction::before{
    content: "";
    position: absolute;
    inset: 0 -1rem 0 -1rem;
    height: 1px;
    background-color: #E8E8E8;
}
.chatMsgActionImgs img{
    width: 30px;
    height: 30px;
    object-fit: cover;
    margin-left: -4px;
    border-radius: 50%;
    border:1px solid #fff;
}
.chatMsgActionImgs img:first-child{
    margin-left: 0;
}
.chatMsgActionArrw{
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}
.chatMsgActionArrw::before{
    content: "";
    position: absolute;
    right: 1rem;
    width: 6px;
    height: 6px;
    border: 1px solid;
    border-color: transparent transparent var(--cgrn) var(--cgrn);
    transform: rotate(-135deg);
}
/* \ CHAT-CHANNEL-MSG */

/* Цитаты, ответы, баннер ответа */
.quote-link {
    display: block;
    border-left: 3px solid #4caf50;
    padding-left: 10px;
    margin: 5px 0 10px 0;
    background-color: #f9f9f9;
    color: #555;
    font-style: italic;
    cursor: pointer;
    text-decoration: none;
    border-radius: 0 4px 4px 0;
    padding-top: 4px;
    padding-bottom: 4px;
}
.quote-link:hover {background-color: #e8f5e9}

.reply-btn {
    border: none;
    background: none;
    color: #888;
    cursor: pointer;
}
.reply-btn:hover {color: #4caf50}
#replyBanner{
    inset: -80px auto auto 61px;
    height: 80px;
    min-width:30%;
    display:none; background-color:#f0f0f0; padding:8px 12px; border-radius:8px; margin-bottom:10px;
}
#replyBannerText{
    white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width: 300px;
}

/* Превью прикрепляемого файла */
#chatPreviewContainer{
    position: absolute;
    top: -120px;
    right: 0;
    display: block;
    min-width: 275px;
    height: 90px;
    background: #fff;
    padding: .6rem;
    border-radius: 10px;
}
#imagePreview{
    max-height: 80px; border-radius: 8px; border: 1px solid #ccc; padding: 2px;
}
#previewLoader{
    position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,0.7); display: none; align-items: center; justify-content: center; font-size: 11px; color: #333; font-weight: bold;
}
#removePreviewBtn{
    background-color: #ff4444; color: #fff; padding: 6px 12px; border-radius: 4px; display: none;
}
#uploadFileBtn{
    display: none; padding: 6px 12px; background: #28a745; color: #fff; border-radius: 4px;
}

/* ==========================================================================
   SMART SCROLL DOWN BUTTON & REPLIES NAVIGATOR
   ========================================================================== */
.chatScrollDownBtn {
    position: absolute;
    right: 24px;
    bottom: 84px;
    z-index: 10;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: #ffffff;
    color: #4a4a52;
    border: 1px solid #e1e3e8;
    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;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
}

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

.chatScrollDownBtn:active {
    transform: translateY(0) scale(0.95);
}

.chatScrollDownBtn.has-replies {
    background-color: #ffffff;
    border-color: #2e55c9;
    color: #2e55c9;
}

.chatRepliesBadge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    background-color: #e53935;
    color: #ffffff;
    font-family: Arial, sans-serif;
    font-size: 11px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 6px rgba(229, 57, 53, 0.4);
    animation: badgePop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes highlightReply {
    0% {
        background-color: rgba(76, 175, 80, 0.35);
        box-shadow: 0 0 0 4px rgba(76, 175, 80, 0.2);
    }
    50% {
        background-color: rgba(76, 175, 80, 0.18);
        box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.1);
    }
    100% {
        background-color: transparent;
        box-shadow: none;
    }
}

.highlight-reply {
    animation: highlightReply 2.2s cubic-bezier(0.25, 1, 0.5, 1);
    border-radius: 8px;
}

/* Адаптив чата */
@media screen and (max-width: 720px){
    .chatUserWrite{
        height: auto;
        min-height: 74px;
        padding: 0.8rem 0.5rem;
        padding-bottom: max(0.8rem, env(safe-area-inset-bottom, 0px));
        transform: none !important;
    }
    #userWrite{
        font-size: 16px !important;
    }
    .chatMsgs{
        width: 84%;
    }
}
