﻿body {
    background-color: #f0f2f5;
}

.msgBoxMain {
    margin: 1rem;
}

.msgBox-rtl {
    width: fit-content;
    background-color: #c4d0ff;
    border-radius: 20px;
    max-width: 75%;
}

.msgBox-ltr {
    width: fit-content;
    background-color: #c4ffd3;
    border-radius: 20px;
    max-width: 75%;
}

.ownerName {
    color: #8800ff;
}

.repliedText {
    overflow-wrap: break-word;
    margin: 0;
    background-color: lavender;
    border-radius: 10px;
    padding: 0 5px 0 5px;
    box-shadow: 0 4px 4px rgb(0 0 0 / 20%);
    cursor: pointer;
}

.msgBoxText {
    overflow-wrap: break-word;
}

.msgBoxImage {
    max-width: 100%;
    cursor: pointer;
}

.msgBoxAudio {
    max-width: 100%;
}

.msgBoxDate {
    color: grey;
}

.replyBoxMain {
    width: fit-content;
    align-content: end;
}

.replyBoxBtn {
    border: none;
    background-color: transparent;
    padding: 1rem;
}

.replyPreviewMain {
    direction: rtl;
}

.replyPreviewBtn {
    float: left;
    background-color: transparent;
    border: none;
}

/* Chats Sidebar */
#chatsPanel {
    width: 300px;
    height: calc(100vh - 5rem);
    background-color: #f8f9fa;
    border-right: 1px solid #dee2e6;
    padding: 1rem;
    position: fixed;
    top: 5rem;
    left: 0;
    z-index: 1001;
    transition: transform 0.3s ease;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    /* Default: visible on desktop */
}

@media (min-width: 768px) {
    body {
        height: calc(100vh - 60px);
    }

    #chatsPanel {
        transform: translateX(0);
        display: block;
    }

    #toggleChatsBtn {
        display: none;
    }

    #closeChatsBtn {
        display: none;
    }

    .chat-main {
        padding: 1rem;
    }
}

@media (max-width: 767px) {
    body {
        height: calc(100vh - 135px);
    }

    #chatsPanel {
        position: fixed;
        height: 100vh;
        top: 0;
        left: 0;
        z-index: 1002;
        width: 100%;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        display: flex;
        flex-direction: column;
        background-color: #f8f9fa;
        border-right: none;
        box-shadow: none;
    }

        #chatsPanel.visible {
            transform: translateX(0);
        }

    #toggleChatsBtn {
        display: block;
    }

    #closeChatsBtn {
        display: block;
        position: absolute;
        top: 1rem;
        right: 1rem;
        background: #fff;
        border: none;
        font-size: 1.5rem;
        width: 35px;
        height: 35px;
        border-radius: 50%;
        cursor: pointer;
        box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    }

    #chatMain {
        margin-left: 0 !important;
        padding: 1rem 10px;
    }

    .chat-main {
        padding: 0;
    }

    .msgBoxMain {
        margin: 0.5rem 0;
    }
}

#chatMain {
    margin-left: 300px;
    transition: margin-left 0.3s ease;
}

@media (max-width: 767px) {
    #chatMain {
        margin-left: 0;
    }
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e9ecef;
}

#closeChatsBtn {
    font-size: 1.2rem;
    padding: 0.2rem 0.5rem;
}

.chats-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chat-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.2s;
    border: 1px solid transparent;
}

    .chat-item:hover {
        background-color: #e9ecef;
    }

    .chat-item.active {
        background-color: #007bff;
        color: white;
        border-color: #007bff;
    }

    .chat-item img {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        margin-right: 10px;
        object-fit: cover;
    }

    .chat-item .user-info {
        flex: 1;
        overflow: hidden;
    }

    .chat-item .username {
        font-weight: 500;
        font-size: 0.95rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .chat-item .last-message {
        font-size: 0.8rem;
        color: #6c757d;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin-top: 2px;
    }

    .chat-item .timestamp {
        font-size: 0.75rem;
        color: #adb5bd;
        margin-left: auto;
    }

    .chat-item .status-dot {
        width: 15px;
        height: 15px;
        border-radius: 50%;
        display: inline-block;
        margin-right: 5px;
        border: 3px solid #f8f9fa;
    }

.status-online {
    background-color: #28a745;
}

.status-offline {
    background-color: #6c757d;
}

#toggleChatsBtn {
    font-size: 1.5rem;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    bottom: 1vh;
    left: 10px;
    z-index: 1003;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

    #toggleChatsBtn i {
        font-size: 1.4rem;
    }

.chat-main {
    position: relative;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

#chatMain .container-fluid {
    padding: 0;
}

#chatBox {
    background-color: white;
    border-radius: 12px;
    border: 1px solid #ddd;
    padding: 10px;
    min-height: 250px;
    overflow-y: auto;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    position: relative;
    height: 40vh;
}

#messageInput {
    border-radius: 15px;
    border: 1px solid #ccc;
    padding: 12px 16px;
    font-size: 1rem;
    background-color: white;
    width: 100%;
    max-height: 100px;
    resize: none;
}

#replyBox {
    background-color: #f8f9fa;
    border-radius: 10px;
    padding: 10px;
    border: 1px solid #e9ecef;
}

/* Typing Indicator */
#typingIndicator, #fileSendingIndicator, #voiceSendingIndicator {
    font-style: italic;
    font-size: 0.85rem;
    margin: 5px 0;
    padding: 5px 10px;
    margin-bottom: 4.5%;
    margin-left: 2px;
    background-color: #f0f8ff;
    border-radius: 15px;
    border: 1px solid #b0d9ff;
    display: none;
}

.msgBoxImage, .msgBoxAudio {
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}