#publicChatContent, #contactsContent, #profileContent, #postsContent {
    padding: 10px;
}

.users-list {
    display: flex;
    flex-direction: column;
}

/* START: MODIFICATION - Last message text style in conversations list */
.user-item .user-last-message {
    font-size: 0.85rem;
    color: var(--gray);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px; /* Adjust as needed */
    margin-top: 4px;
}
.user-item .user-last-message.unread {
    color: var(--dark-gray);
    font-weight: bold;
}
.user-item .message-time-info {
     font-size: 0.75rem;
     color: var(--gray);
     text-align: left; /* Align to the end */
}
/* END: MODIFICATION */

.chat-area {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    overflow: visible;
    padding: 0;
    min-height: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
}

/* NEW: Chat bubble container and message styles */
.message-container {
    display: flex;
    align-items: flex-end; /* Align avatar and message bottom */
    margin-bottom: 8px; /* Slightly reduced margin */
    max-width: 100%; /* Take full width to control inner message width */
}

.message-incoming .message-container {
    align-self: flex-start;
    flex-direction: row-reverse; /* Avatar on the right for incoming */
}

.message-outgoing .message-container {
    align-self: flex-end;
    flex-direction: row; /* Avatar on the left for outgoing */
}

.message-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background-color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 0.85rem;
    background-size: cover;
    background-position: center;
    flex-shrink: 0; /* Prevent avatar from shrinking */
    cursor: pointer;
    margin: 0 8px; /* Space around avatar */
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.message {
    max-width: 75%; /* Set a max-width for the message bubble itself */
    padding: 10px 14px; /* Adjusted padding for a more compact look */
    border-radius: 18px; /* Slightly more rounded */
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1); /* Subtle shadow for bubbles */
    line-height: 1.4;
    flex-shrink: 1; /* Allow message to shrink */
    cursor: pointer; /* Add cursor to indicate it's clickable */
    color: var(--dark-gray);
}

.message.message-outgoing {
    background-color: #E2FFC7; /* Light green for outgoing messages */
    color: var(--dark-gray); /* Darker text for readability on light background */
    border-bottom-left-radius: 18px; /* Full rounded on top-left, bottom-left */
    border-bottom-right-radius: 5px; /* Small tail for outgoing */
    margin-right: 0; /* Remove default margin */
    margin-left: auto; /* Push to the left */
}

.message.message-incoming {
    background-color: var(--white); /* White for incoming */
    color: var(--dark-gray);
    border-bottom-right-radius: 18px; /* Full rounded on top-right, bottom-right */
    border-bottom-left-radius: 5px; /* Small tail for incoming */
    margin-left: 0; /* Remove default margin */
    margin-right: auto; /* Push to the right */
}

/* START: MODIFICATION - Style for system messages */
.message-system {
    align-self: center;
    background-color: #e1f5fe;
    color: #01579b;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 0.8rem;
    margin: 8px 0;
    max-width: 80%;
    text-align: center;
}
/* END: MODIFICATION */

.message-header {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
    font-size: 0.8rem;
    justify-content: flex-end; /* Align time/status to the right within the bubble */
    color: var(--gray); /* Common color for header info */
}

/* Sender name for incoming messages */
.message-incoming .message-header .sender-name {
    color: var(--primary-dark);
    font-weight: 600;
    margin-right: 8px;
    flex-grow: 1; /* Allow sender name to take available space */
    text-align: right; /* Align sender name to the right */
}

/* Hide sender name in outgoing messages */
.message-outgoing .message-header .sender-name {
    display: none;
}

.message-time {
    font-size: 0.7rem;
    color: inherit; /* Inherit color from message-header */
    display: inline-block; /* Keep time inline with status */
    margin-right: 5px; /* Space between time and status */
}

.message-text-content {
    font-size: 0.95rem; /* Slightly larger text for better readability */
    color: inherit; /* Inherit text color from message bubble */
}

.message-image, .message-video {
    max-width: 100%;
    border-radius: 10px;
    margin-top: 8px; /* Space between text and media */
    display: block; /* Ensure media takes full width */
}

