
/* ================= MODAL ================= */
#messageModal{
    display:none;
    position:fixed;
    inset:0;
    z-index:9999;
    background:rgba(15,15,30,.70);
    backdrop-filter:blur(5px);
    padding:20px;
}

#messageModal.show{
    display:flex;
    align-items:center;
    justify-content:center;
}

.msgModal{
    width:min(800px,100%);
    max-height:85vh;
    background:#fff;
    border-radius:24px;
    overflow:hidden;
    box-shadow:0 30px 80px rgba(0,0,0,.25);
    display:flex;
    flex-direction:column;
}

/* ================= HEADER ================= */
.msgHeader{
    padding:10px 15px;
    background:linear-gradient(135deg,#31064c,#4d24ab);
    color:#fff;
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:20px;
}

.headLeft{
    display:flex;
    align-items:center;
    gap:16px;
}

.headIcon{
    width:30px;
    height:30px;
    border-radius:16px;
    background:rgba(255,255,255,.16);
    display:flex;
    align-items:center;
    justify-content:center;
    font-size:18px;
}

.headText h2{
    margin:0;
    font-size:18px;
    font-weight:700;
}

.headText p{
    margin:4px 0 0;
    opacity:.92;
    font-size:12px;
}

.closeBtn{
    width:30px;
    height:30px;
    border:none;
    border-radius:50%;
    background:rgba(255,255,255,.18);
    color:#fff;
    font-size:26px;
    cursor:pointer;
    margin-right:10px;
}


/* ================= BODY ================= */
.msgContent{
    padding:20px;
    display:grid;
    grid-template-columns:320px 1fr;
    gap:30px;
    overflow:hidden;
}

/* ================= PANEL ================= */
.panel{
    border:1px solid #ececf3;
    margin-bottom:15px;
    border-radius:22px;
    background:#fff;
    overflow:hidden;
    display:flex;
    flex-direction:column;
}

.panelHead{
    padding:12px 18px;
    border-bottom:1px solid #ececf3;
    background:#fafafe;
}

.panelHead h3{
    margin:10px 0 6px;
    font-size:14px;
    color:#222;
}

.panelHead p{
    margin:0;
    font-size:11px;
    color:#777;
    line-height:1.5;
}

.panelBody{
    padding:14px;
    display:flex;
    flex-direction:column;
    gap:16px;
}

.tag{
    display:inline-block;
    padding:5px 10px;
    border-radius:999px;
    font-size:11px;
    font-weight:700;
}

.green{
    background:#dcfce7;
    color:#166534;
}

.purple{
    background:#f3e8ff;
    color:#6b21a8;
}

/* ================= COMPOSE ================= */
textarea{
    width:100%;
    min-height:120px;
    resize:vertical;
    border:1px solid #ddddee;
    border-radius:16px;
    padding:12px;
    font-size:12px;
    line-height:1.6;
    font-family:inherit;
    outline:none;
}

textarea:focus{
    border-color:#8b5cf6;
    box-shadow:0 0 0 4px rgba(139,92,246,.10);
}

.uploadBox{
    display:flex;
    flex-direction:column;
    gap:8px;
}

.uploadBox label{
    font-size:13px;
    color:#666;
    font-weight:600;
}

.uploadBox input{
    border:1px solid #ddddee;
    border-radius:14px;
    padding:10px;
}

.sendBtn{
    height:32px;
    border:none;
    border-radius:14px;
    background:#0b0c0b;
    color:#fff;
    font-weight:700;
    font-size:14px;
    cursor:pointer;
}

.sendBtn:hover{
    background:#330748;
}

.sendBtn:disabled{
    opacity:.75;
    cursor:not-allowed;
}

/* ================= HISTORY ================= */
.historyPanel{
    min-height:400px;
}

.msgList{
    padding:18px;
    overflow:auto;
    display:flex;
    flex-direction:column;
    gap:16px;
}

/* ================= MESSAGE CARD ================= */
.msgRow{
    border:1px solid #ededf5;
    border-radius:18px;
    padding:16px;
    display:flex;
    flex-direction:column;
    gap:14px;
}

.msgTop{
    display:flex;
    justify-content:space-between;
    gap:14px;
    align-items:center;
}

.msgIndex{
    padding:4px 10px;
    border-radius:999px;
    background:#f3f0ff;
    color:#5b21b6;
    font-size:12px;
    font-weight:700;
}

.msgDate{
    font-size:12px;
    color:#777;
}

.msgText{
    font-size:14px;
    color:#000000;
    line-height:1.65;
    white-space:pre-wrap;
    word-break:break-word;
    margin-left:10px;
    margin-top : 15px;
}

.msgMedia{
    display:flex;
    flex-wrap:wrap;
    gap:10px;
}

.msgImg{
    max-width:220px;
    max-height:180px;
    object-fit:cover;
    border-radius:14px;
    border:1px solid #eee;
    cursor:pointer;
}

.fileBox{
    display:inline-flex;
    align-items:center;
    gap:4px;
    padding:6px 8px;
    border-radius:8px;
    background:#f3f0ff;
    color:#5b21b6;
    text-decoration:none;
    font-size:12px;
    font-weight:600;
}

.msgFoot{
    display:flex;
    justify-content:flex-end;
}

.deleteBtn{
    border:none;
    border-radius:12px;
    padding:6px 12px;
    background:#ef4444;
    color:#fff;
    font-weight:700;
    cursor:pointer;
}

.deleteBtn:hover{
    background:#dc2626;
}

/* ================= EMPTY ================= */
.empty{
    text-align:center;
    padding:60px 20px;
    color:#777;
}

/* ================= TOAST ================= */
.toast{
    position:fixed;
    top:22px;
    right:22px;
    z-index:10050;
    min-width:220px;
    max-width:360px;
    padding:14px 18px;
    border-radius:14px;
    color:#fff;
    font-weight:700;
    opacity:0;
    transform:translateY(-10px);
    transition:.22s;
}

.toast.show{
    opacity:1;
    transform:translateY(0);
}

.toast.success{ background:#16a34a; }
.toast.error{ background:#dc2626; }

/* ================= VIEWER ================= */
.imgViewer{
    position:fixed;
    inset:0;
    z-index:10060;
    background:rgba(0,0,0,.82);
    display:none;
    align-items:center;
    justify-content:center;
    padding:24px;
}

.imgViewer.show{
    display:flex;
}

.imgViewer img{
    max-width:95%;
    max-height:92%;
    border-radius:18px;
}

/* ================= MOBILE ================= */
@media(max-width:980px){

    .msgContent{
        grid-template-columns:1fr;
        overflow:auto;
    }

    .historyPanel{
        min-height:420px;
    }
}

@media(max-width:640px){

    #messageModal{
        padding:12px;
    }

    .headText h2{
        font-size:20px;
    }

    .headText p{
        font-size:13px;
    }

    .headIcon{
        width:44px;
        height:44px;
    }

    .msgHeader{
        padding:16px;
    }

    .msgContent{
        padding:14px;
        gap:14px;
    }
}
