/**
 * Chat Application Styles
 * Desktop chat interface for NhatrovN
 */


/* ===== Base Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f5f5f5;
    height: 100vh;
    overflow: hidden;
}

.chat-container {
    display: flex;
    height: 100vh;
    background: white;
}

/* ===== Sidebar ===== */
.sidebar {
    width: 400px;
    min-width: 250px;
    max-width: 600px;
    background: #2563eb;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e5e7eb;
    position: relative;
    transition: width 0.1s ease-out;
}

/* Resize Handle */
.sidebar-resize-handle {
    position: absolute;
    top: 0;
    right: 0;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    background: transparent;
    z-index: 10;
    transition: background-color 0.2s;
}

.sidebar-resize-handle:hover {
    background: rgba(255, 255, 255, 0.2);
}

.sidebar-resize-handle.resizing {
    background: rgba(255, 255, 255, 0.4);
}

.sidebar-resize-handle::after {
    content: '';
    position: absolute;
    top: 0;
    left: -3px;
    right: -3px;
    height: 100%;
}

.sidebar.resizing {
    transition: none;
    user-select: none;
}

body.resizing-sidebar {
    cursor: col-resize;
    user-select: none;
}

.sidebar-header {
    background: #1e40af;
    padding: 8px 10px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.sidebar-header-left {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    flex-shrink: 1;
    min-width: 0;
    max-width: 100%;
}

.sidebar-logo a {
    display: flex;
    align-items: center;
    text-decoration: none;
    min-width: 0;
    max-width: 100%;
}

.sidebar-logo img {
    height: 32px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
}

.sidebar-user-info {
    font-size: 0.75rem;
    font-weight: normal;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    padding-left: 2px;
}

.sidebar-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Sidebar Buttons */
.sidebar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 36px;
    padding: 0 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: white;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.sidebar-btn .material-symbols-outlined {
    font-size: 20px;
    color: white;
    line-height: 1;
}

.sidebar-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
}

.sidebar-btn:active {
    transform: translateY(0);
}

/* Settings Button */
.settings-btn {
    width: 36px;
    padding: 0;
}

/* Logout Button */
.logout-btn {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.9) 0%, rgba(220, 38, 38, 0.9) 100%);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.logout-btn:hover {
    background: linear-gradient(135deg, rgba(220, 38, 38, 1) 0%, rgba(185, 28, 28, 1) 100%);
    border-color: rgba(255, 255, 255, 0.6);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
    transform: translateY(-2px);
}

.logout-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.logout-text {
    font-weight: 600;
    letter-spacing: 0.3px;
}

.search-container {
    padding: 6px 10px;
    background: #2563eb;
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-input {
    flex: 1;
    padding: 6px 10px;
    padding-right: 32px;
    border: none;
    border-radius: 20px;
    font-size: 14px;
}

.search-clear-btn {
    position: absolute;
    right: 24px;
    width: 24px;
    height: 24px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
}

.search-clear-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.search-clear-btn:active {
    transform: scale(0.95);
}

.search-clear-btn .material-symbols-outlined {
    font-size: 16px;
    line-height: 1;
}

.search-container.searching {
    opacity: 0.8;
}

.search-loading {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* ===== Tabs ===== */
.tabs {
    display: flex;
    background: #2563eb;
    padding: 0 10px;
}

.tab {
    flex: 1;
    padding: 6px 0px;
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    font-size: 14px;
    font-weight: 500;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.tab.active {
    color: white;
    border-bottom-color: white;
}

.tab-unread-badge {
    background: #dc2626;
    color: white;
    border-radius: 10px;
    padding: 1px 5px;
    font-size: 11px;
    min-width: 16px;
    text-align: center;
    font-weight: 600;
    line-height: 1.4;
}

.tab.active .tab-unread-badge {
    background: #ef4444;
}

/* ===== Conversation List ===== */
.conversation-list {
    flex: 1;
    overflow-y: auto;
    background: white;
}

.conversation-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #e0e0e0;
    transition: background-color 0.2s;
    position: relative;
}

.conversation-item:hover {
    background-color: #f9fafb;
}

.conversation-item.active {
    background-color: #e0f2fe !important;
}

.conversation-item.pinned {
    background-color: var(--gray-100);
    border-left: 3px solid var(--gray-300);
}

.avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #3b82f6;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    margin-right: 12px;
    flex-shrink: 0;
}

.conversation-info {
    flex: 1;
    min-width: 0;
}

.conversation-name {
    display: flex;
    align-items: center;
    font-weight: 600;
    font-size: 15px;
    color: #111827;
    margin-bottom: 2px;
    min-width: 0; /* Important for flex child truncation */
}

.conversation-name-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0; /* Important for ellipsis to work in flex */
}

.conversation-preview {
    font-size: 13px;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-preview-sender {
    color: #3b82f6;
    font-weight: 500;
}

.conversation-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    margin-left: 8px;
}

.conversation-time {
    font-size: 12px;
    color: #9ca3af;
    margin-bottom: 4px;
}

.unread-badge {
    background: #dc2626;
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 12px;
    min-width: 18px;
    text-align: center;
}

.conversation-item.active .unread-badge {
    display: none;
}

.mention-badge {
    background: #2563eb;
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 12px;
    min-width: 18px;
    text-align: center;
    font-weight: 600;
    margin-top: 2px;
}

.conversation-item.active .mention-badge {
    display: none;
}

.muted-indicator {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0; /* Prevent icon from shrinking */
    margin-left: 6px;
    opacity: 0.6;
}

.muted-indicator .material-symbols-outlined {
    font-size: 16px;
    color: #6b7280;
}

.search-result-badge {
    background: #059669;
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 12px;
    min-width: 18px;
    text-align: center;
    font-weight: 600;
    margin-top: 2px;
}

.search-results-section {
    margin-top: 8px;
}

.search-results-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: white;
    padding: 12px 16px;
    border-bottom: 1px solid #f3f4f6;
    font-weight: 600;
    color: #6b7280;
    font-size: 13px;
}

.online-indicator {
    width: 12px;
    height: 12px;
    background: #10b981;
    border-radius: 50%;
    border: 2px solid white;
    position: absolute;
    bottom: 8px;
    right: 56px;
}

/* ===== Main Chat Area ===== */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
}

#chatArea {
    display: flex;
    flex-direction: column;
    flex: 1;
    height: 100%; /* Ensure it takes full height of parent */
    min-height: 0; /* Allow it to shrink */
}

