
/* ============================================
   RESET & ROOT VARIABLES
============================================ */
*{
    margin:0;
    padding:0;
    box-sizing:border-box;
    -webkit-tap-highlight-color:transparent;
    scrollbar-width:thin;
    scrollbar-color:rgba(255,255,255,0.2) transparent;
}

:root{
    --primary-color:#25D366;
    --secondary-color:#128C7E;
    --bg-color:#111B21;
    --sidebar-bg:#202C33;
    --chat-bg:#0B141A;
    --message-bg:#005C4B;
    --incoming-message-bg:#202C33;
    --border-color:#2A3942;
    --text-primary:#E9EDEF;
    --text-secondary:#8696A0;
    --hover-bg:#2A3942;
    --danger:#ff4444;
    --white:#ffffff;
    --shadow:0 2px 10px rgba(0,0,0,0.2);
}

html,
body{
    width:100%;
    height:100%;
    overflow:hidden;
    font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;
    background:var(--bg-color);
    color:var(--text-primary);
}

body{
    height:100vh;
    height:100dvh;
}

.hidden{
    display:none !important;
}

img,
video{
    max-width:100%;
}

button,
input,
textarea{
    font-family:inherit;
}

/* ============================================
   SCROLLBAR
============================================ */
::-webkit-scrollbar{
    width:6px;
    height:6px;
}

::-webkit-scrollbar-track{
    background:transparent;
}

::-webkit-scrollbar-thumb{
    background:rgba(255,255,255,0.2);
    border-radius:10px;
}

::-webkit-scrollbar-thumb:hover{
    background:rgba(255,255,255,0.3);
}

/* ============================================
   LOGIN PAGE
============================================ */
.login-page{
    width:100%;
    min-height:100vh;
    min-height:100dvh;
    display:flex;
    align-items:center;
    justify-content:center;
    background:linear-gradient(135deg,var(--secondary-color),var(--primary-color));
    padding:20px;
}

.login-container{
    width:100%;
    max-width:420px;
}

.login-box{
    background:var(--sidebar-bg);
    border-radius:16px;
    padding:35px;
    box-shadow:0 10px 40px rgba(0,0,0,0.35);
}

.logo{
    text-align:center;
    margin-bottom:30px;
}

.logo img{
    width:80px;
    height:80px;
    object-fit:contain;
}

.logo h1{
    margin-top:15px;
    font-size:28px;
    font-weight:700;
}

.tabs{
    display:flex;
    margin-bottom:20px;
    border-bottom:1px solid var(--border-color);
}

.tab{
    flex:1;
    padding:14px;
    background:none;
    border:none;
    color:var(--text-secondary);
    cursor:pointer;
    font-size:15px;
    transition:0.3s;
    border-bottom:2px solid transparent;
}

.tab.active{
    color:var(--primary-color);
    border-bottom-color:var(--primary-color);
}

.tab-content{
    display:none;
}

.tab-content.active{
    display:block;
}

.input-group{
    margin-bottom:18px;
}

.input-group input,
.input-group textarea,
.profile-content input,
.profile-content textarea,
.caption-input{
    width:100%;
    padding:13px 15px;
    border-radius:8px;
    border:1px solid var(--border-color);
    background:var(--chat-bg);
    color:var(--text-primary);
    font-size:14px;
}

.input-group input:focus,
.input-group textarea:focus,
.profile-content input:focus,
.profile-content textarea:focus,
.caption-input:focus,
.search-box input:focus,
#messageInput:focus{
    outline:none;
    border-color:var(--primary-color);
}

.btn-primary,
.btn-secondary,
#phoneLoginBtn{
    border:none;
    border-radius:8px;
    cursor:pointer;
    transition:0.3s;
    font-weight:600;
}

.btn-primary,
#phoneLoginBtn{
    width:100%;
    padding:13px;
    background:var(--primary-color);
    color:#fff;
    font-size:15px;
}

