/* ============================================================
   MESSAGES PAGE
   ============================================================ */
.messages-page{
    background: #f0f4f8;
    overflow: hidden;
    padding-top: 64px;
}
.messages-page .site-header{ position: sticky; top: 0; z-index: 100; }

/* Support chat button */
.msg-support-btn{ display:none; }\n
/* Pinned support dialog row */
.dialog-item--support-pin{
    background: #f0f5fa;
    border-bottom: none;
}
.dialog-item--support-pin:hover{ background: #e5eef7; }
.dialog-item--support-pin.dialog-item--active{ background: #ddeaf5; border-right: 3px solid #1a5276; }
.dialog-list__sep{
    height: 1px; background: #e4ecf3; margin: 0 14px 4px;
}

.msg-shell{
    display: grid;
    grid-template-columns: 280px 1fr 300px;
    height: calc(100vh - 64px);
    overflow: hidden;
    border-top: 1px solid #e8edf2;
}

/* ===== Dialog list ===== */
.msg-list{
    display: flex; flex-direction: column;
    background: #fff; border-right: 1px solid #e8edf2;
    overflow: hidden;
}
.msg-list__head{ padding: 16px 14px 10px; flex-shrink: 0; }
.msg-list__title{ font-size: 1.05rem; font-weight: 800; color: #1a1a2e; margin-bottom: 10px; }
.msg-list__search{ position: relative; margin-bottom: 10px; }
.msg-list__search input{
    width: 100%; padding: 8px 12px 8px 34px;
    border: 1.5px solid #e8edf2; border-radius: 10px;
    font-size: .82rem; color: #333; background: #f6f8fa;
    transition: border-color .2s;
    font-family: inherit;
}
.msg-list__search input:focus{ outline: none; border-color: #1a5276; }
.msg-list__search svg{
    position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
    color: #aaa; pointer-events: none;
}
.msg-list__tabs{ display: flex; gap: 2px; background: #f0f4f8; border-radius: 9px; padding: 3px; }
.msg-list-tab{
    flex: 1; text-align: center; padding: 5px 6px;
    border-radius: 7px; border: none; background: none;
    font-size: .74rem; font-weight: 600; color: #888; cursor: pointer; transition: all .15s;
    display: flex; align-items: center; justify-content: center; gap: 4px; font-family: inherit;
}
.msg-list-tab--active{ background: #fff; color: #1a5276; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.msg-list-tab__badge{
    background: #e8740c; color: #fff; font-size: .6rem; font-weight: 800;
    padding: 1px 5px; border-radius: 20px; min-width: 14px; text-align: center;
}

.dialog-list{ flex: 1; overflow-y: auto; }
.dialog-list::-webkit-scrollbar{ width: 4px; }
.dialog-list::-webkit-scrollbar-track{ background: transparent; }
.dialog-list::-webkit-scrollbar-thumb{ background: #dde3ea; border-radius: 2px; }

.dialog-item{
    display: flex; gap: 10px; padding: 12px 14px;
    cursor: pointer; border-bottom: 1px solid #f4f6f9;
    transition: background .15s; position: relative;
}
.dialog-item:hover{ background: #f6f9fc; }
.dialog-item--active{ background: #eaf0f6; border-right: 3px solid #1a5276; }
.dialog-item--unread .dialog-item__name{ font-weight: 700; }
.dialog-item--unread .dialog-item__preview{ color: #333; font-weight: 500; }
.dialog-item__avatar{
    width: 42px; height: 42px; border-radius: 10px;
    flex-shrink: 0; position: relative; overflow: visible;
    display: flex; align-items: center; justify-content: center;
}
.dialog-item__avatar img{ width: 100%; height: 100%; border-radius: 10px; object-fit: cover; }
.dialog-item__avatar--text{
    color: #fff; font-weight: 800; font-size: .85rem; border-radius: 10px;
    width: 42px; height: 42px; display: flex; align-items: center; justify-content: center;
}
.dialog-item__avatar--support{ background: #1a5276; }
.dialog-item__online{
    width: 10px; height: 10px; background: #27ae60; border: 2px solid #fff;
    border-radius: 50%; position: absolute; bottom: -1px; right: -1px;
}
.dialog-item__body{ flex: 1; min-width: 0; }
.dialog-item__head{ display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 2px; }
.dialog-item__name{ font-size: .86rem; color: #1a1a2e; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dialog-item__time{ font-size: .7rem; color: #aaa; flex-shrink: 0; }
.dialog-item__preview{ font-size: .78rem; color: #999; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 2px; }
.dialog-item__order-tag{
    font-size: .68rem; color: #1a5276; background: #eaf0f6;
    padding: 2px 6px; border-radius: 4px; display: inline-block;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
}
.dialog-item__badge{
    background: #e8740c; color: #fff; font-size: .62rem; font-weight: 800;
    padding: 1px 6px; border-radius: 20px; min-width: 16px; text-align: center;
    position: absolute; right: 12px; bottom: 12px;
}

/* ===== Chat panel ===== */
.msg-chat{
    display: flex; flex-direction: column;
    background: #f6f8fa; overflow: hidden;
}

.chat-header{
    display: flex; align-items: center; gap: 12px;
    padding: 12px 18px; background: #fff; border-bottom: 1px solid #e8edf2;
    flex-shrink: 0;
}
.chat-header__back{
    display: none; background: none; padding: 4px; cursor: pointer; color: #1a5276;
}
.chat-header__avatar{
    width: 40px; height: 40px; border-radius: 9px; overflow: hidden; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 800; font-size: .84rem;
}
.chat-header__avatar img{ width: 100%; height: 100%; object-fit: cover; }
.chat-header__info{ flex: 1; }
.chat-header__name{ font-size: .95rem; font-weight: 700; color: #1a1a2e; }
.chat-header__status{ font-size: .76rem; color: #27ae60; }
.chat-header__actions{ display: flex; align-items: center; gap: 8px; }
.chat-header__menu{ position: relative; }

.chat-context-menu{
    position: absolute; top: calc(100% + 6px); right: 0;
    background: #fff; border: 1px solid #e8edf2; border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.1); min-width: 180px;
    z-index: 50; overflow: hidden; display: none;
}
.chat-context-menu.open{ display: block; }
.chat-context-menu button{
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 11px 16px; background: none; border: none; font-size: .85rem;
    color: #333; cursor: pointer; font-family: inherit;
}
.chat-context-menu button:hover{ background: #f0f4f8; }
.chat-context-menu button.danger{ color: #e74c3c; }

.chat-order-banner{
    display: flex; align-items: center; gap: 10px;
    background: #fff7f0; border-bottom: 1px solid #fde8d8;
    padding: 8px 18px; font-size: .82rem; color: #b7600c; flex-shrink: 0;
}
.chat-order-banner a{ color: #e8740c; font-weight: 700; }
.chat-order-banner a:hover{ text-decoration: underline; }

.chat-messages{
    flex: 1; overflow-y: auto; padding: 16px 18px;
    display: flex; flex-direction: column; gap: 4px;
}
.chat-messages::-webkit-scrollbar{ width: 4px; }
.chat-messages::-webkit-scrollbar-track{ background: transparent; }
.chat-messages::-webkit-scrollbar-thumb{ background: #dde3ea; border-radius: 2px; }

.chat-date-sep{
    text-align: center; font-size: .72rem; color: #aaa; font-weight: 600;
    padding: 8px 0; position: relative;
}
.chat-date-sep::before, .chat-date-sep::after{
    content: ''; position: absolute; top: 50%; width: calc(50% - 44px);
    height: 1px; background: #e8edf2;
}
.chat-date-sep::before{ left: 0; }
.chat-date-sep::after{ right: 0; }

.chat-msg{ display: flex; align-items: flex-end; gap: 8px; margin-bottom: 4px; }
.chat-msg--new{ margin-top: 8px; }
.chat-msg--out{ flex-direction: row-reverse; }
.chat-msg__avatar{
    width: 28px; height: 28px; border-radius: 8px;
    overflow: hidden; flex-shrink: 0; align-self: flex-end;
}
.chat-msg__avatar img{ width: 100%; height: 100%; object-fit: cover; }
.chat-msg__avatar--spacer{ width: 28px; flex-shrink: 0; }

.chat-msg__bubble{
    max-width: 65%; padding: 10px 14px; border-radius: 14px;
    font-size: .86rem; line-height: 1.55; color: #333;
    background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.chat-msg--in .chat-msg__bubble{ border-bottom-left-radius: 4px; }
.chat-msg--out .chat-msg__bubble{
    background: #1a5276; color: #fff; border-bottom-right-radius: 4px;
}

/* Typing indicator */
.chat-msg__bubble--typing{
    padding: 14px 18px; display: flex; align-items: center; gap: 4px;
}
.chat-msg__bubble--typing span{
    width: 7px; height: 7px; border-radius: 50%; background: #aaa;
    display: inline-block; animation: typing-dot 1.2s infinite;
}
.chat-msg__bubble--typing span:nth-child(2){ animation-delay: .2s; }
.chat-msg__bubble--typing span:nth-child(3){ animation-delay: .4s; }
@keyframes typing-dot{
    0%, 60%, 100%{ transform: translateY(0); opacity: .5; }
    30%{ transform: translateY(-5px); opacity: 1; }
}

.chat-msg__time{
    font-size: .68rem; white-space: nowrap; flex-shrink: 0;
    align-self: flex-end; margin-bottom: 4px;
    color: #aaa;
}
.chat-msg--out .chat-msg__time{ color: #aaa; }
.chat-msg__check{ margin-left: 3px; color: #27ae60; }

/* Attachments */
.chat-attachment{ margin-top: 6px; display: flex; flex-direction: column; gap: 5px; }
.chat-attachment__item{
    display: flex; align-items: center; gap: 8px;
    background: rgba(0,0,0,.04); border-radius: 8px; padding: 7px 10px;
    font-size: .8rem; color: #1a5276;
}
.chat-msg--out .chat-attachment__item{ background: rgba(255,255,255,.15); color: #e8f4ff; }

/* Inline uploaded images & file links */
.chat-img-wrap{ margin-top: 4px; }
.chat-img{
    max-width: 260px; max-height: 300px; border-radius: 10px;
    display: block; cursor: zoom-in; object-fit: cover;
    border: 1px solid rgba(0,0,0,.08);
}
.chat-file-attach{
    display: flex; align-items: center; gap: 7px;
    background: rgba(0,0,0,.04); border-radius: 8px; padding: 7px 10px;
    font-size: .8rem; margin-top: 4px;
}
.chat-msg--out .chat-file-attach{ background: rgba(255,255,255,.15); }
.chat-file-attach a{ color: inherit; text-decoration: underline; word-break: break-all; }
.chat-attachment__thumb{
    width: 80px; height: 60px; border-radius: 8px;
    background: #f0f4f8 center/cover; border: 1px solid #eee; flex-shrink: 0;
}

/* Offer card */
.chat-offer-card{
    background: #fff; border: 1.5px solid #e8740c; border-radius: 12px;
    padding: 16px; max-width: 300px; margin-top: 6px;
}
.chat-msg--out .chat-offer-card{ max-width: 300px; }
.chat-offer-card__title{ font-size: .78rem; font-weight: 700; color: #666; margin-bottom: 8px; text-transform: uppercase; letter-spacing: .04em; }
.chat-offer-card__price{ font-size: 1.3rem; font-weight: 800; color: #1a1a2e; margin-bottom: 10px; }
.chat-offer-card__items{ display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.chat-offer-card__items span{
    display: flex; justify-content: space-between;
    font-size: .8rem; color: #666;
}
.chat-offer-card__items strong{ color: #1a1a2e; font-weight: 600; }
.chat-offer-card__actions{ display: flex; gap: 8px; }

/* Input area */
.chat-input-area{
    background: #fff; border-top: 1px solid #e8edf2;
    padding: 10px 14px 12px; flex-shrink: 0; position: relative;
}
.emoji-panel{
    position: absolute; bottom: calc(100% + 4px); left: 14px;
    background: #fff; border: 1.5px solid #e0e7ef; border-radius: 12px;
    padding: 8px; box-shadow: 0 4px 20px rgba(0,0,0,.12); z-index: 200;
}
.emoji-panel__grid{ display: flex; flex-wrap: wrap; gap: 1px; max-width: 292px; }
.emoji-panel__grid button{
    width: 36px; height: 36px; font-size: 1.15rem;
    background: none; border: none; border-radius: 6px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .1s; line-height: 1; font-family: inherit;
}
.emoji-panel__grid button:hover{ background: #f0f4f8; }
.chat-file-preview{ display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chat-file-item{
    display: flex; align-items: center; gap: 5px;
    background: #eaf0f6; border-radius: 8px; padding: 4px 8px;
    font-size: .76rem; color: #1a5276;
}
.chat-file-item button{ background: none; cursor: pointer; color: #888; padding: 0 2px; }
.chat-input-wrap{ display: flex; align-items: flex-end; gap: 8px; }
.chat-tool-btn{
    background: none; border: none; padding: 8px; cursor: pointer;
    color: #aaa; flex-shrink: 0; border-radius: 8px; transition: color .15s, background .15s;
    display: flex; align-items: center; justify-content: center;
}
.chat-tool-btn:hover{ color: #1a5276; background: #f0f4f8; }
.chat-input-field{
    flex: 1; background: #f6f8fa; border: 1.5px solid #e8edf2; border-radius: 12px;
    padding: 4px 4px; transition: border-color .2s;
}
.chat-input-field:focus-within{ border-color: #1a5276; }
.chat-input-field textarea{
    width: 100%; padding: 7px 12px;
    background: none; border: none; resize: none; font-size: .88rem;
    color: #333; font-family: inherit; line-height: 1.5;
    max-height: 120px; min-height: 38px; display: block;
}
.chat-input-field textarea:focus{ outline: none; }
.chat-input-field textarea::placeholder{ color: #bbb; }
.chat-send-btn{
    width: 42px; height: 42px; border-radius: 12px; border: none;
    background: #1a5276; color: #fff; cursor: pointer; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: background .2s, transform .1s;
}
.chat-send-btn:hover{ background: #154360; }
.chat-send-btn:active{ transform: scale(.94); }
.chat-input-hint{ font-size: .7rem; color: #ccc; margin-top: 6px; text-align: right; }

/* ===== Info sidebar ===== */
.msg-info{
    display: flex; flex-direction: column;
    background: #fff; border-left: 1px solid #e8edf2; overflow-y: auto;
}
.msg-info::-webkit-scrollbar{ width: 4px; }
.msg-info::-webkit-scrollbar-thumb{ background: #dde3ea; border-radius: 2px; }
.msg-info__head{
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px; border-bottom: 1px solid #f0f4f8; flex-shrink: 0;
    font-size: .9rem; font-weight: 700; color: #1a1a2e;
}
.msg-info__close{
    background: none; border: none; cursor: pointer; color: #aaa; padding: 4px; border-radius: 6px;
}
.msg-info__close:hover{ color: #333; background: #f0f4f8; }
.msg-info__avatar-big{
    width: 72px; height: 72px; border-radius: 14px;
    margin: 20px auto 12px; display: block;
    color: #fff; font-weight: 800; font-size: 1.1rem;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.msg-info__avatar-big img{ width: 100%; height: 100%; object-fit: cover; border-radius: 14px; }
.msg-info__name{
    text-align: center; font-size: .95rem; font-weight: 800; color: #1a1a2e;
    padding: 0 16px; margin-bottom: 4px;
}
.msg-info__rating{
    display: flex; align-items: center; justify-content: center; gap: 4px;
    font-size: .8rem; color: #888; margin-bottom: 10px;
}
.msg-info__meta{
    display: flex; flex-wrap: wrap; gap: 6px; justify-content: center;
    padding: 0 14px 14px; border-bottom: 1px solid #f0f4f8;
}
.msg-info__actions{
    display: flex; flex-direction: column; gap: 8px; padding: 14px 14px;
    border-bottom: 1px solid #f0f4f8;
}
.msg-info__section{ padding: 14px 14px; }
.msg-info__section strong{ font-size: .82rem; color: #888; font-weight: 600; display: block; margin-bottom: 10px; text-transform: uppercase; letter-spacing: .04em; }
.msg-info__files{ display: flex; flex-direction: column; gap: 6px; }
.msg-info__file{
    display: flex; align-items: center; gap: 8px;
    font-size: .8rem; color: #333; padding: 6px 0;
    border-bottom: 1px solid #f4f6f9;
}
.msg-info__file:last-child{ border: none; }
.msg-info__file svg{ color: #1a5276; flex-shrink: 0; }
.msg-info__file small{ display: block; color: #aaa; font-size: .7rem; }

/* ===== Mobile ===== */
@media(max-width: 1020px){
    .msg-shell{ grid-template-columns: 260px 1fr; }
    .msg-info{ display: none; position: fixed; right: 0; top: 66px; bottom: 0; width: 280px; z-index: 200; box-shadow: -4px 0 20px rgba(0,0,0,.1); }
    .msg-info--open{ display: flex; }
}
@media(max-width: 760px){
    .msg-shell{ grid-template-columns: 1fr; grid-template-rows: 1fr; }
    .msg-list{
        grid-column: 1; position: fixed; left: 0; top: 66px; bottom: 0; width: 100%;
        z-index: 50; transform: translateX(-100%); transition: transform .25s;
    }
    .msg-chat{
        grid-column: 1;
    }
    .msg-list--mobile-open{
        transform: translateX(0);
    }
    .msg-chat--mobile-open{
        /* default visible */
    }
    .chat-header__back{ display: flex; }
    .chat-msg__bubble{ max-width: 80%; }
}

/* Mobile back-to-list button (shown in chat panel when no dialog selected) */
.chat-mobile-back{
    display: none;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #f5f8fc;
    border: none;
    border-bottom: 1px solid #e8edf2;
    cursor: pointer;
    font-size: .88rem;
    font-weight: 600;
    color: #1a5276;
    width: 100%;
    text-align: left;
}
.chat-mobile-back:hover{ background: #eaf0f6; }
@media(max-width: 760px){
    .chat-mobile-back{ display: flex; }
}