.chat-header {
    padding: 12px 20px;
    border-bottom: 1px solid #e5e7eb;
    background: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header-info {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 4px 8px;
    margin: -4px -8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.chat-header-info:hover {
    background: rgba(0, 0, 0, 0.05);
}

.chat-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #3b82f6;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    margin-right: 12px;
}

.chat-header-details h3 {
    font-size: 16px;
    color: #111827;
    margin-bottom: 2px;
}

.chat-header-details p {
    font-size: 12px;
    color: #10b981;
}

.chat-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    color: #374151;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.action-btn .material-symbols-outlined {
    font-size: 18px;
    line-height: 1;
}

.action-btn:hover {
    background: #f3f4f6;
}

/* ===== Conversation Search (Telegram-style) ===== */
.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Chat Header States - Telegram-style inline search */
.chat-header-normal {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.chat-header-search {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 0 4px;
}

.chat-header-search .chat-header-avatar {
    margin-right: 0;
}

.chat-header-search .search-icon {
    font-size: 20px;
    color: #9ca3af;
}

.conversation-search-toggle {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.conversation-search-toggle:hover {
    background: #f3f4f6;
}

.conversation-search-toggle .material-symbols-outlined {
    font-size: 20px;
    color: #6b7280;
}

.conversation-search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px;
    background: transparent;
    color: #1f2937;
}

.conversation-search-input::placeholder {
    color: #9ca3af;
}

.search-navigation {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-counter {
    font-size: 13px;
    color: #6b7280;
    white-space: nowrap;
    min-width: 60px;
    text-align: center;
}

.search-nav-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.search-nav-btn:hover {
    background: #f3f4f6;
}

.search-nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.search-nav-btn .material-symbols-outlined {
    font-size: 20px;
    color: #6b7280;
}

.conversation-search-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    margin-right: 8px;
}

.conversation-search-close:hover {
    background: #f3f4f6;
}

.conversation-search-close .material-symbols-outlined {
    font-size: 20px;
    color: #6b7280;
}

/* Search Results Dropdown (Telegram-style) */
.conversation-search-results {
    position: relative;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    overflow-y: auto;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.conversation-search-results[style*="display: block"],
.conversation-search-results.active {
    max-height: 400px;
    opacity: 1;
}

.conversation-search-header {
    padding: 8px 16px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.conversation-search-empty {
    padding: 40px 16px;
    text-align: center;
    color: #9ca3af;
    font-size: 14px;
}

.conversation-search-result {
    display: flex;
    align-items: flex-start;
    padding: 12px 16px;
    gap: 12px;
    cursor: pointer;
    transition: background-color 0.15s;
    border-bottom: 1px solid #f3f4f6;
}

.conversation-search-result:hover {
    background: #f9fafb;
}

.conversation-search-result.active {
    background: #eff6ff;
    border-left: 3px solid #3b82f6;
}

.search-result-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.search-result-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.search-result-avatar .avatar-text {
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
}

.search-result-content {
    flex: 1;
    min-width: 0;
}

.search-result-username {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 4px;
}

.search-result-text {
    font-size: 13px;
    color: #6b7280;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.search-result-text mark {
    background: #fef3c7;
    color: #92400e;
    padding: 0 2px;
    border-radius: 2px;
}

/* ===== Pinned Messages Section ===== */
.pinned-messages-section {
    border-bottom: 1px solid #e5e7eb;
    padding: 4px 0;
}

.pinned-messages-header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 24px;
    cursor: pointer;
}

.pinned-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    color: var(--primary-blue);
    padding: 4px;
    transition: transform 0.2s;
    flex-shrink: 0; /* Prevent toggle from shrinking */
    margin-left: auto; /* Push toggle to the right end */
}

.pinned-toggle.collapsed {
    transform: rotate(-90deg);
}

.pinned-messages-content {
    padding: 0 24px;
    max-height: 300px;
    overflow-y: auto;
    display: flex;
    flex-direction: row;
}

.pinned-messages-content.collapsed {
    display: none;
}

.pinned-message-item {
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: all 0.2s;
}

.pinned-message-item:hover {
    background: #f3f4f6;
}

.pinned-message-item:last-child {
    margin-bottom: 0;
}

.pinned-icon {
    display: flex;
    align-items: center;
}

.pinned-icon .material-symbols-outlined {
    font-size: 20px;
    color: #ca8a04; /* Yellow-700: Pin icon maintains its distinctive color */
}

.pinned-message-user {
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
    flex-shrink: 0;
}

.pinned-message-text {
    font-size: 13px;
    color: #374151;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* ===== Messages Container ===== */
.messages-container {
    flex: 1;
    padding: 16px 24px;
    overflow-y: auto;
    background: #f9fafb;
    min-height: 0; /* Critical: allows flex item to shrink below content size */
    height: 0; /* Forces the flex container to respect flex: 1 and not grow beyond available space */
}

/* ===== Jump Buttons (Mention, Last Read, Scroll to Bottom) ===== */
/* Jump to Mention Button */
.jump-to-mention-btn {
    position: absolute;
    bottom: 260px;
    right: 12px;
    background: white;
    border: 1px solid #f59e0b;
    border-radius: 24px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.2);
    transition: all 0.3s ease;
    z-index: 100;
    font-size: 14px;
    font-weight: 500;
    color: #92400e;
}

.jump-to-mention-btn:hover {
    background: #fffbeb;
    box-shadow: 0 6px 16px rgba(245, 158, 11, 0.3);
    transform: translateY(-2px);
}

.jump-to-mention-btn:active {
    transform: translateY(0);
}

.jump-to-mention-btn .jump-btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.jump-to-mention-btn .jump-btn-icon.material-symbols-outlined {
    font-size: 20px;
    width: 24px;
    height: 24px;
    background: #f59e0b;
    color: white;
    border-radius: 50%;
}

/* Jump to Last Read Button */
.jump-to-read-btn {
    position: absolute;
    bottom: 200px;
    right: 12px;
    background: white;
    border: 1px solid #8b5cf6;
    border-radius: 24px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.2);
    transition: all 0.3s ease;
    z-index: 100;
    font-size: 14px;
    font-weight: 500;
    color: #5b21b6;
}

.jump-to-read-btn:hover {
    background: #faf5ff;
    box-shadow: 0 6px 16px rgba(139, 92, 246, 0.3);
    transform: translateY(-2px);
}

.jump-to-read-btn:active {
    transform: translateY(0);
}

.jump-to-read-btn .jump-btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.jump-to-read-btn .jump-btn-icon.material-symbols-outlined {
    font-size: 20px;
    width: 24px;
    height: 24px;
    background: #8b5cf6;
    color: white;
    border-radius: 50%;
}

/* Scroll to Bottom Button - Modern circular icon-only design */
.scroll-to-bottom-btn {
    position: absolute;
    bottom: 140px;
    right: 12px;
    width: 44px;
    height: 44px;
    background: white;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
    z-index: 100;
}