.btn-primary:hover,
#phoneLoginBtn:hover{
    background:var(--secondary-color);
}

.btn-secondary{
    padding:10px 20px;
    background:var(--hover-bg);
    color:#fff;
}

.btn-secondary:hover{
    background:var(--border-color);
}

.error-message{
    display:none;
    margin-top:15px;
    background:var(--danger);
    color:#fff;
    padding:12px;
    border-radius:8px;
    text-align:center;
}

.error-message.show{
    display:block;
}

/* ============================================
   MAIN APP
============================================ */
.app-container{
    width:100%;
    height:100vh;
    height:100dvh;
    display:flex;
    overflow:hidden;
    position:relative;
}

/* ============================================
   SIDEBAR
============================================ */
.sidebar{
    width:400px;
    min-width:400px;
    height:100%;
    background:var(--sidebar-bg);
    border-right:1px solid var(--border-color);
    display:flex;
    flex-direction:column;
    overflow:hidden;
}

.sidebar-header{
    display:flex;
    align-items:center;
    justify-content:space-between;
    padding:14px 16px;
    background:var(--bg-color);
    border-bottom:1px solid var(--border-color);
}

.user-info,
.chat-header-info{
    display:flex;
    align-items:center;
    gap:12px;
}

.avatar,
.avatar-large,
.profile-avatar{
    border-radius:50%;
    object-fit:cover;
}

.avatar{
    width:42px;
    height:42px;
}

.avatar-large{
    width:80px;
    height:80px;
}

.profile-avatar{
    width:120px;
    height:120px;
    border:4px solid var(--primary-color);
}

.header-actions,
.chat-header-actions{
    display:flex;
    align-items:center;
    gap:5px;
}

.icon-btn,
.call-btn,
.slider-btn,
.slider-nav{
    border:none;
    cursor:pointer;
    transition:0.2s;
}

.icon-btn{
    width:40px;
    height:40px;
    border-radius:50%;
    background:none;
    color:var(--text-secondary);
    display:flex;
    align-items:center;
    justify-content:center;
}

.icon-btn:hover{
    background:var(--hover-bg);
}

.search-box{
    padding:10px 15px;
    background:var(--bg-color);
}

.search-box input,
#contactSearchInput{
    width:100%;
    padding:11px 14px;
    border-radius:8px;
    border:1px solid var(--border-color);
    background:var(--sidebar-bg);
    color:var(--text-primary);
}

.chat-list,
.call-list{
    flex:1;
    overflow-y:auto;
}

.chat-item,
.call-item{
    display:flex;
    align-items:center;
    gap:12px;
    padding:12px 16px;
    border-bottom:1px solid rgba(255,255,255,0.04);
    cursor:pointer;
    transition:0.2s;
}

.chat-item:hover,
.call-item:hover,
.chat-item.active{
    background:var(--hover-bg);
}

.chat-item-content{
    flex:1;
    min-width:0;
}

.chat-item-header{
    display:flex;
    justify-content:space-between;
    gap:10px;
    margin-bottom:4px;
}

.chat-item-name{
    font-size:15px;
    font-weight:500;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
}
.message-time {
    font-size: 11px;
    color: var(--text-secondary);
    text-align: right;
    margin-top: 4px;
}
.chat-item-time,
.chat-item-preview,
.chat-status,
.document-size,
.message-time,
.link-preview-desc,
.link-preview-site{
    color:var(--text-secondary);
}

.chat-item-time{
    font-size:11px;
    white-space:nowrap;
}

.chat-item-preview{
    font-size:13px;
    overflow:hidden;
    white-space:nowrap;
    text-overflow:ellipsis;
}

.online-indicator{
    width:10px;
    height:10px;
    border-radius:50%;
    background:var(--primary-color);
}

/* ============================================
   CHAT AREA
============================================ */
.chat-area{
    flex:1;
    display:flex;
    flex-direction:column;
    height:100%;
    background:var(--chat-bg);
    position:relative;
    overflow:hidden;
}

