    /* Global Styles */
    body {
        font-family: 'Roboto', sans-serif;
        background-color: #f4f7fa;
        margin: 0;
        padding: 0;
    }

    .chat-layout {
        display: flex;
        min-height: 80vh;
        height: auto;
        background: linear-gradient(135deg, #9ac8d4 0%, #4496f9 100%);
        border-radius: 8px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.05);
        overflow: hidden;
    }
    
    /* Chat container */
    .chat-container {
        display: flex;
        flex-direction: column;
        height: 80vh;
        border: 1px solid #d1d5da;
        border-radius: 8px;
        overflow: hidden;
        background: linear-gradient(135deg, #9ac8d4 0%, #4496f9 100%);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
        position: relative;
        padding: 10px 0 0 0;
    }
    
    
    .chat-sidebar {
        width: 200px;
        background: #f7f7f7;
        border-right: 1px solid #e0e0e0;
        padding: 0;
        display: flex;
        flex-direction: column;
        min-width: 180px;
        max-width: 240px;
        overflow-y: auto;
        align-items: stretch;
    }
    .chat-sidebar-header {
        background: #1976d2;
        color: #fff;   
        font-size: 1.3em;
        font-weight: 700;
        text-align: center;
        padding: 16px 28px;
        border-bottom: 1px solid #bbdefb;
        border-right: 2px solid #bbdefb;
        letter-spacing: 0.02em;
        border-radius: 8px 8px 0 0;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    .chat-sidebar-list {
        flex: 1;
        overflow-y: auto;
        padding: 10px 0;
        align-items: stretch;
        background: #9fcefc;  
    }
    .chat-sidebar-list a {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        box-sizing: border-box;
        padding: 12px 24px;
        color: #333;
        text-decoration: none;
        border-left: 4px solid transparent;
        border: 2px solid #e0e0e0;
        margin-bottom: 6px;
        border-radius: 8px;
        transition: background 0.2s, color 0.2s, border-left 0.2s, border 0.2s;
    }
    .chat-sidebar-list a.active, .chat-sidebar-list a:hover {
        background: #e3f2fd;
        border-left: 4px solid #1976d2;
        border-right: 4px solid #1976d2;
        border-radius: 8px;
        color: #1976d2;
    }

    .chat-sidebar-list a:hover {
        background: linear-gradient(90deg, #e3f2fd 60%, #bbdefb 100%);
        color: #1976d2;
        transform: scale(1.03);
        transition: background 0.2s, color 0.2s, transform 0.15s;
    }
    .chat-main {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-width: 0;
        background: #fff;
    }
    .chat-header-bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px 28px;
        background: #1976d2;
        color: #fff;
        border-bottom: 1px solid #e0e0e0;
        border-left: 2px solid #e0e0e0;
        min-height: 60px;
    }
    .chat-header-bar .room-name {
        font-size: 1.3em;
        font-weight: 600;
        letter-spacing: 0.01em;
    }
    .chat-header-bar .presence-summary {
        font-size: 1em;
        color: #e3f2fd;
        margin-left: 18px;
    }
    .chat-header-bar .header-actions {
        display: flex;
        gap: 10px;
    }

    .message-area::-webkit-scrollbar,
    #messageList::-webkit-scrollbar {
        width: 6px;
    }
    .message-area::-webkit-scrollbar-thumb,
    #messageList::-webkit-scrollbar-thumb {
        background-color: #ddd;
        border-radius: 3px;
    }
    .message-area::-webkit-scrollbar-thumb:hover,
    #messageList::-webkit-scrollbar-thumb:hover {
        background-color: #ccc;
    }
    
    .message-area {
        position: relative;
        overflow-y: auto;
        flex: 1 1 auto;
        min-height: 0;
        padding: 10px 10px 0 10px;
        background: linear-gradient(135deg, #9ac8d4 0%, #4496f9 100%);
        border-radius: 8px;
        box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.10);
    }
    
    
    .new-message-indicator {
        position: absolute;
        bottom: 20px;
        right: 20px;
        background: var(--primary);
        color: white;
        padding: 5px 10px;
        border-radius: 20px;
        cursor: pointer;
        box-shadow: 0 2px 5px rgba(0,0,0,0.2);
        display: none;
        z-index: 10;
    }
        
    /* Basic message styles - applied to all messages */
    .message {
        display: flex;
        align-items: flex-end;
        margin-bottom: 10px;
        max-width: 90vw;
        width: auto;
        position: relative;
        padding: 0;
        border-radius: 12px;
        box-shadow: 0 1px 4px rgba(0,0,0,0.04);
        background: none;
    }
    
    .message-self {
        margin-left: auto;
        justify-content: flex-end;
    }
    
    .message-other {
        margin-right: auto;
        justify-content: flex-start;
    }
    
    .message-self .message-content-wrapper {
        background: linear-gradient(135deg, #00c6ff 0%, #0072ff 100%);
        color: #fff;
        border-radius: 18px 18px 4px 18px;
        border: 1px solid #e0e0e0;
        box-shadow: 0 2px 8px rgba(0, 114, 255, 0.15);
        text-align: right;
    }
    
    .message-other .message-content-wrapper {
        background: linear-gradient(135deg, #78dad0 0%, #2ad83e 100%);
        color: #343a40;
        border-radius: 18px 18px 18px 4px;
        border: 1px solid #e0e0e0;
        box-shadow: 0 2px 8px rgba(0,0,0,0.06);
        text-align: left;
    }
    
    .message-content-wrapper {
        padding: 12px 16px 8px 16px;
        min-width: 240px;
        max-width: 90vw;
        width: auto;
        word-break: break-word;
        position: relative;
        display: flex;
        flex-direction: column;
    }
    
    .message-avatar img {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        object-fit: cover;
        margin-right: 10px;
        box-shadow: 0 1px 4px #0001;
        border: 1px solid #ffffff;
    }
    
    .message-header {
        font-size: 17px;
        font-weight: 600;
        margin-bottom: 4px;
        display: flex;
        align-items: center;
        gap: 6px;
        white-space: nowrap; 
    }
    
    .message-header .username {
        text-decoration: underline;
    }
    
    .message-avatar img.online,
    .message-avatar img.online {
        box-shadow: 0 0 0 2px #42a5f5, 0 0 8px #42a5f5;
    }

    .message-content {
        font-size: 1.08em;
        margin-bottom: 4px;
        line-height: 1.6;
        color: inherit;
        word-break: break-word;
    }
    
    /* Context menu buttons */
    .message-context-menu {
        position: absolute;
        right: 0;
        top: -30px;
        background: white;
        border-radius: 20px;
        padding: 4px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        display: flex;
        opacity: 0;
        transform: translateY(10px);
        transition: all 0.2s ease;
        z-index: 5;
    }
  
    .message:hover .message-context-menu {
        opacity: 1;
        transform: translateY(0);
    }
  
    .message-context-menu .menu-item {
        background: transparent !important;
        box-shadow: none !important;
        color: #1976d2;
        border: none;
        transition: color 0.2s;
    }
    
    .message-context-menu .menu-item:hover,
    .message-context-menu .menu-item:focus {
        background: rgba(25, 118, 210, 0.08) !important;
        color: #1565c0;
    }       
    .edit-message-btn i { color: #1976d2 !important; }
    .delete-message-btn i { color: #e53935 !important; }
    .pin-message-btn i { color: #ad8b00 !important; }

    .message-self .message-content-wrapper::after {
        content: '';
        position: absolute;
        right: -8px;
        bottom: 8px;
        width: 0;
        height: 0;
        border-top: 8px solid #1976d2;
        border-left: 8px solid transparent;
        border-radius: 0 0 8px 0;
    }
    .message-other .message-content-wrapper::after {
        content: '';
        position: absolute;
        left: -8px;
        bottom: 8px;
        width: 0;
        height: 0;
        border-top: 8px solid #f5f5f5;
        border-right: 8px solid transparent;
        border-radius: 0 0 0 8px;
    }

    .message-time {
        font-size: 11px;
        opacity: 0.9;
        align-self: flex-end;
        margin-top: 5px;
        position: relative;
        color: rgba(255,255,255,0.8);
    }
    
    .message-status {
        font-size: 11px;
        margin-top: 2px;
        display: flex;
        align-items: center;
    }
      
    .message-status .status-icon {
        margin-right: 4px;
        font-size: 14px;
    }
      
    .status-delivered {
        color: #8e8e8e;
    }
      
    .status-read {
        color: #0084ff;
    }
    /* Read receipts */
    .read-receipt {
        display: flex;
        align-items: center;
        gap: 4px;
        margin-top: 2px;
        flex-wrap: wrap;
        position: static;
        font-size: 0.85em;
        color: #888;
    }
    
    .read-receipt-icon {
        color: #4c97d8;
        margin-left: 2px;
    }
    
    /* Message reactions */
    .message-reactions {
        display: flex;
        flex-wrap: wrap;
        margin-top: 5px;
        gap: 4px;
    }
    
    .reaction-badge {
        display: inline-flex;
        align-items: center;
        padding: 4px 8px;
        margin-right: 5px;
        margin-bottom: 5px;
        border-radius: 20px;
        background-color: #f0f2f5;
        border: 1px solid rgba(0, 0, 0, 0.05);
        font-size: 0.85rem;
        cursor: pointer;
        transition: all 0.2s;
    }
    
    .reaction-badge:hover {
        background-color: #e4e6eb;
        transform: scale(1.05);
    }
    
    .reaction-badge.user-reacted {
        background-color: #e7f3ff;
        border-color: #77b7ff;
    }
    
    .reaction-badge .reaction-count {
        margin-left: 0.25rem;
        font-size: 0.75rem;
        color: #6c757d;
    }
    
    .reaction-emoji {
        margin-right: 3px;
    }
    
    .reaction-count {
        font-size: 0.9em;
        color: #555;
    }
    
    .add-reaction {
        color: #888;
        cursor: pointer;
        font-size: 0.8em;
        padding: 2px 6px;
        border-radius: 12px;
        display: inline-block; 
    }
    
    .message:hover .add-reaction {
        display: inline-block;
    }
    
    /* Message threading */
    .thread-indicator {
        margin-top: 5px;
        font-size: 0.85em;
        font-weight: 600;
        color: #e7ebf0;
        cursor: pointer;
        display: inline-block;
        padding: 2px 8px;
        background: transparent;
        border-radius: 10px;
        transition: background-color 0.2s ease;
        position: relative;
    }
    
    .thread-indicator:hover {
        background-color: #cce5ff;
        text-decoration: underline;
    }
    
    
    .thread-container {
        margin-top: 5px;
        border-left: 2px solid #ddd;
        padding-left: 10px;
    }
    .input-area {
        padding: 15px 20px;
        background: #86def8; 
        border-top: 1px solid #eee;
        display: flex;
        align-items: center;
        gap: 10px;
    }
      
    .input-area input {
        flex: 1;
        position: relative;
        background: rgba(245, 245, 245, 0.438);
        border-radius: 24px;
        padding: 12px 20px;
        display: flex;
        align-items: center;
        transition: all 0.2s;
    }
      
    .input-area input:focus {
        background: #f7fafd;
        box-shadow: 0 0 0 2px rgba(0,132,255,0.2);
    }
      
    .input-area-wrapper {
        flex: 1;
        border: none;
        background: transparent;
        padding: 12px 5px;
        font-size: 15px;
        outline: none;
        color: #333;
    }
      
    .input-buttons {
        display: flex;
        gap: 8px;
    }
      
    .attach-btn, .emoji-btn {
        padding: 12px;
        background-color: transparent;
        color: #0084ff;
        border: none;
        border-radius: 50%;
        cursor: pointer;
        transition: background-color 0.3s ease;
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
    }
      
    .attach-btn:hover, .emoji-btn:hover {
        background: #f0f0f0;
        color: #0084ff;
    }
      
    .send-btn {
        background: linear-gradient(90deg, #19d266 0%, #42f57e 100%);
        color: #fff;
        border: none;
        border-radius: 50%;
        width: 50px;
        height: 50px;
        font-size: 0.98em;
        box-shadow: 0 2px 8px rgba(25, 118, 210, 0.12);
        transition: background 0.2s, transform 0.1s;
    }
    .send-btn:hover {
        background: linear-gradient(90deg, #42a5f5 0%, #1976d2 100%);
        transform: scale(1.08);
    }
    .message {
        animation: messageAppear 0.3s ease forwards;
    }
  
    /* Typing indicator */
    .typing-indicator {
        padding: 0 1px;
        background: transparent !important;
        display: inline-flex;
        align-items: center;
        margin: 0 1px 4px 1px; /* horizontal and a little bottom space */
        width: auto;
        font-size: 1em;
        white-space: nowrap;
        z-index: 99999 !important;
    }
    
    .typing-indicator .typing-text {
        color: #FFF;
        margin-right: 8px;
        font-size: 1em;
        white-space: nowrap;
    }
    
    .typing-indicator span:not(.typing-text) {
        width: 8px;
        height: 8px;
        background: none;
        border-radius: 50%;
        display: inline-block;
        margin: 0 1px;
        opacity: 0.4;
        vertical-align: middle;
    }

    .typing-indicator span:nth-child(2) {
        animation: typing 1s infinite;
    }
    .typing-indicator span:nth-child(3) {
        animation: typing 1s infinite 0.2s;
    }
    .typing-indicator span:nth-child(4) {
        animation: typing 1s infinite 0.4s;
    }
  
    @keyframes typing {
        0%, 100% { opacity: 0.4; }
        50% { opacity: 1; }
    }
  
    /* User presence indicator */
    .user-presence {
        padding: 10px 15px;
        background-color: #7ff7bf;
        border-bottom: 1px solid #e0e6ed;
        display: flex;
        align-items: center;
        flex-wrap: wrap;
        margin-bottom: 5px;
        border-radius: 8px;
    }
    
    #onlineUsers {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin-left: 10px;
    }
    
    .presence-indicator {
        position: absolute;
        bottom: 0;
        right: 0;
        width: 14px;
        height: 14px;
        border-radius: 50%;
        border: 2px solid white;
        display: inline-block;
    }
    
    .online-status, .presence-online {
        background-color: #4CAF50;
    }
    
    .away-status, .presence-away {
        background-color: #ffc107;
    }
    
    .busy-status, .presence-busy {
        background-color: #F44336;
    }
    
    .offline-status, .presence-offline {
        background-color: #9E9E9E;
    }
    
    .user-badge {
        display: inline-flex;
        align-items: center;
        margin-right: 10px;
        margin-bottom: 5px;
        padding: 4px 10px;
        background-color: #e9ecef;
        border-radius: 20px;
        font-size: 0.85em;
        color: #333;
    }
    
    .user-avatar-small {
        width: 18px;
        height: 18px;
        border-radius: 50%;
        margin-right: 5px;
        object-fit: cover;
    }
    
    /* Thread Modal */
    .thread-modal {
        display: none;
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 400px;
        max-width: 90%;
        background: #fff;
        box-shadow: -2px 0 10px rgba(0,0,0,0.2);
        z-index: 1050;
        overflow: hidden;
        transition: transform 0.3s cubic-bezier(.4,0,.2,1), opacity 0.2s;
        transform: translateX(100%);
        opacity: 0;
        height: 100vh;
    }
    
    .thread-modal.open {
        display: block;
        transform: translateX(0);
        opacity: 1;
    }
    
    .thread-modal-content {
        display: flex;
        flex-direction: column;
        height: 100%;
    }
    
    .thread-modal-header {
        padding: 15px;
        border-bottom: 1px solid #e0e6ed;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .thread-close {
        background: none;
        border: none;
        font-size: 1.5rem;
        cursor: pointer;
        color: #555;
        padding: 5px 10px;
        transition: color 0.2s;
    }
    
    .thread-close:hover {
        color: #007bff;
    }
    
    .parent-message-container {
        padding: 15px;
        border-bottom: 1px solid #e0e6ed;
        background: #f7f9fc;
    }
    
    .thread-input-area {
        background: #f8f9fa;
        border-top: 1px solid #e0e6ed;
        display: flex;
        padding: 15px;
    }
    
    .thread-input-area input {
        background: #fff;
        border: 1px solid #ddd;
        border-radius: 20px;
        padding: 10px;
        flex: 1;
        outline: none;
    }
    
    .thread-input-area input:focus {
        border-color: #5cb85c;
        outline: none;
    }
    
    .thread-send-btn {
        margin-left: 10px;
        border: none;
        background: transparent !important;
        color: #1976d2 !important;
        border-radius: 50%;
        width: 36px;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        box-shadow: none;
        transition: background 0.2s, color 0.2s;
    }
    
    .thread-send-btn:hover {
        background: rgba(25, 118, 210, 0.08) !important;
        color: #1976d2 !important;
    }
    .thread-message-list.scrollable {
        flex: 1 1 auto;
        overflow-y: auto;
        padding: 10px;
        min-height: 0;
    }
    .parent-message-list.highlighted {
        background: #f0f4ff;
        border-left: 4px solid #1976d2;
        padding: 10px;
        margin-bottom: 10px;
    }
    .thread-message {
        display: flex;
        align-items: flex-start;
        margin-bottom: 12px;
    }
    /* Make thread messages look like main chat messages */
    .thread-message.message-self .message-content-wrapper {
        background: linear-gradient(135deg, #00c6ff 0%, #0072ff 100%);
        color: #fff;
        border-radius: 18px 18px 4px 18px;
        border: 1px solid #e0e0e0;
        box-shadow: 0 2px 8px rgba(0, 114, 255, 0.15);
        text-align: right;
    }
    .thread-message.message-other .message-content-wrapper {
        background: linear-gradient(135deg, #78dad0 0%, #2ad83e 100%);
        color: #343a40;
        border-radius: 18px 18px 18px 4px;
        border: 1px solid #e0e0e0;
        box-shadow: 0 2px 8px rgba(0,0,0,0.06);
        text-align: left;
    }

    .thread-message.message-self .message-content-wrapper::after {
        content: '';
        position: absolute;
        right: -8px;
        bottom: 8px;
        width: 0;
        height: 0;
        border-top: 8px solid #1976d2;
        border-left: 8px solid transparent;
        border-radius: 0 0 8px 0;
    }
    .thread-message.message-other .message-content-wrapper::after {
        content: '';
        position: absolute;
        left: -8px;
        bottom: 8px;
        width: 0;
        height: 0;
        border-top: 8px solid #f5f5f5;
        border-right: 8px solid transparent;
        border-radius: 0 0 0 8px;
    }
    .thread-message .avatar {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        margin-right: 8px;
    }
    .thread-message .content {
        background: #f8f9fa;
        border-radius: 8px;
        padding: 8px 12px;
        flex: 1;
    }
    .thread-message .meta {
        font-size: 0.85em;
        color: #888;
        margin-bottom: 2px;
    }

    .message-actions button {
        background: transparent;
        border: none;
        color: #1976d2;
        margin: 0 4px;
        padding: 6px;
        border-radius: 50%;
        transition: background 0.2s;
    }
    .message-actions button:hover {
        background: rgba(25, 118, 210, 0.08);
        color: #1565c0;
    }
    /* Emoji picker */
    .emoji-picker {
        background: linear-gradient(135deg, #f7fafd 0%, #e3f2fd 100%);
        border: 1.5px solid #1976d2;
        border-radius: 16px;
        box-shadow: 0 8px 32px rgba(25, 118, 210, 0.10);
        min-width: 280px;
        padding: 16px 12px;
        z-index: 9999;
        transition: box-shadow 0.2s, border 0.2s;
    }
    .emoji-picker-content {
        display: grid;
        grid-template-columns: repeat(7, 1fr);
        gap: 12px;
        padding: 8px 0;
    }
    .emoji-item {
        font-size: 1.7em;
        border-radius: 8px;
        padding: 8px;
        transition: background 0.15s, transform 0.12s;
    }
    .emoji-item:hover, .emoji-item:focus {
        background: #e3f2fd;
        transform: scale(1.18);
        outline: none;
    }

    .message.reaction-added {
        animation: reaction-added-pulse 0.5s ease;
    }
    .emoji-picker.flash {
        animation: picker-flash 0.3s ease;
    }
    /* Emoji modal */
    #emojiModal {
        display: none;
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        background: linear-gradient(135deg, #f7fafd 0%, #e3f2fd 100%);
        border: 2.5px solid #1976d2;
        border-radius: 20px;
        padding: 28px 24px;
        box-shadow: 0 12px 48px rgba(25, 118, 210, 0.18);
        z-index: 99999;
        width: min(800px, 90vw);
        max-height: 80dvh;
        overflow-y: auto;
        text-align: center;
        transition: box-shadow 0.2s, border 0.2s;
    }
    #emojiModal.visible {
        display: block;
    }
    .emoji-btn {
        font-size: 32px;
        cursor: pointer;
        padding: 8px;
        border-radius: 8px;
        transition: all 0.2s;
    }
    #emojiGrid {
        display: grid;
        grid-template-columns: repeat(15, 1fr); /* 8 columns, adjust as needed */
        gap: 10px;
        justify-items: center;
        align-items: center;
        margin: 20px 0;
    }
    #emojiModal .emoji-btn {
        font-size: 2em;
        border-radius: 10px;
        padding: 8px;
        transition: background 0.15s, transform 0.12s;
        cursor: pointer;
    }
    #emojiModal .emoji-btn:hover, #emojiModal .emoji-btn:focus {
        background: #e3f2fd;
        transform: scale(1.15);
        outline: none;
    }

    .emoji-btn:hover {
        background-color: #e9f5ff;
        transform: scale(1.3);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    }
    
    .message.reaction-updated {
        animation: reaction-update-pulse 0.5s ease;
    }
    
    .username {
        font-weight: bold;
        margin-right: 8px;
    }
    
    .timestamp {
        font-size: 0.69em;
        font-weight: 200;
        color: #d1d9e1;
        margin-left: auto;
    }
    
    /* Notifications */
    .notification-container {
        position: fixed;
        top: 20px;
        right: 20px;
        z-index: 9999;
        max-width: 350px;
    }
    
    .notification {
        padding: 15px;
        margin-bottom: 10px;
        border-radius: 4px;
        color: #fff;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
        opacity: 1;
        animation: slideIn 0.3s ease;
        transition: opacity 0.5s ease;
    }
        
    .notification.fade-out {
        opacity: 0;
    }
    
    @keyframes slideIn {
        from {
            opacity: 0;
            transform: translateX(30px);
        }
        to {
            opacity: 1;
            transform: translateX(0);
        }
    }    
    /* Floating context menu (right-click) styles */
    #floatingMessageMenu {
        display: none;
        position: absolute;
        z-index: 9999;
        min-width: 180px;
        background: #fff;
        border: 1.5px solid #1976d2;
        border-radius: 12px;
        box-shadow: 0 8px 32px rgba(25, 118, 210, 0.10);
        padding: 6px 0;
        font-size: 1em;
        cursor: pointer;
        overflow: hidden;
        transition: box-shadow 0.18s, border-color 0.18s;
    }
    #floatingMessageMenu.visible {
        display: block !important;
    }
    #floatingMessageMenu .menu-item {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 10px 24px;
        color: #1976d2;
        background: none;
        border: none;
        font-weight: 500;
        font-size: 1em;
        transition: background 0.15s, color 0.15s;
        cursor: pointer;
    }
    #floatingMessageMenu .menu-item i {
        font-size: 1.1em;
        color: #1976d2;
        transition: color 0.15s;
    }
    #floatingMessageMenu .menu-item:hover,
    #floatingMessageMenu .menu-item:focus {
        background: #e3f2fd;
        color: #1565c0;
    }
    #floatingMessageMenu .menu-item:hover i,
    #floatingMessageMenu .menu-item:focus i {
        color: #1565c0;
    }    
    .thread-notification {
        position: fixed;
        bottom: 20px;
        right: 20px;
        background-color: #4CAF50;
        color: white;
        padding: 12px 16px;
        border-radius: 8px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.2);
        z-index: 1000;
        cursor: pointer;
        transform: translateY(100px);
        opacity: 0;
        transition: transform 0.3s ease, opacity 0.3s ease;
    }

    .thread-notification.show {
        transform: translateY(0);
        opacity: 1;
    }

    /* Hide UI components by default */
    #threadModal, 
    #emojiPicker, 
    #emojiModal, 
    #floatingMessageMenu {
        display: none;
    }

    /* Visibility control classes */
    #emojiPicker.visible,
    #floatingMessageMenu.visible,
    #emojiModal.visible {
        display: block;
    }
        
    .tribute-container {
        font-family: 'Segoe UI', Arial, sans-serif;
        border-radius: 8px;
        box-shadow: 0 4px 16px rgba(25, 118, 210, 0.10);
        border: 3px solid #1976d2;
        background: rgb(27, 184, 228) !important;
        padding: 0;
        z-index: 9999;
    }
    
    .tribute-container ul {
        margin: 0;
        padding: 0;
        list-style: none;
    }
    
    .tribute-container li {
        padding: 10px 18px;
        cursor: pointer;
        transition: background 0.2s, color 0.2s;
        color: #1976d2;
        font-size: 1rem;
        border-radius: 6px;
    }
    
    .tribute-container li.highlight {
        background: #1976d2;
        color: #fff;
        border-radius: 6px;
    }
    
    .tribute-container li:not(.highlight):hover {
        background: #e3f2fd;
        color: #1976d2;
    }        
    .read-avatar {
        display: inline-flex;
        align-items: center;
        margin-right: 6px;
    }
    .read-avatar .avatar-img {
        width: 20px;
        height: 20px;
        border-radius: 50%;
        margin-right: 3px;
        object-fit: cover;
        border: 1px solid #ccc;
    }
    .read-username {
        font-size: 0.9em;
        color: #555;
        margin-right: 2px;
    }

    .pinned-messages-bar {
        position: sticky;
        top: 0;
        z-index: 20;
        display: flex;
        align-items: center;
        gap: 8px;
        background: #84d2fc;
        box-shadow: 0 2px 8px rgba(25, 118, 210, 0.08);
        border-bottom: 2px solid #1976d2;
        min-height: 32px;
        padding: 8px 12px;
    }
        
    .pinned-message {
        display: flex;
        align-items: center;
        background: none;
        border: none;
        border-radius: 0;
        padding: 0 12px;
        font-size: 1.2em;
        font-weight: 600;
        color: #1976d2;
        min-width: 0;
        flex: 1;
        height: 32px;
        overflow: hidden;
        cursor: pointer;
        transition: background 0.15s;
    }
    .pinned-message .left-meta {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-shrink: 0;
    }
    .pinned-message .message-content {
        flex: 1;
        text-align: center;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        padding: 0 8px;
    }
    .pinned-message .right-meta {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-shrink: 0;
        color: #030434;
    }
    .pinned-message .timestamp {
        font-size: 13px;
        font-weight: 200;
        color: #030434;
    }
    .pinned-message:hover, .pinned-message:focus {
        background: linear-gradient(90deg, #e3f2fd 60%, #bbdefb 100%);
        box-shadow: 0 6px 24px rgba(25, 118, 210, 0.15);
        border-color: #42a5f5;
        outline: none;
    }
    .pinned-message .pin-icon {
        color: #ad8b00;
        margin-right: 10px;
        font-size: 1.4em;
        flex-shrink: 0;
    }

    .pinned-message .avatar {
        width: 24px;
        height: 24px;
        border-radius: 50%;
        object-fit: cover;
        border: 1.5px solid #1976d2;
        box-shadow: 0 1px 4px #1976d21a;
    }
    .pinned-message .unpin-button {
        display: flex;
        align-items: center;
        justify-content: center;
        color: #f40f0f;
        background: none;
        border: none;
        cursor: pointer;
        padding: 0;
        box-shadow: none;
        outline: none;
        font-size: 1.1em;
        line-height: 1;
        width: 22px;
        height: 22px;
        border-radius: 50%;
        transition: background 0.15s;
        margin-left: 6px;
    }
    .pinned-message .unpin-button:hover {
        background: #ffeaea;
        color: #b71c1c;
    }

    /* Enhanced #reactionUserModal to match chat system */
    #reactionUserModal.modal {
        display: none;
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        background: linear-gradient(135deg, #f7fafd 0%, #e3f2fd 100%);
        border: 2.5px solid #1976d2;
        border-radius: 20px;
        box-shadow: 0 12px 48px rgba(25, 118, 210, 0.18);
        z-index: 10000;
        min-width: 220px;
        max-width: 350px;
        width: 100%;
        min-height: 80px;
        max-height: 300px;
        padding: 0;
        animation: modalFadeIn 0.35s cubic-bezier(.4,0,.2,1);
        overflow: hidden;
    }
    #reactionUserModal .modal-content {
        padding: 16px 14px 10px 14px;
        background: transparent;
        border-radius: 20px;
        box-shadow: none;
        text-align: left;
        height: 100%;
        display: flex;
        flex-direction: column;
    }
    #reactionUserModal .modal-header {
        padding: 10px 14px 6px 14px;
        background: linear-gradient(90deg, #1976d2 0%, #42a5f5 100%);
        color: #fff;
        border-radius: 20px 20px 0 0;
        font-size: 1.08em;
        font-weight: 600;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    #reactionUserModal .close {
        position: absolute;
        top: 10px;
        right: 18px;
        font-size: 1.5em;
        color: #888;
        cursor: pointer;
        background: none;
        border: none;
        border-radius: 50%;
        transition: background 0.2s, color 0.2s;
        padding: 4px 10px;
        z-index: 1;
    }
    #reactionUserModal .close:hover {
        color: #1976d2;
        background: #e3f2fd;
    }
    #reactionUserModal h3 {
        margin-top: 0;
        margin-bottom: 12px;
        font-size: 1.1em;
        color: #1976d2;
        font-weight: 600;
    }
    #reactionUserModal ul {
        flex: 1 1 auto;
        overflow-y: auto;
        max-height: 180px;
        margin-bottom: 0;
    }
    #reactionUserModal li {
        padding: 8px 0;
        border-bottom: 1px solid #e3f2fd;
        font-size: 1em;
        color: #333;
        transition: background 0.15s, color 0.15s;
    }
    #reactionUserModal li:last-child {
        border-bottom: none;
    }
    #reactionUserModal li:hover {
        background: #e3f2fd;
        color: #1976d2;
        border-radius: 8px;
    }
    #reactionUserModal.modal.show,
    #reactionUserModal.modal.visible {
        display: block;
        opacity: 1;
    }

    @keyframes messageAppear {
        from {
            opacity: 0;
            transform: translateY(20px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    @keyframes reaction-added-pulse {
        0% { opacity: 1; }
        50% { opacity: 0.7; background-color: rgba(76, 175, 80, 0.15); }
        100% { opacity: 1; }
    }
    @keyframes picker-flash {
        0% { transform: scale(1); opacity: 0.7; }
        50% { transform: scale(1.05); opacity: 1; }
        100% { transform: scale(1); opacity: 1; }
    }    
    @keyframes reaction-update-pulse {
        0% { opacity: 1; }
        50% { opacity: 0.7; background-color: rgba(0, 123, 255, 0.1); }
        100% { opacity: 1; }
    }
    @keyframes flash-animation {
        0% { box-shadow: 0 0 0 rgba(13, 110, 253, 0); }
        50% { box-shadow: 0 0 20px rgba(13, 110, 253, 0.7); }
        100% { box-shadow: 0 0 0 rgba(13, 110, 253, 0); }
    }
    @keyframes spin {
        0% { transform: rotate(0deg); }
        100% { transform: rotate(360deg); }
    }
    
    .flash {
        animation: flash-animation 0.3s;
    }
        /* Loading indicators */
    .loading-container {
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 20px;
    }
    
    .loading-spinner {
        border: 3px solid #f0f0f0;
        border-top: 3px solid #007bff;
        border-radius: 50%;
        width: 24px;
        height: 24px;
        animation: spin 1s linear infinite;
        margin-right: 10px;
    }
    
    .loading-text {
        font-size: 14px;
        color: #666;
    }

    /* Mobile optimizations */
    @media (max-width: 900px) {
        .message {
            max-width: 70%;
            font-size: 0.97em;
        }
    }
    
    /* Small mobile devices */
    @media (max-width: 480px) {
        .message {
            max-width: 90%;
        }
        
        .message.message-self {
            max-width: 80%;
        }
        
        .message.message-other {
            max-width: 80%;
        }
    }
    @media (max-width: 500px) {
        #emojiModal {
          width: 95vw;
          min-width: 0;
          padding: 16px 4px;
        }
    }
    @media (max-width: 400px) {
        #notificationHistoryDropdown {
          min-width: 90vw !important;
          max-width: 98vw !important;
          left: 50% !important;
          transform: translateX(-50%) !important;
        }
      }
      
    @media (prefers-color-scheme: dark) {
    #notificationHistoryDropdown {
        background: rgba(30, 41, 59, 0.98) !important;
        border: 1.5px solid #334155 !important;
        color: #e0e7ef !important;
    }
    .notification-history-item {
        background: #1e293b !important;
        color: #60a5fa !important;
    }
    .notification-history-item.unread {
        background: #334155 !important;
        border-left: 4px solid #60a5fa !important;
    }
    }

    #presenceStatusModal .modal-content {
        border-radius: 16px;
        box-shadow: 0 8px 32px rgba(25, 118, 210, 0.10);
        border: 1.5px solid #1976d2;
    }
    
    #presenceStatusModal .modal-header {
        background: linear-gradient(90deg, #1976d2 0%, #42a5f5 100%);
        color: #fff;
        border-radius: 16px 16px 0 0;
    }
    
    #presenceStatusModal .list-group-item {
        display: flex;
        align-items: center;
        font-size: 1.08em;
        border: none;
        border-radius: 8px;
        margin-bottom: 6px;
        transition: background 0.15s, color 0.15s;
    }
    #presenceStatusModal .list-group-item:hover,
    #presenceStatusModal .list-group-item.active {
        background: #e3f2fd;
        color: #1976d2;
        font-weight: 600;
    }
    #presenceStatusModal .presence-indicator {
        margin-right: 12px;
        box-shadow: 0 0 0 2px #fff;
    }
    .presence-status-container .btn-primary {
        background: linear-gradient(90deg, #1976d2 0%, #42a5f5 100%);
        border: none;
        box-shadow: 0 2px 8px rgba(25, 118, 210, 0.18);
    }

    .add-reaction i, .add-reaction svg {
        font-size: 1.5em !important;
        vertical-align: middle;
        color: #fffb00;
    }

    /* 1. Custom scrollbar for thread modal message list */
    .thread-message-list::-webkit-scrollbar,
    #threadMessageList::-webkit-scrollbar {
        width: 6px;
    }
    .thread-message-list::-webkit-scrollbar-thumb,
    #threadMessageList::-webkit-scrollbar-thumb {
        background-color: #ddd;
        border-radius: 3px;
    }
    .thread-message-list::-webkit-scrollbar-thumb:hover,
    #threadMessageList::-webkit-scrollbar-thumb:hover {
        background-color: #ccc;
    }

    /* 2. Thread modal overlay */
    .thread-modal-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(30, 42, 60, 0.35);
        z-index: 1049;
        transition: opacity 0.3s;
        opacity: 0;
    }
    .thread-modal.open ~ .thread-modal-overlay {
        display: block;
        opacity: 1;
    }

    /* 3. Modal and notification fade/slide-in animations */
    @keyframes modalFadeIn {
        from { opacity: 0; transform: translateX(40px); }
        to { opacity: 1; transform: translateX(0); }
    }
    @keyframes modalFadeOut {
        from { opacity: 1; transform: translateX(0); }
        to { opacity: 0; transform: translateX(40px); }
    }
    @keyframes notificationFadeIn {
        from { opacity: 0; transform: translateY(20px); }
        to { opacity: 1; transform: translateY(0); }
    }
    @keyframes notificationFadeOut {
        from { opacity: 1; transform: translateY(0); }
        to { opacity: 0; transform: translateY(20px); }
    }

    /* Apply modal fade/slide-in to modals */
    .thread-modal.open,
    #emojiModal.visible,
    #reactionUserModal.modal.visible {
        animation: modalFadeIn 0.35s cubic-bezier(.4,0,.2,1);
    }
    .thread-modal:not(.open),
    #emojiModal:not(.visible),
    #reactionUserModal.modal:not(.visible) {
        animation: modalFadeOut 0.25s cubic-bezier(.4,0,.2,1);
    }

    /* Apply notification fade/slide-in */
    .notification,
    .thread-notification {
        animation: notificationFadeIn 0.3s cubic-bezier(.4,0,.2,1);
    }
    .notification.fade-out,
    .thread-notification.fade-out {
        animation: notificationFadeOut 0.3s cubic-bezier(.4,0,.2,1);
    }

    /* Notification popup styling */
    .chat-notification {
        background: linear-gradient(90deg, #e3f2fd 60%, #bbdefb 100%);
        color: #1976d2;
        border-radius: 8px;
        box-shadow: 0 4px 16px rgba(25, 118, 210, 0.10);
        padding: 16px 32px 16px 20px;
        margin-bottom: 12px;
        font-size: 1.08em;
        font-weight: 500;
        position: relative;
        min-width: 220px;
        max-width: 350px;
        z-index: 10001;
        display: flex;
        align-items: center;
        animation: notificationFadeIn 0.3s cubic-bezier(.4,0,.2,1);
    }

    /* Notification close button styling */
    .notification-close {
        background: none;
        border: none;
        color: #1976d2;
        font-size: 1.3em;
        font-weight: bold;
        position: absolute;
        top: 8px;
        right: 14px;
        cursor: pointer;
        padding: 0;
        line-height: 1;
        z-index: 2;
        opacity: 0.7;
        transition: opacity 0.2s, color 0.2s;
    }
    .notification-close:hover {
        opacity: 1;
        color: #0d47a1;
    }

    /* Notification icon/content alignment */
    .chat-notification .notification-content {
        display: flex;
        align-items: center;
        gap: 10px;
    }
    .chat-notification i {
        font-size: 1.3em;
        margin-right: 8px;
        color: #1976d2;
    }
    .chat-notification.mention-notification {
        position: fixed;
        bottom: 450px;
        left: 50%;
        transform: translateX(-50%);
        background: linear-gradient(90deg, #1976d2 0%, #42a5f5 100%);
        color: #fff;
        padding: 16px 32px;
        border-radius: 10px;
        box-shadow: 0 6px 24px rgba(25, 118, 210, 0.10);
        font-size: 1.1rem;
        font-weight: 500;
        z-index: 10000;
        opacity: 0.97;
        border: 1.5px solid #1976d2;
        transition: opacity 0.3s, bottom 0.3s;
        pointer-events: none;
        text-align: center;
        letter-spacing: 0.02em;
    }
    .chat-notification.mention-notification .notification-header {
        font-weight: bold;
        color: #fff;
        margin-bottom: 4px;
    }
    .chat-notification.mention-notification .notification-body {
        color: #e3f2fd;
    }
    .chat-notification.mention-notification.fade-out {
        opacity: 0;
        transition: opacity 0.5s;
    }

    #notificationHistoryDropdown {
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
        min-width: 260px !important;
        max-width: 300px !important;
        width: 100% !important;
        background: rgba(247, 250, 253, 0.95) !important;
        border-radius: 16px !important;
        box-shadow: 0 12px 32px rgba(25, 118, 210, 0.18) !important;
        backdrop-filter: blur(6px);
        padding: 10px 0 !important;
        font-size: 1.07em !important;
        border: 1.5px solid #e3f2fd !important;
        overflow: visible !important;
        transition: box-shadow 0.2s, background 0.2s;
    }
    .notification-history-item {
        padding-top: 14px !important;
        padding: 12px 22px !important;
        padding-bottom: 14px !important;
        border-bottom: 1px solid #e3f2fd5a !important;
        word-break: break-word;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        background: #fafdff !important;
        color: #1976d2 !important;
        font-size: 1.04em !important;
        cursor: pointer;
        transition: background 0.15s, box-shadow 0.15s;
        transform: scale(1.01);
    }
    .notification-history-item:hover {
        background: #e3f2fd !important;
        box-shadow: 0 2px 8px rgba(34, 122, 210, 0.666);
    }
    .notification-history-item.unread {
        background: #e3f2fd !important;
        font-weight: 600 !important;
        border-left: 4px solid #1976d2 !important;
    }
    .notification-history-item:last-child {
        border-bottom: none !important;
    }
    .notification-history-item .mark-read-btn {
        background: none;
        border: none;
        color: #1976d2;
        font-size: 1em;
        cursor: pointer;
        margin-left: 8px;
        padding: 2px 6px;
        border-radius: 6px;
        transition: background 0.15s;
    }
    .notification-history-item .mark-read-btn:hover {
        background: #bbdefb;    
    }
    .notification-dropdown .dropdown-menu .notification-history-item,
    .notification-dropdown .dropdown-menu .notification-history-item * {
    color: #1976d2 !important;
    font-weight: 700 !important;
    }
    .navbar,
    .navbar-nav,
    .navbar-nav.ms-auto,
    .nav-item,
    .notification-dropdown {
        overflow: visible !important;
    }
    #notificationBadge {
        font-size: 0.82em !important;
        z-index: 100 !important;
        top: -8px !important;
        right: -10px !important; 
        min-width: 22px !important;
        min-height: 22px !important;
        padding: 2px 6px !important;
        border-radius: 50% !important;
        display: flex;
        align-items: center !important;
        justify-content: center !important;
        position: absolute !important;
        background: #ef4444 !important;
        color: #fff !important;
        border: 1px solid #fff !important;
        font-weight: 500 !important;
        box-shadow: 0 2px 8px rgba(239, 68, 68, 0.18);
        transition: background 0.2s, box-shadow 0.2s;
    }
    @keyframes badge-pulse {
        0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
        70% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
        100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
    }
    #notificationBadge.pulse {
        animation: badge-pulse 1s;
    }
    #clearAllNotifications {
        margin: 4px 0 0 0;
        font-size: 0.9em !important;
        color: #1976d2 !important;
        font-weight: 500 !important;
    }    
    .navbar .fa-bell {
        font-size: 1.5em; /* Adjust as needed */
    }

    .file-preview {
        max-width: 240px;
        max-height: 240px;
        border-radius: 12px;
        box-shadow: 0 4px 16px rgba(0,0,0,0.13);
        object-fit: contain;
        border: 1.5px solid #1976d2;
        display: block;
        margin-bottom: 14px;
    }
    .file-icon {
        font-size: 3.5em;
        display: block; 
        color: #1976d2;
        margin: 0 auto 8px auto;
        text-align: center;
        background: #fff;
        border-radius: 14px;
        padding: 0;
        box-shadow: 0 2px 8px rgba(currentColorRGB, 0.15);
    }
    .file-icon-pdf { color: #F40F02; }
    .file-icon-word { color: #2B579A; }
    .file-icon-excel { color: #217346; }
    .file-icon-ppt { color: #D24726; }
    .file-icon-txt { color: #616161; }
    .file-icon-csv { color: #616161; }

    .upload-progress-bar {
        width: 100%;
        height: 8px;
        background: #e3f2fd;
        border-radius: 6px;
        overflow: hidden;
        margin-top: 8px;
        margin-bottom: 8px;
    }
    .upload-progress-bar-inner {
        height: 100%;
        background: linear-gradient(90deg, #19d266 0%, #42f57e 100%);
        border-radius: 6px;
        transition: width 0.2s;
    }
    .file-size-warning {
        color: #e53935;
        background: #fff3f3;
        border: 1px solid #e53935;
        border-radius: 8px;
        padding: 8px 16px;
        margin: 8px 0;
        font-weight: 500;
    }
    /* Stack file meta info below the preview */
    .file-attachment {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0;
        width: 100%;
        margin-top: 4px;
        box-shadow: 0 2px 8px rgba(currentColorRGB, 0.15);
        transition: background var(0.2s);
    }
    .file-attachment:hover {
        background: rgba( currentColorRGB, 0.05 );
        box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    }
    .file-meta {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        font-size: 0.98em;
        color: #555;
        margin-top: 2px;
        gap: 2px;
    }
    .file-meta-row {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 10px;
    }
    .file-download-link {
        font-size: 1em;
        color: #fff;
        text-decoration: underline;
        font-weight: 200;
        cursor: pointer;
        margin-bottom: 0;
        margin-right: 0;
        transition: color 0.15s;
    }
    .file-download-link:hover, .file-download-link:focus {
        color: #1976d2;
        text-decoration: underline;
    }
    .file-type, .file-size {
        font-size: 0.69em;
        color: #0d2340;
        background: #fff;
        border-radius: 4px;
        padding: 0.1px 3px;
        margin-left: 0;
        font-weight: 300;
        margin-top: 0;
        margin-bottom: 0;
        box-shadow: 0 1px 4px #0001;
        display: inline-block;
    }

    #notificationContainer,
    .flash-messages-container,
    .chat-notification {
      position: fixed !important;
      top: 110px !important;
      right: 20px !important;
      max-width: 350px !important;
      z-index: 10001 !important;
      width: 100%;
      box-sizing: border-box;
      pointer-events: auto;
    }

    @media (max-width: 500px) {
      #notificationContainer,
      .flash-messages-container,
      .chat-notification {
        right: 5px !important;
        left: 5px !important;
        max-width: 98vw !important;
      }
    }