.scroll-to-bottom-btn:hover {
    background: #f9fafb;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transform: scale(1.05);
}

.scroll-to-bottom-btn:active {
    transform: scale(0.95);
}

.scroll-to-bottom-btn .material-symbols-outlined {
    font-size: 24px;
    color: #3b82f6;
    font-weight: 500;
}

.jump-btn-text {
    white-space: nowrap;
}

/* Slide in animation */
@keyframes slideInFromBottom {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.jump-to-mention-btn.show,
.jump-to-read-btn.show,
.scroll-to-bottom-btn.show {
    animation: slideInFromBottom 0.3s ease;
}

/* ===== Message Wrapper (contains message + action buttons) ===== */
.message-wrapper {
    position: relative;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    flex-direction: row; /* Default: message on left, actions on right */
    transition: background-color 0.15s ease;
    border-radius: 8px;
    padding: 4px;
    margin-left: -4px;
    margin-right: -4px;
}

/* Highlighted state when context menu is open */
.message-wrapper.context-menu-active {
    background-color: rgba(59, 130, 246, 0.08);
}

.message-wrapper.context-menu-active .message-content {
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15);
}

/* For sent messages, reverse the wrapper direction */
.message-wrapper:has(.message.sent) {
    flex-direction: row-reverse; /* Actions on left, message on right */
}

.message {
    display: flex;
    /* flex: 1; */ /* Removed to make actions sit next to message */
}

.message.sent {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #6b7280;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: bold;
    margin: 0 8px;
    flex-shrink: 0;
}


.message-content {
    /* max-width: 70%; */
    background: white;
    border-radius: 16px;
    padding: 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    position: relative;
}

.message.sent .message-content {
    background: #d0f0fd;
}

/* .message.image-message.sent .message-content {
    background: transparent;
} */

.message-user-name {
    font-size: 12px;
    font-weight: 600;
    color: #3b82f6;
    margin-bottom: 4px;
    padding: 12px 16px 0;
}

/* ===== Reply Message Styles ===== */
.message-reply {
    margin: 0 16px 8px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 8px;
    padding-top: 8px;
    border-left: 3px solid #3b82f6;
    position: relative;
}

.message.sent .message-reply {
    background: rgba(255, 255, 255, 0.15);
    border-left-color: rgba(255, 255, 255, 0.6);
}


.reply-content {
    min-width: 0;
}

.reply-author {
    font-size: 11px;
    font-weight: 600;
    color: #3b82f6;
    margin-bottom: 2px;
    padding: 0 8px;
}

.reply-content-body .message-text {
    padding: 0 8px;
    font-size: 12px;
    margin-bottom: 0;
}

.reply-content-body {
    font-size: 12px;
    color: #6b7280;
    line-height: 1.3;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-word;
    padding: 0 8px;
}

.message-text {
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: 4px;
    padding: 0 16px;
    white-space: pre-wrap; /* Preserve whitespace and wrap text */
    word-break: break-word; /* Force break anywhere to prevent overflow */
    word-wrap: break-word; /* Break long words if needed */
    overflow-wrap: break-word; /* Modern alternative to word-wrap */
}

/* ===== Message Links ===== */
.message-link {
    color: #2563eb;
    text-decoration: underline;
    word-break: break-all;
    transition: color 0.2s;
}

.message-link:hover {
    color: #1d4ed8;
    text-decoration: underline;
}

.message-link:visited {
    color: #7c3aed;
}

/* ===== Message Mentions ===== */
.message-mention {
    color: #2563eb;
    font-weight: 500;
    background-color: rgba(37, 99, 235, 0.1);
    padding: 1px 4px;
    border-radius: 3px;
}

/* ===== Mention Indicator ===== */
.message-mention-indicator {
    margin: 0 16px 8px;
    background: rgba(251, 191, 36, 0.1);
    border-radius: 8px;
    padding: 8px 12px;
    border-left: 3px solid #fbbf24;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.message.sent .message-mention-indicator {
    background: rgba(251, 191, 36, 0.15);
    border-left-color: #f59e0b;
}

.mention-icon {
    font-size: 16px;
    font-weight: bold;
    color: #f59e0b;
}

.mention-text {
    flex: 1;
    color: #92400e;
    font-weight: 500;
}

.mention-jump-btn {
    padding: 4px 12px;
    background: #fbbf24;
    color: #78350f;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.mention-jump-btn:hover {
    background: #f59e0b;
    transform: translateY(-1px);
}

.mention-jump-btn:active {
    transform: translateY(0);
}

.message-image img {
    /* max-width: 300px; */
    max-height: 500px;
    cursor: pointer;
    transition: transform 0.2s ease;
    /* box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); */
}

.message-image-error {
    display: none;
    padding: 10px;
    background: #f0f0f0;
    color: #666;
}

/* ===== Multiple Images Layouts ===== */
.message-images-container {
    margin-top: 0.5rem;
}

/* Ensure images fill their containers properly */
.message-image-item {
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
}

.message-image-item img {
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.message-image-item:hover img {
    transform: scale(1.02);
}

/* Single image layout */
.message-images-single img {
    border-radius: 8px;
    max-width: 100%;
    height: auto;
}

/* Two images - side by side */
.message-images-two .message-image-item {
    border-radius: 6px;
}

/* Three images - asymmetric layout */
.message-images-three .message-image-item:first-child {
    border-radius: 6px 0 0 6px;
}

.message-images-three .message-image-item:nth-child(2) {
    border-radius: 0 6px 0 0;
}

.message-images-three .message-image-item:nth-child(3) {
    border-radius: 0 0 6px 0;
}

/* Four images - grid */
.message-images-four .message-image-item:nth-child(1) {
    border-radius: 6px 0 0 0;
}

.message-images-four .message-image-item:nth-child(2) {
    border-radius: 0 6px 0 0;
}

.message-images-four .message-image-item:nth-child(3) {
    border-radius: 0 0 0 6px;
}

.message-images-four .message-image-item:nth-child(4) {
    border-radius: 0 0 6px 0;
}

/* Five images layout */
.message-images-five .message-image-item:first-child {
    border-radius: 6px 0 0 0;
}

.message-images-five .message-image-item:nth-child(2) {
    border-radius: 0 6px 0 0;
}

.message-images-five .message-image-item:nth-child(3) {
    border-radius: 0 0 0 6px;
}

.message-images-five .message-image-item:last-child {
    border-radius: 0 0 6px 0;
}

/* Many images - with overlay count */
.image-overlay-more {
    cursor: pointer;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .message-images-container > div {
        max-width: 100% !important;
    }

    .message-images-five,
    .message-images-six,
    .message-images-many {
        aspect-ratio: auto !important;
    }
}

/* ===== Failed Message States ===== */
.message-content.message-failed {
    opacity: 0.8;
}

.message-content.message-failed {
    border-left: 3px solid #ef4444;
    border-right: 3px solid #ef4444;
}

.message-error-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
}