.welcome-screen{
    flex:1;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    text-align:center;
    padding:30px;
}

.welcome-screen h2{
    margin:20px 0 10px;
}

.welcome-screen p{
    color:var(--text-secondary);
}

.chat-container{
    display:flex;
    flex-direction:column;
    width:100%;
    height:100%;
    overflow:hidden;
}

.chat-header{
    display:flex;
    align-items:center;
    justify-content:space-between;
    padding:10px 16px;
    background:var(--bg-color);
    border-bottom:1px solid var(--border-color);
    flex-shrink:0;
    z-index:100;
}

.chat-header:hover{
    background:#1f2c34;
}

.chat-status{
    font-size:12px;
}

.messages-container{
    flex:1;
    overflow-y:auto;
    padding:20px;
    background:#efeae2;
    background-image:url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
    display:flex;
    flex-direction:column;
    gap:2px;
}

.message-input-container{
    display:flex;
    align-items:center;
    gap:10px;
    padding:10px 15px;
    background:var(--bg-color);
    border-top:1px solid var(--border-color);
    flex-shrink:0;
}

#messageInput{
    flex:1;
    padding:12px 15px;
    border-radius:8px;
    border:1px solid var(--border-color);
    background:var(--sidebar-bg);
    color:var(--text-primary);
    font-size:14px;
}

.send-btn.active{
    background:var(--primary-color);
    color:#fff;
}

/* ============================================
   MESSAGE BUBBLES
============================================ */
.message{
    display:flex;
    width:100%;
    margin-bottom:10px;
    animation:messageSlide 0.2s ease;
}

.message.outgoing{
    justify-content:flex-end;
}

@keyframes messageSlide{
    from{
        opacity:0;
        transform:translateY(10px);
    }
    to{
        opacity:1;
        transform:translateY(0);
    }
}

.message-bubble{
    position:relative;
    max-width:75%;
    padding:7px 9px 18px;
    border-radius:8px;
    font-size:14px;
    line-height: 15px;
    text-align: right;
    box-shadow:0 1px 0.5px rgba(11,20,26,.13);
    word-break:break-word;
}

.message.incoming .message-bubble{
    background:#fff;
    color:#111b21;
    border-top-left-radius:0;
}

.message.outgoing .message-bubble{
    background:#d9fdd3;
    color:#111b21;
    border-top-right-radius:0;
}

.message-content{
    white-space:pre-wrap;
    padding-bottom:3px;
}

.forwarded-label{
    font-size:11px;
    font-style:italic;
    color:var(--text-secondary);
    margin-bottom:4px;
}

.message-meta{
    position:absolute;
    bottom:4px;
    right:8px;
    display:flex;
    align-items:center;
    gap:3px;
}

.message-status{
    display:flex;
    align-items:center;
}

.status-read{
    color:#53bdeb;
}

.status-sent{
    color:#8696a0;
}

/* ============================================
   FILES & MEDIA
============================================ */
.message-file{
    margin-top:4px;
    overflow:hidden;
    border-radius:6px;
}

.message-file img,
.message-file video{
    border-radius:6px;
    display:block;
}

.message-file audio{
    width:100%;
}

.message-document{
    display:flex;
    align-items:center;
    gap:12px;
    padding:10px;
    border-radius:8px;
    background:rgba(0,0,0,0.08);
}

.document-icon,
.file-preview-icon{
    width:50px;
    height:50px;
    border-radius:8px;
    background:var(--primary-color);
    display:flex;
    align-items:center;
    justify-content:center;
    flex-shrink:0;
}

.document-info,
.file-preview-info{
    flex:1;
    min-width:0;
}

.document-name,
.file-preview-name{
    overflow:hidden;
    white-space:nowrap;
    text-overflow:ellipsis;
    font-weight:500;
}

.message-image-grid{
    display:grid;
    gap:2px;
    width:320px;
    max-width:100%;
}