/* START: MODIFICATION - Styles for Audio Message Player */
.message-audio-player {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

.message-audio-player .play-pause-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.message-outgoing .message-audio-player .play-pause-btn {
    background: var(--primary-dark);
}

.message-audio-player .audio-progress-container {
    flex-grow: 1;
    height: 5px;
    background-color: var(--gray);
    border-radius: 3px;
    cursor: pointer;
    position: relative;
}
.message-outgoing .message-audio-player .audio-progress-container {
    background-color: #a5d6a7;
}

.message-audio-player .audio-progress-bar {
    width: 0;
    height: 100%;
    background-color: var(--primary-dark);
    border-radius: 3px;
}
.message-outgoing .message-audio-player .audio-progress-bar {
    background-color: var(--accent-color);
}

.message-audio-player .audio-duration {
    font-size: 0.75rem;
    color: var(--gray);
    font-family: 'monospace';
    flex-shrink: 0;
}
/* END: MODIFICATION */

.message-image {
    cursor: pointer;
}

.message-outgoing .message-actions {
    display: none;
    position: absolute;
    top: 50%;
    right: 100%; /* Position actions to the right of outgoing bubble */
    transform: translateY(-50%);
    background-color: rgba(0,0,0,0.1); /* Semi-transparent background for actions */
    border-radius: 5px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.2);
    padding: 3px;
    gap: 2px;
    z-index: 5;
    margin-right: 5px; /* Space from the bubble */
}

.message-outgoing .message-actions.active {
    display: flex;
}

.message-action-btn {
    background: none;
    border: none;
    color: var(--white); /* White icons for actions on outgoing */
    font-size: 0.9rem;
    padding: 5px 8px;
    cursor: pointer;
    transition: all 0.2s;
}
.message-action-btn:hover {
    color: var(--accent-color); /* Highlight color on hover */
    transform: scale(1.1);
}

/* --- START: تعديل مطلوب لإصلاح مشكلة حجم شريط الإدخال --- */
.message-input-area {
    display: flex;
    align-items: center;
    padding: 5px 10px;
    background-color: var(--white);
    border-top: 1px solid #e0e0e0;
    position: relative;
    flex-shrink: 0; /* يمنع شريط الإدخال من التقلص */
}

.message-input {
    flex: 1;
    min-width: 0; /* يسمح للمربع بالتقلص بشكل صحيح بجانب الأزرار */
    padding: 8px 15px;
    border: none;
    border-radius: 20px;
    background-color: var(--light-gray);
    outline: none;
    font-size: 1rem;
    height: 40px; /* ارتفاع ثابت ليتوافق مع الأزرار */
    resize: none;
}
/* --- END: تعديل مطلوب --- */

.emoji-btn, .attachment-btn {
    font-size: 1.5rem;
    color: var(--gray);
    cursor: pointer;
    padding: 0 10px;
}

.send-btn {
    background-color: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-left: 10px;
    transition: all 0.2s;
}

/* START: MODIFICATION - Styles for Mic Button and Recording UI */
.mic-btn {
    background-color: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-left: 10px;
    transition: all 0.2s;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.mic-btn:hover {
    background-color: var(--primary-dark);
}

.recording-ui {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    height: 45px;
    background-color: var(--white);
    border-radius: 25px;
    margin: 0 5px;
    border: 1px solid var(--primary-color);
}

.recording-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--notification-color);
}

.recording-indicator .rec-dot {
    width: 10px;
    height: 10px;
    background-color: var(--notification-color);
    border-radius: 50%;
    animation: blink 1.5s infinite ease-in-out;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.recording-timer {
    font-family: 'monospace';
    font-size: 1rem;
    color: var(--dark-gray);
}

.cancel-recording-text {
    font-size: 0.8rem;
    color: var(--gray);
    animation: slide-left-right 2s infinite ease-in-out;
    cursor: pointer;          /* يظهر أيقونة اليد */
    user-select: none;        /* يمنع تحديد النص عند النقر المتكرر */
    padding: 5px 10px;        /* زيادة المساحة القابلة للنقر لتسهيل الضغط */
    position: relative;       /* لضمان ظهوره فوق العناصر الأخرى */
    z-index: 10;
}

@keyframes slide-left-right {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(-10px); }
}
/* END: MODIFICATION */

.send-btn:hover {
    background-color: var(--primary-dark);
}

.emoji-picker {
    position: absolute;
    bottom: 70px;
    right: 20px;
    width: 300px;
    background-color: var(--white);
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    display: none;
    z-index: 100;
    padding: 10px;
    max-height: 250px;
    overflow-y: auto;
}

.emoji-picker.active {
    display: block;
}

.emoji-item {
    display: inline-block;
    font-size: 1.5rem;
    padding: 5px;
    cursor: pointer;
}