.message-error-indicator .error-icon {
    font-size: 18px;
    animation: pulse-error 2s ease-in-out infinite;
}

@keyframes pulse-error {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.resend-button {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.resend-button:hover {
    background: #dc2626;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

.resend-button:active {
    transform: translateY(0);
}

.resend-button .material-symbols-outlined {
    font-size: 16px;
}

/* ===== Reaction Styles ===== */
.message-reactions {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
}

.reaction {
    display: inline-flex;
    align-items: center;
    background: rgba(107, 114, 128, 0.1);
    border-radius: 12px;
    padding: 2px 6px;
    border: 1px solid rgba(107, 114, 128, 0.2);
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 24px;
}

.reaction:hover {
    background: rgba(107, 114, 128, 0.2);
    transform: scale(1.05);
}


.reaction-emoji {
    font-size: 14px;
    line-height: 1;
    margin-right: 3px;
}

.reaction-count {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    line-height: 1;
    min-width: 8px;
    text-align: center;
}

.reaction.user-reacted {
    background: #3b82f6;
    border-color: #2563eb;
}

.reaction.user-reacted .reaction-count {
    color: white;
    font-weight: bold;
}

.reaction-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 14px;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.reaction-button .material-symbols-outlined {
    font-size: 18px;
    color: #6b7280; /* Grey-500: Good contrast on light grey background */
}

.reaction-button .reaction-emoji-display {
    font-size: 16px;
    line-height: 1;
}

.reaction-button:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
    transform: scale(1.1);
}

.reaction-button:hover .material-symbols-outlined {
    color: #374151; /* Grey-700: Darker on hover */
}

.reaction-button.active .material-symbols-outlined {
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    color: #dc2626; /* Red-600: Filled heart */
}

.reaction-button.active:hover {
    background: #fecaca;
    border-color: #fca5a5;
    transform: scale(1.1);
}

/* ===== Reaction Picker ===== */
.reaction-button-container {
    position: relative;
    display: inline-flex;
}

.reaction-picker {
    position: absolute;
    bottom: calc(100% + 4px);
    right: 0;
    display: none;
    flex-direction: row;
    gap: 2px;
    padding: 4px;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    animation: reactionPickerFadeIn 0.2s ease;
    pointer-events: auto;
}

/* Bridge element to prevent picker from disappearing when moving mouse */
.reaction-picker::before {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    right: 0;
    height: 4px;
    background: transparent;
}

@keyframes reactionPickerFadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.reaction-picker-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 15px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: transparent;
}

.reaction-picker-item:hover {
    background: #f3f4f6;
    transform: scale(1.15);
}


.message-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
    padding: 0 16px 12px;
}

.message-footer-left {
    display: flex;
    align-items: center;
}

.message-footer-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.message-time {
    font-size: 11px;
    color: #9ca3af;
    flex-shrink: 0;
}

/* ===== Message Action Buttons ===== */
.message-actions {
    display: flex;
    flex-direction: row;
    gap: 4px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    align-self: flex-end;
    flex-shrink: 0; /* Prevent actions from shrinking */
}

/* Reverse button order for sent messages */
.message-wrapper:has(.message.sent) .message-actions {
    flex-direction: row-reverse;
}

.message-wrapper:hover .message-actions {
    opacity: 1;
    visibility: visible;
}

.message-action-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 0;
}

.message-action-btn:hover {
    background: #f3f4f6;
    transform: scale(1.1);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.message-action-btn:active {
    transform: scale(0.95);
}

.message-action-btn .action-icon {
    font-size: 20px;
    line-height: 1;
    color: #6b7280; /* Grey-500: Clear visibility on white background */
}

/* Specific hover colors for each action */
.message-action-btn[data-action="reply"]:hover {
    background: #dbeafe;
}

.message-action-btn[data-action="reply"]:hover .action-icon {
    color: #2563eb;
}

.message-action-btn[data-action="edit"]:hover {
    background: #fef3c7;
}

.message-action-btn[data-action="edit"]:hover .action-icon {
    color: #d97706;
}

.message-action-btn[data-action="forward"]:hover {
    background: #ddd6fe;
}

.message-action-btn[data-action="forward"]:hover .action-icon {
    color: #7c3aed;
}

.message-action-btn[data-action="pin"]:hover {
    background: #fef9c3;
}

.message-action-btn[data-action="pin"]:hover .action-icon {
    color: #ca8a04;
}

.message-action-btn[data-action="delete"]:hover {
    background: #fee2e2;
}

.message-action-btn[data-action="delete"]:hover .action-icon {
    color: #dc2626;
}

/* ===== Message Action Preview (Reply/Edit/Forward) ===== */
.message-action-preview {
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.action-preview-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.action-preview-icon {
    font-size: 20px;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.action-preview-icon.reply {
    background: #dbeafe;
    color: #2563eb;
}

.action-preview-icon.edit {
    background: #fef3c7;
    color: #d97706;
}

.action-preview-icon.forward {
    background: #ddd6fe;
    color: #7c3aed;
}

.action-preview-details {
    flex: 1;
    min-width: 0;
}

.action-preview-title {
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 2px;
}

.action-preview-text {
    font-size: 13px;
    color: #6b7280;
    word-break: break-all;
}

.action-preview-close {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: #9ca3af;
    font-size: 18px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.action-preview-close:hover {
    background: #e5e7eb;
    color: #374151;
}

/* ===== Typing Indicator ===== */
.typing-indicator {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: white;
    border-radius: 16px;
    margin: 8px 24px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.typing-dots {
    display: flex;
    gap: 4px;
    margin-left: 8px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* ===== Input Area ===== */
.chat-input-container {
    padding: 8px;
    background: white;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0; /* Prevent input from being compressed */
}

.chat-input-wrapper {
    position: relative; /* Positioning context for mention dropdown */
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 4px 4px 16px;
    background: #f9fafb;
    border-radius: 24px;
    border: 1px solid #e5e7eb;
}

.chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    color: #111827;
    resize: none;
    outline: none;
    min-height: 20px;
    max-height: 100px;
    line-height: 20px;
}

.chat-input::placeholder {
    color: #9ca3af;
    opacity: 1;
}

.input-actions {
    display: flex;
    gap: 4px;
}

.input-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    transition: all 0.2s ease;
    padding: 0;
    position: relative;
}

.input-btn .material-symbols-outlined {
    font-size: 22px;
    color: #6b7280; /* Grey-500: Good contrast on transparent/light background */
    transition: all 0.2s ease;
}

.input-btn:hover {
    background: #e5e7eb;
    transform: scale(1.05);
}

.input-btn:hover .material-symbols-outlined {
    color: #374151; /* Grey-700: Darker on hover */
}

.input-btn:active {
    transform: scale(0.95);
}

/* Send Button - Modern Design */
.send-btn {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
    width: 40px !important;
    height: 40px !important;
}

.send-btn .material-symbols-outlined {
    color: white !important;
    font-size: 24px;
    font-variation-settings: 'FILL' 1, 'wght' 500;
}

.send-btn:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%) !important;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    transform: scale(1.08);
}

.send-btn:active {
    transform: scale(0.92);
    box-shadow: 0 1px 4px rgba(59, 130, 246, 0.3);
}

.send-btn:disabled {
    background: #d1d5db !important;
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.6;
    transform: none !important;
}

.send-btn:disabled .material-symbols-outlined {
    color: #9ca3af !important;
    font-variation-settings: 'FILL' 0, 'wght' 400;
}

/* ===== Emoji Picker Styles ===== */
.emoji-picker-wrapper {
    position: relative;
}

.emoji-picker {
    position: absolute;
    bottom: 45px;
    right: 0;
    width: 320px;
    max-height: 380px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.95);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.emoji-picker.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.emoji-picker-header {
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    background: #f9fafb;
    border-radius: 12px 12px 0 0;
}

.emoji-picker-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    padding: 12px;
    overflow-y: auto;
    max-height: 320px;
}

.emoji-picker-grid::-webkit-scrollbar {
    width: 6px;
}

.emoji-picker-grid::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 3px;
}