.message-image-grid.grid-2{
    grid-template-columns:1fr 1fr;
    grid-auto-rows:180px;
}

.message-image-grid.grid-3{
    grid-template-columns:1fr 1fr;
    grid-template-rows:220px 150px;
}

.message-image-grid.grid-3 .grid-img-wrap:nth-child(1){
    grid-column:1 / -1;
}

.message-image-grid.grid-4{
    grid-template-columns:1fr 1fr;
    grid-template-rows:150px 150px;
}

.grid-img-wrap{
    position:relative;
    overflow:hidden;
    background:#ddd;
}

.grid-img-wrap img{
    width:100%;
    height:100%;
    object-fit:cover;
}

.more-images-overlay{
    position:absolute;
    inset:0;
    background:rgba(0,0,0,0.5);
    color:#fff;
    display:flex;
    align-items:center;
    justify-content:center;
    font-size:28px;
    font-weight:700;
}

/* ============================================
   TYPING INDICATOR
============================================ */
.typing-indicator{
    display:flex;
    align-items:center;
    gap:8px;
    background:var(--incoming-message-bg);
    width:max-content;
    padding:8px 14px;
    border-radius:18px;
}

.typing-text{
    color:var(--primary-color);
    font-size:13px;
}

.typing-dots{
    display:flex;
    gap:4px;
}

.typing-dots span{
    width:6px;
    height:6px;
    border-radius:50%;
    background:var(--primary-color);
    animation:typing 1.4s infinite;
}

.typing-dots span:nth-child(2){
    animation-delay:0.2s;
}

.typing-dots span:nth-child(3){
    animation-delay:0.4s;
}

@keyframes typing{
    0%,60%,100%{
        opacity:0.3;
        transform:translateY(0);
    }
    30%{
        opacity:1;
        transform:translateY(-4px);
    }
}

/* ============================================
   ATTACHMENT MENU
============================================ */
.attachment-menu,
.emoji-picker{
    position:absolute;
    z-index:999;
    animation:popup 0.2s ease;
}

.attachment-menu{
    left:20px;
    bottom:75px;
    background:var(--sidebar-bg);
    border-radius:12px;
    padding:15px;
    display:grid;
    grid-template-columns:repeat(2,1fr);
    gap:15px;
    box-shadow:var(--shadow);
}

.attachment-option{
    display:flex;
    flex-direction:column;
    align-items:center;
    gap:8px;
    padding:10px;
    border-radius:8px;
    cursor:pointer;
}

.attachment-option:hover{
    background:var(--hover-bg);
}

.attachment-icon{
    width:50px;
    height:50px;
    border-radius:50%;
    display:flex;
    align-items:center;
    justify-content:center;
}

.emoji-picker{
    width:320px;
    height:350px;
    right:10px;
    bottom:75px;
    background:var(--sidebar-bg);
    border-radius:12px;
    overflow:hidden;
    box-shadow:var(--shadow);
}

.emoji-grid{
    display:grid;
    grid-template-columns:repeat(8,1fr);
    gap:5px;
    padding:10px;
    overflow-y:auto;
    height:100%;
}

.emoji-item{
    width:32px;
    height:32px;
    display:flex;
    align-items:center;
    justify-content:center;
    cursor:pointer;
    border-radius:4px;
    font-size:22px;
}

.emoji-item:hover{
    background:var(--hover-bg);
}

@keyframes popup{
    from{
        opacity:0;
        transform:translateY(10px);
    }
    to{
        opacity:1;
        transform:translateY(0);
    }
}

/* ============================================
   MODALS
============================================ */
.modal,
.profile-modal,

.image-slider-overlay,
.incoming-call-notification{
    position:fixed;
    inset:0;
    z-index:9999;
    display:flex;
    align-items:center;
    justify-content:center;
}

.modal,
.profile-modal,
.incoming-call-notification{
    background:rgba(0,0,0,0.7);
}

