/* Chat Container */
#chatContainer {
    display: flex;
    flex-direction: column;
    width: 90%;
    max-width: 500px;
    height: 550px;
    background: var(--white);
    border-radius: 15px;
    box-shadow: 0 4px 10px var(--navBar-shadow);
    margin: auto;
    margin-top: 200px;
    margin-bottom: 60px;
    overflow: hidden;
}

/* Chat Header */
#chatHeader {
    display: flex;
    align-items: center;
    padding: 15px;
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--content-grey);
    background: var(--body-bg2);
    border-bottom: 1px solid var(--border-grey);
}

/* Profile Picture */
.chat-profile-pic {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 10px;
    border: 2px solid var(--nav-btn);
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--light-blue) var(--body-bg);
}

/* Message Date Separator */
.chat-date-separator {
    text-align: center;
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--light-grey);
    margin: 10px 0;
}

/* Individual Messages */
.message {
    max-width: 70%;
    padding: 10px;
    border-radius: 15px;
    font-size: 1rem;
    word-wrap: break-word;
    display: inline-block;
    position: relative;
}

.message p {
    white-space: pre-wrap;
    font-size: 1em;
    font-family: 'Inter';
}

/* Sent Messages (Blue, Right) */
.sent {
    align-self: flex-end;
    background: var(--msgsent);
    color: var(--msgtxt);
    border-bottom-right-radius: 5px;
    text-align: left;
    margin-top: 10px;
}

/* Received Messages (White, Left) */
.received {
    align-self: flex-start;
    background: var(--msgreceived);
    color: var(--msgtxt);
    border-bottom-left-radius: 5px;
    text-align: left;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-top: 10px;
}

/* Message Timestamp */
.message-time {
    font-size: 0.7rem;
    color: var(--msgtxt);
    position: relative;
    top: 5px;
}

/* Input Field */
#chatInputContainer {
    display: flex;
    padding: 10px;
    border-top: 1px solid var(--border-grey);
    background: var(--body-bg2);
    align-items: center;
}

#chatInput {
    flex: 1;
    padding: 10px;
    padding-left: 15px;
    border: none;
    border-radius: 20px;
    font-size: 1rem;
    outline: none;
    /* Hide scrollbar on Firefox */
    scrollbar-width: none;
    /* Internet Explorer & older Edge */
    -ms-overflow-style: none;
}

/* Chrome, Safari, and newer Edge */
#chatInput::-webkit-scrollbar {
    display: none;
}

/* Send Button */
#sendMessageBtn {
    margin-left: 10px;
    border: none;
    background: none;
    cursor: pointer;
    padding: 5px;
}

#sendMessageBtn img {
    width: 28px;
    height: 28px;
    transition: transform 0.2s;
}

:root.dark-mode #sendMessageBtn img {
    filter: invert(1);
}

#sendMessageBtn:hover img {
    transform: scale(1.1);
}

/* Empty & Error States */
.no-messages,
.loading-text,
.error-msg {
    text-align: center;
    color: var(--light-grey);
}

/* Message batch: groups a chunk of messages vertically */
.message-batch {
    display: flex;
    flex-direction: column;
    width: 100%;
}

#chatInput {
    resize: none;
    overflow-y: auto;
    max-height: 150px;
    font-family: "Roboto";
    line-height: 1.4;
    /* Improve spacing */
    white-space: pre-wrap;
    /* Preserve line breaks visually */
}

/* Addin Username to chat messages */
.msg-username {
    font-family: 'Zain';
    color: rgb(102, 102, 102);
    /* display: none; */
}

:root.dark-mode .msg-username {
    color: rgb(224, 224, 224);
}

.sender {
    align-self: flex-end;
}

.reciever {
    align-self: flex-start;
}

.new-sent {
    margin-top: -10px;
}

.status-message {
    font-family: 'Zain';
    font-size: 1.1rem;
    color: var(--content-grey);
    opacity: 0.8;
}

#emptyChatimg {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 15px;
    /* Space between image and text */
    width: 100%;
    height: 100%;
    min-height: 200px;
    /* Adjust based on layout */
    color: var(--content-grey);
    /* Use theme color */
    font-size: 1rem;
    margin-top: 180px;
}

#emptyChatimg img {
    width: 200px;
    max-width: 80%;
    opacity: 0.8;
}

#emptyChatimg p {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--light-grey);
    /* Use your theme color */
}

#chatUsername,
.chat-profile-pic,
.comment-user-avatar,
.user-avatar {
    cursor: pointer;
}

#chatUsername:hover {
    color: var(--nav-btn);
}

:root.dark-mode #chatUsername:hover {
    color: rgb(71, 71, 71)
}

.chat-profile-pic:hover,
.comment-user-avatar:hover,
.user-avatar:hover {
    border: 2px solid var(--nav-btn);
}

/* Notification container */
.message-popup {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--light-blue, #007bff);
    /* Bluish modern theme */
    color: var(--grey-mr);
    padding: 12px 18px;
    font-size: 14px;
    font-weight: bold;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    cursor: pointer;
    z-index: 100000;
}

/* Fade-in effect */
.message-popup.show {
    opacity: 1;
    transform: translateY(0);
}

/* Fade-out effect */
.message-popup:not(.show) {
    opacity: 0;
    transform: translateY(20px);
}

/* ********* Typing Indicator Style ********* */
.typing-indicator {
    display: none;
    /* align-items: center; */
    padding: 5px 10px;
    background-color: var(--white);
    border-radius: 15px;
    max-width: 200px;
    margin: 5px auto;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease-in-out;
    position: relative;
    transform: translate(-50%, 20px);
    z-index: 10;
    font-size: 0.8rem;
}

.typing-indicator.active {
    display: flex;
    opacity: 1;
    transform: translate(-50%, 0);
}

.typing-text {
    margin-right: 8px;
    font-size: 12px;
    color: var(--light-grey);
}

.typing-dots {
    display: flex;
    align-items: center;
}

.dot {
    width: 4px;
    height: 4px;
    background-color: var(--light-grey);
    border-radius: 50%;
    margin: 0 2px;
    animation: typing 1.4s infinite ease-in-out;
}

.dot:nth-child(2) {
    animation-delay: 0.2s;
}

.dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {

    0%,
    60%,
    100% {
        transform: initial;
        opacity: 0.5;
    }

    30% {
        transform: translateY(-3px);
        opacity: 1;
    }
}

.typing-indicator {
    left: auto;
}

@media (min-width: 320px) {
    .typing-indicator {
        left: 0%;
    }
}

@media (min-width: 375px) {
    .typing-indicator {
        left: -5%;
    }
}

@media (min-width: 425px) {
    .typing-indicator {
        left: -10%;
    }
}

@media (min-width: 768px) {
    .typing-indicator {
        left: -20%;
    }
}

.online-user.typing .online-user-name {
    color: var(--title-color);
    font-style: italic;
}