.emoji-picker-grid::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.emoji-picker-grid::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

.emoji-item {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.15s ease;
    user-select: none;
}

.emoji-item:hover {
    background: #f3f4f6;
    transform: scale(1.15);
}

.emoji-item:active {
    transform: scale(1.05);
}

/* ===== Mention Dropdown Styles ===== */
.mention-dropdown-wrapper {
    position: relative;
}

.mention-dropdown {
    position: absolute;
    bottom: 100%;
    left: 0;
    width: 300px;
    max-height: 280px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.95);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    margin-bottom: 8px;
}

.mention-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.mention-dropdown-header {
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    background: #f9fafb;
    border-radius: 12px 12px 0 0;
}

.mention-dropdown-list {
    overflow-y: auto;
    max-height: 240px;
}

.mention-dropdown-list::-webkit-scrollbar {
    width: 6px;
}

.mention-dropdown-list::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 3px;
}

.mention-dropdown-list::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.mention-dropdown-list::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

.mention-user-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    gap: 12px;
}

.mention-user-item:hover,
.mention-user-item.selected {
    background: #f3f4f6;
}

.mention-user-item:active {
    background: #e5e7eb;
}

.mention-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #3b82f6;
    color: white;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}

.mention-user-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.mention-user-info {
    flex: 1;
    min-width: 0;
}

.mention-user-name {
    font-size: 14px;
    font-weight: 500;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mention-user-role {
    font-size: 12px;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.mention-empty-state {
    padding: 24px 16px;
    text-align: center;
    color: #9ca3af;
    font-size: 13px;
}

/* Mention tag styling in messages */
.mention-tag {
    display: inline;
    padding: 2px 6px;
    background: rgba(59, 130, 246, 0.1);
    color: #2563eb;
    border-radius: 4px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.mention-tag:hover {
    background: rgba(59, 130, 246, 0.2);
}

/* ===== Empty State ===== */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    text-align: center;
}

.empty-state h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: #374151;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .sidebar {
        width: 280px;
    }
    
    .chat-header {
        padding: 10px 14px;
    }
    
    .messages-container {
        padding: 12px 16px;
    }
    
    .chat-input-container {
        padding: 12px 16px;
    }
}

/* ===== Custom Scrollbars ===== */
.conversation-list::-webkit-scrollbar,
.messages-container::-webkit-scrollbar {
    width: 6px;
}

.conversation-list::-webkit-scrollbar-track,
.messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.conversation-list::-webkit-scrollbar-thumb,
.messages-container::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.conversation-list::-webkit-scrollbar-thumb:hover,
.messages-container::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ===== Clickable Reply Styles ===== */
.clickable-reply {
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease-in-out;
    border-radius: 6px;
    padding: 2px;
    border-left: 2px solid transparent;
}

.clickable-reply:hover {
    background-color: rgba(59, 130, 246, 0.05);
    border-left-color: #3b82f6;
    transform: translateX(2px);
}

.clickable-reply .reply-content {
    position: relative;
}

.clickable-reply .reply-indicator {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: #6b7280;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    pointer-events: none;
}

.clickable-reply:hover .reply-indicator {
    opacity: 1;
}

.clickable-reply:active {
    transform: translateX(1px) scale(0.98);
}

/* ===== Message Jump & Highlight Styles ===== */
.message-highlight {
    background-color: #fef3c7 !important;
    box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.3);
    transition: all 0.3s ease-in-out;
    animation: pulse 0.5s ease-in-out;
}

.message-highlight.message-highlight-fade {
    background-color: transparent !important;
    box-shadow: none;
    transition: all 1s ease-out;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
    100% {
        transform: scale(1);
    }
}

/* Search term highlight within message text */
.search-highlight {
    background: linear-gradient(135deg, #fde047 0%, #fbbf24 100%);
    color: #92400e;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(251, 191, 36, 0.3);
    animation: searchHighlightPulse 1s ease-in-out;
}

@keyframes searchHighlightPulse {
    0%, 100% {
        background: linear-gradient(135deg, #fde047 0%, #fbbf24 100%);
    }
    50% {
        background: linear-gradient(135deg, #fef08a 0%, #fcd34d 100%);
    }
}

/* Dark theme support for highlights */
@media (prefers-color-scheme: dark) {
    .message-highlight {
        background-color: #451a03 !important;
        box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.2);
    }

    .search-highlight {
        background: linear-gradient(135deg, #ca8a04 0%, #a16207 100%);
        color: #fef3c7;
        box-shadow: 0 1px 3px rgba(202, 138, 4, 0.4);
    }
}

/* ===== Image Preview Styles ===== */
.image-preview-container {
    padding: 12px 16px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    max-height: 200px;
    overflow-y: auto;
}

.image-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.image-preview-count {
    font-size: 13px;
    font-weight: 500;
    color: #374151;
}

.image-preview-clear {
    background: none;
    border: none;
    color: #ef4444;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.image-preview-clear:hover {
    background-color: #fee2e2;
}

.image-preview-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
}

.image-preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    background: white;
    border: 2px solid #e5e7eb;
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.2s;
}

.image-preview-item:hover .image-preview-remove {
    opacity: 1;
}

.image-preview-remove:hover {
    background: rgba(220, 38, 38, 1);
}

.image-preview-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 10px;
    padding: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    transition: opacity 0.2s;
}