.modal-content,
.profile-box{
    width:90%;
    max-width:500px;
    max-height:90vh;
    background:var(--sidebar-bg);
    border-radius:14px;
    overflow:hidden;
    display:flex;
    flex-direction:column;
}

.modal-header,
.profile-header-modal{
    display:flex;
    align-items:center;
    justify-content:space-between;
    padding:16px 20px;
    border-bottom:1px solid var(--border-color);
    background:var(--bg-color);
}

.modal-body,
.profile-content{
    padding:20px;
    overflow-y:auto;
}

.profile-content{
    display:flex;
    flex-direction:column;
    align-items:center;
    gap:12px;
}

.modal-footer{
    display:flex;
    justify-content:flex-end;
    gap:10px;
    padding:15px 20px;
    border-top:1px solid var(--border-color);
}

.close-btn,
.profile-header-modal button{
    background:none;
    border:none;
    color:#fff;
    font-size:28px;
    cursor:pointer;
}

/* ============================================
   IMAGE LIGHTBOX
============================================ */

.image-slider-overlay{
    background:rgba(0,0,0,0.92);
}


.slider-image{
    max-width:90vw;
    max-height:90vh;
    object-fit:contain;
}

.lightbox-close{
    position:absolute;
    top:20px;
    right:20px;
    width:50px;
    height:50px;
    border:none;
    border-radius:50%;
    background:rgba(255,255,255,0.15);
    color:#fff;
    font-size:30px;
    cursor:pointer;
}

.slider-toolbar{
    position:absolute;
    top:0;
    left:0;
    width:100%;
    padding:15px 20px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    background:linear-gradient(rgba(0,0,0,0.5),transparent);
}

.slider-counter{
    color:#fff;
}

.slider-actions{
    display:flex;
    gap:10px;
}

.slider-btn,
.slider-nav{
    color:#fff;
    background:rgba(255,255,255,0.1);
}

.slider-btn{
    width:40px;
    height:40px;
    border-radius:50%;
}

.slider-nav{
    position:absolute;
    top:50%;
    transform:translateY(-50%);
    width:50px;
    height:50px;
    border-radius:50%;
}

.slider-nav.prev{
    left:20px;
}

.slider-nav.next{
    right:20px;
}

/* ============================================
   VIDEO CALL
============================================ */
.video-call-container{
    position:absolute;
    inset:0;
    z-index:999;
    background:#000;
    display:flex;
    flex-direction:column;
}

.video-header{
    padding:20px;
    text-align:center;
    background:rgba(0,0,0,0.5);
}

.video-grid{
    flex:1;
    position:relative;
}

#remoteVideo{
    width:100%;
    height:100%;
    object-fit:cover;
}

#localVideo{
    position:absolute;
    bottom:20px;
    right:20px;
    width:220px;
    height:160px;
    object-fit:cover;
    border-radius:10px;
    border:2px solid var(--primary-color);
}

.call-controls,
.incoming-call-actions{
    display:flex;
    align-items:center;
    justify-content:center;
    gap:20px;
    padding:20px;
}

.call-btn{
    width:55px;
    height:55px;
    border-radius:50%;
    display:flex;
    align-items:center;
    justify-content:center;
    color:#fff;
    background:var(--hover-bg);
}

.call-btn.end-call,
.call-btn.reject{
    background:#ff4444;
}

.call-btn.accept{
    background:var(--primary-color);
}

.incoming-call-content{
    text-align:center;
}

/* ============================================
   LINK PREVIEW
============================================ */
.chat-link,
.chat-number{
    color:#027eb5;
    text-decoration:none;
}

.chat-link:hover{
    text-decoration:underline;
}

.link-preview-wrapper{
    margin-top:8px;
}

.link-preview-card{
    display:flex;
    flex-direction:column;
    overflow:hidden;
    border-radius:10px;
    text-decoration:none;
    border:1px solid var(--border-color);
    background:rgba(0,0,0,0.08);
}

.link-preview-image{
    width:100%;
    height:150px;
    object-fit:cover;
}