.back-icon {
    cursor: pointer;
    margin-right: 10px;
}

.search-bar {
    display: none;
    padding: 10px;
    background-color: var(--white);
    border-bottom: 1px solid #e0e0e0;
}

.search-input {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 0.9rem;
}

.notifications-container {
    padding: 15px;
}

.notification-item.unread {
    background-color: var(--light-color);
}

.notification-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 10px;
}

.notification-content {
    flex: 1;
}

.notification-title {
    font-weight: 600;
    margin-bottom: 5px;
}

.notification-time {
    font-size: 0.8rem;
    color: var(--gray);
}

.notification-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 1.2rem;
    background-size: cover;
    background-position: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    overflow: hidden;
    margin-left: 10px;
}

.notification-avatar:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.notification-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.notification-avatar .avatar-initial {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.typing {
    display: flex;
    align-items: center;
    padding: 5px 15px;
}

.typing span {
    width: 8px;
    height: 8px;
    background-color: #9E9E9E;
    border-radius: 50%;
    display: inline-block;
    margin-right: 5px;
}

.typing span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typingAnimation {
    0%, 80%, 100% {
        transform: scale(0.6);
    }
    40% {
        transform: scale(1);
    }
}

.message-status {
    margin-left: 5px;
    display: inline-block;
    font-size: 0.7rem;
    color: inherit; /* Inherit color from message-header or message-time */
}

.message-status.read {
    color: #25D366; /* Accent color for read */
}

.message-status.delivered {
    color: #b0e0e6; /* Light blue for delivered (distinct from read) */
}

/* أنماط غرف الدردشة العامة */
#publicRoomsList {
    padding: 10px;
}
.public-room-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    background-color: var(--white);
    border-radius: 10px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.2s;
}
.public-room-item:hover {
    transform: translateY(-3px);
}
.room-name {
    font-weight: 600;
    font-size: 1.1rem;
}
.room-count {
    font-size: 0.9rem;
    color: var(--gray);
    background-color: var(--light-gray);
    padding: 5px 10px;
    border-radius: 15px;
}

/* NEW: Styles for Mention Suggestions */
.mention-suggestions {
    position: absolute;
    bottom: 60px; /* Adjust based on input field height */
    left: 10px;
    right: 10px;
    background-color: var(--white);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-height: 200px;
    overflow-y: auto;
    z-index: 200;
    display: none; /* Hidden by default */
    border: 1px solid var(--light-gray); /* Added for better visibility */
}

.mention-suggestions.active {
    display: block;
}

.mention-item {
    padding: 10px 15px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s;
}

.mention-item:hover, .mention-item.active-suggestion {
    background-color: var(--light-gray);
}

.mention-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 0.8rem;
    margin-left: 10px;
    background-size: cover;
    background-position: center;
    flex-shrink: 0; /* Prevents avatar from shrinking */
}

.mention-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mention-name {
    font-weight: 600;
    color: var(--dark-gray);
}

/* Styles for highlighted mentions in text */
.mention-highlight {
    color: var(--mention-color);
    font-weight: bold;
    cursor: pointer;
    text-decoration: none;
}

#manualLoadMoreBtn {
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 20px;
    cursor: pointer;
}
.theme-dark .message-input {
    color: #FFFFFF;
}
.theme-dark .message-input::placeholder {
    color: #b0b0b0;
}
.theme-dark .message-outgoing {
    color: #111111 !important;
}

/* تنسيق مرفقات الملفات */
.message-file-attachment {
    display: flex;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.05);
    padding: 10px;
    border-radius: 8px;
    margin-top: 5px;
    max-width: 100%;
}

.message-outgoing .message-file-attachment {
    background-color: rgba(255, 255, 255, 0.2); /* لون مختلف للرسائل الصادرة */
}

.file-icon {
    font-size: 24px;
    margin-right: 12px; /* اجعلها margin-left في حالة RTL إذا لزم الأمر */
    color: var(--primary-color);
}

.message-outgoing .file-icon {
    color: white;
}

.file-details {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.file-name {
    font-weight: bold;
    font-size: 0.9em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
    max-width: 200px;
}

.download-link {
    font-size: 0.8em;
    text-decoration: none;
    color: var(--primary-color);
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.message-outgoing .download-link {
    color: rgba(255, 255, 255, 0.9);
}

.download-link:hover {
    text-decoration: underline;
}