.image-preview-item:hover .image-preview-name {
    opacity: 1;
}

/* Upload overlay for images being sent */
.message-image.uploading,
.message-images-single.uploading,
.message-images-two.uploading,
.message-images-three.uploading,
.message-images-four.uploading,
.message-images-five.uploading,
.message-images-six.uploading,
.message-images-many.uploading {
    position: relative;
}

.upload-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.upload-progress {
    color: white;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 20px;
}

/* Attachment button active state */
.input-btn#attachImageBtn.has-images {
    background-color: #dbeafe;
    color: #2563eb;
}

/* Scrollbar styling for preview container */
.image-preview-container::-webkit-scrollbar {
    width: 6px;
}

.image-preview-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.image-preview-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.image-preview-container::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ===== File Preview Styles ===== */
.file-preview-container {
    padding: 12px 16px;
    background: #f0f9ff;
    border-top: 1px solid #bae6fd;
    max-height: 200px;
    overflow-y: auto;
}

.file-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.file-preview-count {
    font-size: 13px;
    font-weight: 500;
    color: #374151;
}

.file-preview-clear {
    background: none;
    border: none;
    color: #ef4444;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.file-preview-clear:hover {
    background-color: #fee2e2;
}

.file-preview-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-preview-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: white;
    border: 2px solid #e0f2fe;
    border-radius: 8px;
    transition: all 0.2s;
}

.file-preview-item:hover {
    border-color: #0ea5e9;
    background: #f0f9ff;
}

.file-preview-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.file-preview-info {
    flex: 1;
    min-width: 0;
}