.link-preview-info{
    padding:10px 12px;
}

.link-preview-title{
    font-size:14px;
    font-weight:600;
    margin-bottom:5px;
}

/* ============================================
   DATE SEPARATOR
============================================ */
.date-separator,
.encryption-notice{
    width:100%;
    display:flex;
    justify-content:center;
    margin:10px 0;
}

.date-separator span,
.encryption-notice span{
    padding:6px 12px;
    border-radius:8px;
    font-size:12px;
    box-shadow:0 1px 0.5px rgba(11,20,26,.13);
}

.date-separator{
    position: sticky;

    top: 10px;

    display: flex;
    justify-content: center;

    width: 100%;

    margin: 12px 0;

    z-index: 50;

    pointer-events: none;
}

/* Date Label */
.date-separator span{
    background: rgba(255,255,255,0.95);

    color: #54656f;

    font-size: 12px;
    font-weight: 500;

    padding: 6px 12px;

    border-radius: 8px;

    box-shadow: 0 1px 2px rgba(0,0,0,0.15);

    backdrop-filter: blur(5px);

    pointer-events: auto;
}

/* Hide Smoothly */
.date-separator.hidden{
    opacity: 0;
    visibility: hidden;

    transition: all 0.2s ease;
}


.encryption-notice span{
    background:#ffeecd;
    color:#54656f;
    max-width:85%;
    text-align:center;
}

/* ============================================
   CONTACT MODAL
============================================ */
#contactModal .modal-content{
    height:500px;
}

#contactModal .modal-body{
    flex:1;
    overflow-y:auto;
}

#contactSearchInput{
    position:sticky;
    top:0;
    z-index:10;
    margin-bottom:10px;
}

/* ============================================
   UPLOAD PROGRESS
============================================ */
.upload-progress-container{
    width:100%;
    height:6px;
    background:rgba(0,0,0,0.1);
    border-radius:6px;
    overflow:hidden;
    margin-top:10px;
}

.upload-progress-bar{
    width:0%;
    height:100%;
    background:var(--primary-color);
    transition:width 0.2s linear;
}

.upload-progress-text{
    margin-top:4px;
    text-align:right;
    font-size:11px;
    color:var(--text-secondary);
}

/* ============================================
   RESPONSIVE DESIGN
============================================ */
.back-btn{
    display:none;
}

@media(max-width:992px){
    .sidebar{
        width:340px;
        min-width:340px;
    }
}

@media(max-width:768px){
    .app-container{
        position:relative;
    }

    .sidebar{
        width:100%;
        min-width:100%;
        position:absolute;
        inset:0;
        z-index:20;
        transition:transform 0.3s ease;
    }

    .chat-area{
        position:absolute;
        inset:0;
        width:100%;
        transform:translateX(100%);
        transition:transform 0.3s ease;
        z-index:30;
    }

    .app-container.chat-active .sidebar{
        transform:translateX(-100%);
    }

    .app-container.chat-active .chat-area{
        transform:translateX(0);
    }

    .back-btn{
        display:flex;
    }

    .welcome-screen{
        display:none;
    }

    .messages-container{
        padding:15px 10px;
    }

    .message-bubble{
        max-width:88%;
    }

    .chat-header{
        padding:8px 10px;
    }

    .message-input-container{
        padding:8px 10px calc(8px + env(safe-area-inset-bottom));
    }

    #messageInput{
        font-size:16px;
    }

    .emoji-picker{
        width:100%;
        height:45vh;
        left:0;
        right:0;
        bottom:65px;
        border-radius:16px 16px 0 0;
    }

    .attachment-menu{
        width:90%;
        left:5%;
        bottom:70px;
        grid-template-columns:repeat(4,1fr);
    }

    #localVideo{
        width:110px;
        height:140px;
        right:10px;
        bottom:90px;
    }

    .slider-nav{
        display:none;
    }

    .modal-content,
    .profile-box{
        width:95%;
    }
}