.file-preview-name {
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-preview-size {
    font-size: 11px;
    color: #6b7280;
    margin-top: 2px;
}

.file-preview-remove {
    background: none;
    border: none;
    color: #ef4444;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.file-preview-remove:hover {
    background-color: #fee2e2;
}

/* Scrollbar styling for file preview container */
.file-preview-container::-webkit-scrollbar {
    width: 6px;
}

.file-preview-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.file-preview-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.file-preview-container::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ===== Reply Image Preview Styles ===== */
.reply-image-preview {
    display: flex;
    align-items: center;
    gap: 8px;
}

.reply-thumbnail {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.reply-image-label {
    color: #374151;
    font-size: 14px;
}

/* ===== Pinned Image Preview Styles ===== */
.pinned-image-preview {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pinned-thumbnail {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.pinned-image-label {
    color: #374151;
    font-size: 14px;
    font-weight: 500;
}

/* ===== File Icon Styles ===== */
.file-icon {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    font-weight: 600;
    font-size: 11px;
    color: white;
    text-transform: uppercase;
}

/* Smaller icon sizes for replies and pins */
.reply-file-icon-wrapper .file-icon,
.pinned-file-icon-wrapper .file-icon {
    width: 24px;
    height: 24px;
    font-size: 8px;
}

/* Icon background colors and text based on file type */
.file-icon-pdf {
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
}

.file-icon-pdf::after {
    content: 'PDF';
}

.file-icon-word {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
}

.file-icon-word::after {
    content: 'DOC';
}

.file-icon-excel {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

.file-icon-excel::after {
    content: 'XLS';
}

.file-icon-csv {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.file-icon-csv::after {
    content: 'CSV';
}

.file-icon-powerpoint {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
}

.file-icon-powerpoint::after {
    content: 'PPT';
}

.file-icon-text {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
}

.file-icon-text::after {
    content: 'TXT';
}

.file-icon-archive {
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
}

.file-icon-archive::after {
    content: 'ZIP';
}

.file-icon-image {
    background: linear-gradient(135deg, #ec4899 0%, #db2777 100%);
}

.file-icon-image::after {
    content: 'IMG';
}

.file-icon-audio {
    background: linear-gradient(135deg, #0891b2 0%, #0e7490 100%);
}

.file-icon-audio::after {
    content: 'MP3';
}

.file-icon-video {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
}

.file-icon-video::after {
    content: 'MP4';
}

.file-icon-code {
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
}

.file-icon-code::after {
    content: 'CODE';
    font-size: 9px;
}

.reply-file-icon-wrapper .file-icon-code::after,
.pinned-file-icon-wrapper .file-icon-code::after {
    font-size: 7px;
}

.file-icon-default {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%);
}

.file-icon-default::after {
    content: 'FILE';
    font-size: 9px;
}

.reply-file-icon-wrapper .file-icon-default::after,
.pinned-file-icon-wrapper .file-icon-default::after {
    font-size: 7px;
}

/* File icon hover effect */
.file-download-card:hover .file-icon {
    transform: scale(1.05);
    transition: transform 0.2s ease;
}

/* ===== File Download Card Styles ===== */
.file-download-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    max-width: 350px;
    transition: all 0.2s;
    cursor: pointer;
}

.file-download-card .file-icon {
    flex-shrink: 0;
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 0.25rem;
}

.file-meta {
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.file-ext {
    text-transform: uppercase;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-weight: 500;
    font-size: 0.75rem;
}

.file-size {
    font-size: 0.875rem;
}

.file-download-icon {
    font-size: 1.5rem;
    color: #3b82f6;
    flex-shrink: 0;
}

/* ===== Forward Modal Styles ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal-backdrop, 1040);
    animation: fadeIn 0.2s ease-out;
}

.forward-modal {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    z-index: var(--z-modal, 1050);
    animation: slideUp 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.forward-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
}

.forward-modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
}

.modal-close-btn {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.modal-close-btn .material-symbols-outlined {
    font-size: 24px;
    color: #9ca3af; /* Grey-400: Subtle but visible */
}

.modal-close-btn:hover {
    background-color: #f3f4f6;
}

.modal-close-btn:hover .material-symbols-outlined {
    color: #1f2937; /* Grey-800: Dark on hover */
}

/* Search Section */
.forward-search {
    padding: 16px 24px;
    border-bottom: 1px solid #e5e7eb;
}

.forward-search-input {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.forward-search-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Filter Tabs */
.forward-tabs {
    display: flex;
    gap: 8px;
    padding: 12px 24px;
    border-bottom: 1px solid #e5e7eb;
    background-color: #f9fafb;
}

.forward-tab {
    flex: 1;
    padding: 8px 16px;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s;
}

.forward-tab:hover {
    background-color: #f3f4f6;
    border-color: #9ca3af;
}

.forward-tab.active {
    background-color: #2563eb;
    border-color: #2563eb;
    color: white;
}

/* Selected Section */
.forward-selected-section {
    padding: 16px 24px;
    background-color: #eff6ff;
    border-bottom: 1px solid #bfdbfe;
}

.forward-selected-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.forward-selected-header span {
    font-size: 13px;
    font-weight: 600;
    color: #1e40af;
}

.forward-clear-btn {
    background: none;
    border: none;
    color: #2563eb;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.forward-clear-btn:hover {
    background-color: #dbeafe;
}

.forward-selected-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.forward-selected-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: white;
    border: 1px solid #2563eb;
    border-radius: 20px;
    font-size: 13px;
    color: #1e40af;
    max-width: 200px;
}

.forward-selected-item-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.forward-selected-item-remove {
    background: none;
    border: none;
    color: #2563eb;
    cursor: pointer;
    padding: 0;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 14px;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.forward-selected-item-remove:hover {
    background-color: #dbeafe;
}

/* Conversation List */
.forward-list-section {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.forward-list {
    padding: 8px 0;
}

.forward-conversation-item {
    display: flex;
    align-items: center;
    padding: 12px 24px;
    cursor: pointer;
    transition: background-color 0.2s;
    border-bottom: 1px solid #f3f4f6;
}

.forward-conversation-item:hover {
    background-color: #f9fafb;
}

.forward-conversation-item.selected {
    background-color: #eff6ff;
}

.forward-checkbox {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    cursor: pointer;
    accent-color: #2563eb;
    flex-shrink: 0;
}

.forward-conversation-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #3b82f6;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    margin-right: 12px;
    flex-shrink: 0;
}

.forward-conversation-info {
    flex: 1;
    min-width: 0;
}

.forward-conversation-name {
    display: flex;
    align-items: center;
    font-size: 14px;
    font-weight: 500;
    color: #1f2937;
    margin-bottom: 2px;
    min-width: 0; /* Important for flex child truncation */
}

.forward-conversation-type {
    font-size: 12px;
    color: #6b7280;
}

.forward-conversation-group-badge {
    background-color: #dbeafe;
    color: #1e40af;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}

/* Empty State */
.forward-empty-state {
    padding: 40px 24px;
    text-align: center;
    color: #9ca3af;
}

.forward-empty-state-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.forward-empty-state-text {
    font-size: 14px;
}

/* Footer */
.forward-modal-footer {
    display: flex;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid #e5e7eb;
    background-color: #f9fafb;
}

.forward-btn {
    flex: 1;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.forward-btn-cancel {
    background-color: white;
    color: #6b7280;
    border: 1px solid #d1d5db;
}

.forward-btn-cancel:hover {
    background-color: #f3f4f6;
    border-color: #9ca3af;
}

.forward-btn-primary {
    background-color: #2563eb;
    color: white;
}

.forward-btn-primary:hover:not(:disabled) {
    background-color: #1e40af;
}

.forward-btn-primary:disabled {
    background-color: #9ca3af;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Toast Notification */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* Scrollbar styling for forward list */
.forward-list-section::-webkit-scrollbar {
    width: 8px;
}

.forward-list-section::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.forward-list-section::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.forward-list-section::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Responsive Mobile */
@media (max-width: 768px) {
    .forward-modal {
        width: 100%;
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .forward-tabs {
        flex-wrap: wrap;
    }

    .forward-tab {
        flex: 1 1 calc(33.333% - 6px);
        min-width: 100px;
    }

    .forward-selected-item {
        max-width: 150px;
    }
}

/* ===== Conversation Context Menu ===== */
.conversation-context-menu {
    position: fixed;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0, 0, 0, 0.1);
    padding: 4px 0;
    min-width: 200px;
    z-index: var(--z-popover, 1060);
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.conversation-context-menu.show {
    opacity: 1;
    transform: scale(1);
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    color: #1f2937;
}

.context-menu-item:hover {
    background-color: #f3f4f6;
}

.context-menu-item:active {
    background-color: #e5e7eb;
}

.context-menu-item .material-symbols-outlined {
    font-size: 20px;
    color: #6b7280;
}

.context-menu-text {
    font-size: 14px;
    font-weight: 500;
}

.context-menu-divider {
    height: 1px;
    background-color: #e5e7eb;
    margin: 4px 0;
}

/* Hide pin/unpin based on state */
.conversation-context-menu[data-is-pinned="true"] .context-menu-item[data-action="pin"] {
    display: none;
}

.conversation-context-menu[data-is-pinned="false"] .context-menu-item[data-action="unpin"] {
    display: none;
}

/* Hide mute/unmute based on state */
.conversation-context-menu[data-is-muted="true"] .context-menu-item[data-action="mute"] {
    display: none;
}

.conversation-context-menu[data-is-muted="false"] .context-menu-item[data-action="unmute"] {
    display: none;
}

/* ===== Message Context Menu ===== */
.message-context-menu {
    position: fixed;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0, 0, 0, 0.1);
    padding: 4px 0;
    min-width: 200px;
    z-index: var(--z-popover, 1060);
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.message-context-menu.show {
    opacity: 1;
    transform: scale(1);
}

/* Delete action styling */
.context-menu-delete {
    color: #dc2626;
}

.context-menu-delete:hover {
    background-color: #fee2e2 !important;
}

.context-menu-delete .material-icons-outlined {
    color: #dc2626 !important;
}

/* Hide edit/delete for received messages (only show for sent messages) */
.message-context-menu[data-is-sent="false"] .context-menu-sent-only {
    display: none;
}

/* Show delete for authorized users even if message is not sent by them */
.message-context-menu[data-is-sent="false"][data-is-del="true"] .context-menu-sent-or-authorized {
    display: flex;
}

/* Hide delete/divider if not sent and not authorized */
.message-context-menu[data-is-sent="false"][data-is-del="false"] .context-menu-sent-or-authorized {
    display: none;
}

/* Hide edit for non-text messages (images, files, etc.) */
.message-context-menu[data-message-type="file"] .context-menu-text-only,
.message-context-menu[data-message-type="file-image"] .context-menu-text-only,
.message-context-menu[data-message-type="file-images"] .context-menu-text-only,
.message-context-menu[data-message-type="link-image"] .context-menu-text-only {
    display: none;
}

/* Hide pin/unpin based on state */
.message-context-menu[data-is-pinned="true"] .context-menu-item[data-action="pin"] {
    display: none;
}

.message-context-menu[data-is-pinned="false"] .context-menu-item[data-action="unpin"] {
    display: none;
}

/* Hide divider if all sent-only items are hidden */
.message-context-menu[data-is-sent="false"] .context-menu-sent-only.context-menu-divider {
    display: none;
}

/* Hide divider if not sent and not authorized (no delete/edit to show) */
.message-context-menu[data-is-sent="false"][data-is-del="false"] .context-menu-sent-or-authorized.context-menu-divider {
    display: none;
}

/* Message Context Menu Reactions */
.context-menu-reactions {
    display: flex;
    flex-direction: row;
    gap: 4px;
    padding: 8px 12px;
    justify-content: center;
}

.context-menu-reaction-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 18px;
    font-size: 22px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: transparent;
}

.context-menu-reaction-item:hover {
    background: #f3f4f6;
    transform: scale(1.15);
}

.context-menu-reaction-item:active {
    transform: scale(1.05);
}

/* ===== Message Selection Mode ===== */
.message-selection-toolbar {
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
    padding: 12px 24px;
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    animation: slideDown 0.2s ease-out;
}

.message-selection-toolbar.hidden {
    display: none;
}

.message-selection-toolbar.show {
    display: flex;
}

.selection-toolbar-left,
.selection-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.selection-count {
    font-size: 14px;
    font-weight: 600;
    color: #4b5563;
    margin-left: 4px;
}

.message-selection-toolbar .btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #6b7280;
}

.message-selection-toolbar .btn-icon:hover:not(:disabled) {
    background-color: #e5e7eb;
    color: #374151;
}

.message-selection-toolbar .btn-icon:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.message-selection-toolbar .btn-icon .material-symbols-outlined {
    font-size: 20px;
}

.message-selection-toolbar #cancelSelection {
    color: #374151;
}

.message-selection-toolbar #deleteSelected {
    color: #dc2626;
}

.message-selection-toolbar #deleteSelected:hover:not(:disabled) {
    background-color: #fee2e2;
}

/* Selection checkbox */
.message-selection-checkbox {
    display: none;
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: white;
    border: 2px solid #d1d5db;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
}

.message-selection-mode .message-selection-checkbox {
    display: flex;
}

.message-selection-checkbox .material-symbols-outlined {
    font-size: 20px;
    color: transparent;
    transition: color 0.2s ease;
}

.message-selection-checkbox.checked {
    background: var(--primary-color, #3b82f6);
    border-color: var(--primary-color, #3b82f6);
}

.message-selection-checkbox.checked .material-symbols-outlined {
    color: white;
}

/* Selected message styling */
.message-wrapper.message-selected {
    background-color: rgba(59, 130, 246, 0.08);
}

.message-wrapper.message-selected .message-content {
    background-color: rgba(59, 130, 246, 0.12) !important;
}

/* Selection mode - adjust message wrapper for checkbox space */
.message-selection-mode .message-wrapper {
    cursor: pointer;
    padding-left: 48px;
    transition: background-color 0.2s ease;
}

.message-selection-mode .message-wrapper:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

/* Disable normal hover effects in selection mode */
.message-selection-mode .message-wrapper:hover .message-actions {
    opacity: 0;
    pointer-events: none;
}

/* ===== Reactions Modal ===== */
.reactions-modal {
    background: white;
    border-radius: 12px;
    width: 500px;
    max-width: 90vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.reactions-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
}

.reactions-modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
}

.reactions-modal-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 400px;
}

/* Reactions Sidebar */
.reactions-sidebar {
    width: 120px;
    background: #f9fafb;
    border-right: 1px solid #e5e7eb;
    overflow-y: auto;
    padding: 8px 0;
}

.reactions-tab {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.reactions-tab:hover {
    background: #f3f4f6;
}

.reactions-tab.active {
    background: white;
    border-left-color: #2563eb;
}

.reactions-tab-label {
    font-size: 14px;
    font-weight: 500;
    color: #4b5563;
}

.reactions-tab.active .reactions-tab-label {
    color: #2563eb;
    font-weight: 600;
}

.reactions-tab-emoji {
    font-size: 24px;
}

.reactions-tab-count {
    font-size: 13px;
    color: #9ca3af;
    font-weight: 500;
}

.reactions-tab.active .reactions-tab-count {
    color: #2563eb;
}

/* Reactions Main Content */
.reactions-main {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

.reactions-user-list {
    display: flex;
    flex-direction: column;
}

.reactions-user-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    transition: background-color 0.15s ease;
}

.reactions-user-item:hover {
    background: #f9fafb;
}

.reactions-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.reactions-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 16px;
    flex-shrink: 0;
}

.reactions-user-details {
    flex: 1;
    min-width: 0;
}

.reactions-user-name {
    font-size: 14px;
    font-weight: 500;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reactions-user-reactions {
    display: flex;
    gap: 4px;
    font-size: 20px;
}

/* Loading State */
.reactions-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 60px 20px;
    color: #9ca3af;
}

.reactions-loading .material-symbols-outlined {
    font-size: 40px;
    color: #9ca3af;
    animation: spin 2s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Empty State */
.reactions-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 60px 20px;
    color: #9ca3af;
}

.reactions-empty .material-symbols-outlined {
    font-size: 48px;
    color: #d1d5db;
}

.reactions-empty span:last-child {
    font-size: 14px;
    color: #6b7280;
}

/* ===== Settings Modal ===== */
.settings-modal {
    background: white;
    border-radius: 12px;
    width: 500px;
    max-width: 90vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    animation: slideUp 0.3s ease-out;
}

.settings-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
}

.settings-modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
}

.settings-modal-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.settings-section {
    padding: 24px;
    border-bottom: 1px solid #e5e7eb;
}

.settings-section:last-child {
    border-bottom: none;
}

.settings-section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.settings-section-header .material-symbols-outlined {
    font-size: 24px;
    color: #2563eb;
}

.settings-section-header h4 {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
}

.settings-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: #f9fafb;
    border-radius: 8px;
    transition: background-color 0.2s;
}

.settings-item:hover {
    background: #f3f4f6;
}

.settings-item-info {
    flex: 1;
}

.settings-item-label {
    font-size: 15px;
    font-weight: 500;
    color: #1f2937;
    margin-bottom: 4px;
}

.settings-item-description {
    font-size: 13px;
    color: #6b7280;
}

/* Theme Toggle Switch */
.theme-toggle {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
    cursor: pointer;
}

.theme-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.theme-toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    border-radius: 28px;
    transition: all 0.3s ease;
}

.theme-toggle-slider:before {
    content: "";
    position: absolute;
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.theme-toggle input:checked + .theme-toggle-slider {
    background-color: #2563eb;
}

.theme-toggle input:checked + .theme-toggle-slider:before {
    transform: translateX(24px);
}

.theme-toggle:hover .theme-toggle-slider {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Responsive Mobile */
@media (max-width: 768px) {
    .settings-modal {
        width: 100%;
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
}