@media(max-width:480px){
    .login-box{
        padding:25px 20px;
    }

    .chat-item{
        padding:10px 12px;
    }

    .message-bubble{
        max-width:92%;
        font-size:13px;
    }

    .attachment-menu{
        grid-template-columns:repeat(2,1fr);
    }

    .message-image-grid{
        width:100%;
    }

    .message-image-grid.grid-2{
        grid-auto-rows:140px;
    }

    .message-image-grid.grid-3{
        grid-template-rows:170px 110px;
    }

    .message-image-grid.grid-4{
        grid-template-rows:110px 110px;
    }
}

@media(max-width:360px){
    .chat-item-name{
        font-size:14px;
    }

    .chat-item-preview{
        font-size:12px;
    }

    .message-bubble{
        max-width:95%;
    }
}


/* ============================================
   AUTO MESSAGE BUBBLE SIZE
   NO MIN WIDTH / HEIGHT
   ONLY MAX WIDTH & HEIGHT
   ============================================ */

.message-bubble{
    position: relative;

    display: inline-flex;
    flex-direction: column;

    /* AUTO SIZE */
    width: fit-content;
    height: auto;

    /* REMOVE MIN SIZE */
    min-width: unset;
    min-height: unset;

    /* ONLY MAX SIZE */
    max-width: 340px;
    max-height: 450px;

    padding: 6px 7px 18px 9px;

    border-radius: 7.5px;

    overflow: hidden;

    word-break: break-word;
    overflow-wrap: anywhere;

    box-shadow: 0 1px 0.5px rgba(11,20,26,.13);

    font-size: 14px;
    line-height: 19px;
}

/* ============================================
   MESSAGE CONTENT AUTO SIZE
   ============================================ */

.message-content{
    width: auto;
    height: auto;

    max-width: 100%;

    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: break-word;

    padding-right: 45px;
}

/* ============================================
   FILE AUTO FIT INSIDE BUBBLE
   ============================================ */

.message-file{
    width: auto;
    height: auto;

    max-width: 100%;

    overflow: hidden;

    border-radius: 8px;

    margin-bottom: 4px;
}

/* ============================================
   IMAGE AUTO SIZE
   ============================================ */

.message-file img{
    display: block;

    width: auto;
    height: auto;

    max-width: 100%;
    max-height: 424px;

    border-radius: 8px;

    object-fit: cover;
}

/* ============================================
   VIDEO AUTO SIZE
   ============================================ */

.message-file video{
    display: block;

    width: 100%;
    height: auto;

    max-width: 100%;
    max-height: 424px;

    border-radius: 8px;

    object-fit: cover;

    background: #000;
}

/* ============================================
   AUDIO AUTO SIZE
   ============================================ */

.message-file audio{
    width: 100%;
    max-width: 280px;
}

/* ============================================
   DOCUMENT AUTO SIZE
   ============================================ */

.message-document{
    display: flex;
    align-items: center;
    gap: 12px;

    width: auto;
    max-width: 100%;

    padding: 10px;

    border-radius: 10px;

    background: rgba(0,0,0,0.08);

    overflow: hidden;
}

.document-info{
    flex: 1;
    min-width: 0;
}

.document-name{
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================
   IMAGE GRID
   ============================================ */

.message-image-grid{
    display: grid;

    width: 100%;
    max-width: 330px;

    gap: 2px;

    overflow: hidden;

    border-radius: 8px;
}

/* ============================================
   GRID IMAGE
   ============================================ */

.grid-img-wrap{
    position: relative;

    overflow: hidden;

    background: #ddd;
}

.grid-img-wrap img{
    width: 100%;
    height: 100%;

    object-fit: cover;

    display: block;
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */

@media (max-width:768px){

    .message-bubble{
        max-width: 85vw;
        max-height: 70vh;
    }

    .message-file img,
    .message-file video{
        max-height: 55vh;
    }

    .message-image-grid{
        max-width: 75vw;
    }
}