/* CSS Custom Properties for Consistent Theming */
:root {
    --primary-color: #ff6b6b;
    --primary-hover: #ff5252;
    --secondary-color: #2d2d2d;
    --background-dark: #1a1a1a;
    --background-medium: #2a2a2a;
    --background-light: #444;
    --text-primary: #e0e0e0;
    --text-secondary: #aaa;
    --text-muted: #666;
    --border-color: #444;
    --success-color: #4caf50;
    --warning-color: #ff9800;
    --error-color: #f44336;
    --shadow-standard: 0 2px 8px rgba(0,0,0,0.3);
    --border-radius: 6px;
    --transition-fast: 0.2s ease;
    --transition-standard: 0.3s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: Arial, sans-serif; background: var(--background-dark); color: var(--text-primary); height: calc(var(--vh, 1vh) * 100); overflow: hidden; }

/* IDO Logo Base Styles */
.ido-logo {
    height: auto;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
    transition: transform 0.2s ease;
}

.ido-logo:hover {
    transform: scale(1.05);
}

/* Login Styles */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: calc(var(--vh, 1vh) * 100);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.login-box {
    background: #2d2d2d;
    padding: 40px;
    border-radius: 12px;
    width: 350px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.login-logo {
    text-align: center;
    margin-bottom: 20px;
}

.login-logo-img {
    width: 120px;
    height: auto;
    max-width: 100%;
}

.login-box h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #ff6b6b;
    font-size: 24px;
}

.login-box input {
    width: 100%;
    padding: 12px;
    margin: 8px 0;
    border: 1px solid #555;
    border-radius: 6px;
    background: #3d3d3d;
    color: #e0e0e0;
    font-size: 16px; /* Prevents iOS zoom on focus */
    -webkit-appearance: none; /* Remove iOS styling */
    -webkit-text-size-adjust: 100%; /* Prevent text size changes */
}

.login-box input:focus {
    outline: none;
    border-color: #ff6b6b;
    box-shadow: 0 0 5px rgba(255, 107, 107, 0.3);
}

/* Password input wrapper - USE FLEXBOX to prevent overlap */
.password-input-wrapper {
    position: relative;
    margin: 8px 0;
    width: 100%;
}

.password-input-wrapper input {
    width: 100% !important;
    padding-right: 45px !important; /* Space for button */
    margin: 0 !important;
    box-sizing: border-box !important;
}

.password-toggle {
    position: absolute !important;
    right: 8px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    padding: 5px;
    border-radius: 3px;
    transition: color 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px !important;
    height: 30px !important;
    z-index: 10 !important;
}

.password-toggle:hover {
    color: #ff6b6b;
    background: rgba(255, 107, 107, 0.1);
}

.password-toggle:focus {
    outline: 2px solid #ff6b6b;
    outline-offset: 2px;
}

.login-box button {
    width: 100%;
    padding: 12px;
    margin-top: 10px;
    background: #ff6b6b;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.login-box button:hover {
    background: #ff5252;
}

/* Chat Layout */
.chat-container {
    display: none;
    height: calc(var(--vh, 1vh) * 100);
    flex-direction: row;
}

/* Sidebar with Rocket Chat Style */
.sidebar {
    width: 280px;
    background: #2d2d2d;
    border-right: 2px solid #444;
    display: flex;
    flex-direction: column;
    min-height: calc(var(--vh, 1vh) * 100);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 2px solid #444;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo {
    width: 32px;
    height: auto;
}

.sidebar-header h3 {
    color: #ff6b6b;
    font-size: 18px;
}

.create-room-btn {
    padding: 8px 12px;
    font-size: 12px;
    background: #4caf50;
    border-radius: 4px;
    min-width: auto;
}

.sidebar-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.sort-rooms-btn {
    padding: 4px 8px;
    font-size: 14px;
    background: #555;
    border-radius: 4px;
    min-width: auto;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s;
}

.sort-rooms-btn:hover {
    background: #666;
}

.sort-icon {
    font-size: 14px;
}

/* Sort Menu Dropdown */
.sort-menu {
    position: absolute;
    top: 65px;
    left: 20px;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 10px 0;
    min-width: 180px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    z-index: 1000;
}

.sort-menu.hidden {
    display: none;
}

.sort-menu-header {
    padding: 8px 15px;
    color: #aaa;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #444;
    margin-bottom: 5px;
}

.sort-option {
    padding: 10px 15px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sort-option:hover {
    background: #333;
}

.sort-option input[type="radio"] {
    margin: 0;
    cursor: pointer;
}

.sort-option label {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #ddd;
    font-size: 14px;
    flex: 1;
    margin: 0;
}

.sort-option input[type="radio"]:checked + label {
    color: #ff6b6b;
    font-weight: 600;
}

.sort-icon-label {
    font-size: 16px;
}

/* Room Search (Moderators/Admins Only) */
.room-search-container {
    padding: 12px 16px;
    border-bottom: 1px solid #444;
    background: #2a2a2a;
    position: relative;
}

.room-search-input {
    width: 100%;
    padding: 10px 40px 10px 12px;
    background: #1a1a1a;
    border: 1px solid #444;
    border-radius: 6px;
    color: #ddd;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.room-search-input:focus {
    border-color: #9c27b0;
}

.room-search-input::placeholder {
    color: #888;
}

.clear-search-btn {
    position: absolute;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: #888;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    transition: color 0.2s;
}

.clear-search-btn:hover {
    color: #ff6b6b;
}

/* Rocket Chat Style Room Sections */
.rooms-container {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.room-section {
    margin-bottom: 20px;
}

.room-section-header {
    padding: 12px 20px 8px 20px;
    color: #aaa;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #333;
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Unread section styling with urgency theme */
.room-section-header.unread-header {
    color: #ff6b6b;
    border-bottom: 2px solid #ff6b6b;
    background: rgba(255, 107, 107, 0.1);
    padding: 14px 20px 10px 20px;
    margin-bottom: 8px;
}

.unread-count-badge {
    background: #ff6b6b;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
    margin-left: 8px;
}

#unreadSection .room-item {
    border-left: 3px solid #ff6b6b;
    background: rgba(255, 107, 107, 0.05);
}

#unreadSection .room-item:hover {
    background: rgba(255, 107, 107, 0.15);
}

#unreadSection .room-item.active {
    background: rgba(255, 107, 107, 0.2);
    border-left-color: #ff5252;
}

.start-dm-btn {
    background: #ff6b6b;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.start-dm-btn:hover {
    background: #ff5252;
    transform: scale(1.1);
}

.rooms-list {
    padding: 0 10px;
}

.room-item {
    padding: 8px 15px;
    margin: 2px 0;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.room-item:hover {
    background: #3a3a3a;
}

.room-item.active {
    background: #ff6b6b;
    color: white;
}

.room-item-content {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.room-icon {
    margin-right: 10px;
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.room-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.room-type {
    font-size: 10px;
    background: rgba(255,255,255,0.2);
    padding: 2px 6px;
    border-radius: 10px;
    text-transform: uppercase;
    margin-left: 8px;
}

.room-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.room-item:hover .room-actions {
    opacity: 1;
}

.room-manage-btn, .room-delete-btn, .room-favorite-btn {
    padding: 4px 6px;
    font-size: 10px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.room-manage-btn {
    background: #444;
    color: #ccc;
}

.room-delete-btn {
    background: #f44336;
    color: white;
}

.room-favorite-btn {
    background: transparent;
    color: #888;
    font-size: 14px;
    padding: 2px 4px;
    opacity: 1 !important; /* Always visible, not hidden by parent */
}

.room-manage-btn:hover {
    background: #555;
    color: white;
}

.room-delete-btn:hover {
    background: #d32f2f;
}

.room-favorite-btn:hover {
    color: #ffd700;
    background: rgba(255, 215, 0, 0.1);
}

/* Notification Badge Styles - Enhanced for unread counts */
.notification-badge {
    position: absolute;
    top: -5px;
    right: 5px;
    background: #ff4444;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 10px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border: 2px solid #2d2d2d;
}

.notification-badge.mention {
    background: #ff9800;
    animation: pulse-badge 2s infinite;
}

.notification-badge.dm {
    background: #2196f3;
}

@keyframes pulse-badge {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 152, 0, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(255, 152, 0, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 152, 0, 0); }
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 15px;
    border-top: 2px solid #444;
    background: #252525;
}

/* Archived Rooms Toggle */
.archived-rooms-toggle {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #333;
}

.archived-toggle-btn {
    width: 100%;
    background: #444;
    border: none;
    color: #e0e0e0;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
    text-align: left;
}

.archived-toggle-btn:hover {
    background: #555;
    color: #ff9800;
}

.archived-toggle-btn.active {
    background: #ff9800;
    color: #000;
}

/* Archived Room Styling */
.archived-room {
    opacity: 0.8;
    border-left: 3px solid #ff9800;
}

.archived-room:hover {
    opacity: 1;
    background: #333;
}

.archived-info {
    font-size: 10px;
    color: #888;
    margin-top: 2px;
    line-height: 1.2;
}

.unarchive-btn {
    background: #ff9800;
    border: none;
    color: #000;
    padding: 4px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    margin-left: 8px;
    transition: all 0.2s ease;
}

.unarchive-btn:hover {
    background: #ffb74d;
    transform: scale(1.1);
}

/* Slash Command Autocomplete */
.slash-command-suggestions {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: #2d2d2d;
    border: 1px solid #444;
    border-radius: 6px 6px 0 0;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.3);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.slash-command-suggestions.visible {
    display: block;
}

.slash-command-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #333;
    transition: background-color 0.2s ease;
}

.slash-command-item:last-child {
    border-bottom: none;
}

.slash-command-item:hover {
    background-color: #3d3d3d;
}

.command-name {
    color: #ff9800;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    margin-right: 12px;
}

.command-description {
    color: #ccc;
    font-size: 13px;
}

/* Room Name Autocomplete Suggestions */
.room-name-suggestions {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: #2d2d2d;
    border: 1px solid #444;
    border-radius: 6px 6px 0 0;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.3);
    max-height: 150px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.room-name-suggestions.visible {
    display: block;
}

.room-name-item {
    padding: 8px 16px;
    cursor: pointer;
    border-bottom: 1px solid #333;
    transition: background-color 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.room-name-item:last-child {
    border-bottom: none;
}

.room-name-item:hover,
.room-name-item.selected {
    background-color: #3d3d3d;
}

.room-name-text {
    color: #4CAF50;
    font-weight: bold;
    font-family: 'Courier New', monospace;
}

.room-action {
    color: #888;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #ff6b6b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
}

.user-details {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-weight: 500;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 11px;
    color: #aaa;
    text-transform: uppercase;
}

.online-indicator {
    width: 8px;
    height: 8px;
    background: #4caf50;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.settings-btn {
    width: 100%;
    padding: 8px;
    font-size: 16px;
    background: #555;
    color: white;
    border: none;
    cursor: pointer;
    border-radius: 4px;
    margin-bottom: 5px;
    transition: background 0.2s;
}

.settings-btn:hover {
    background: #666;
}

.logout-btn {
    width: 100%;
    padding: 8px;
    font-size: 12px;
    background: #666;
}

/* Start DM Modal */
.start-dm-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
}

.start-dm-content {
    background: #2d2d2d;
    margin: 10% auto;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    position: relative;
}

.dm-search-container {
    position: relative;
    margin-bottom: 20px;
}

.dm-user-search {
    width: 100%;
    padding: 12px;
    background: #333;
    border: 2px solid #555;
    border-radius: 6px;
    color: #e0e0e0;
    caret-color: #e0e0e0;  /* Ensure cursor is visible */
    outline: none;
    font-size: 14px;
}

.dm-user-search:focus {
    border-color: #ff6b6b;
    caret-color: #ff6b6b;  /* Red cursor when focused */
}

.dm-user-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 6px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1001;
    display: none;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.dm-user-suggestion {
    padding: 12px 15px;
    border-bottom: 1px solid #333;
    cursor: pointer;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}

.dm-user-suggestion:hover {
    background: #333;
}

.dm-user-suggestion:last-child {
    border-bottom: none;
}

.dm-suggestion-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #ff6b6b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    font-size: 14px;
}

.dm-suggestion-info {
    flex: 1;
}

.dm-suggestion-name {
    font-weight: 500;
    color: #e0e0e0;
    margin-bottom: 2px;
}

.dm-suggestion-email {
    font-size: 12px;
    color: #aaa;
}

/* Selected DM Users Pills */
.selected-dm-users {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 15px;
    min-height: 50px;
    background: #1e1e1e;
    border-radius: 6px;
    margin-top: 15px;
}

.selected-dm-users:empty::after {
    content: 'Select users to start a conversation...';
    color: #777;
    font-size: 14px;
}

.selected-user-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #3f51b5;
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
}

.selected-user-pill button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0;
    margin-left: 8px;
    font-size: 8px;
    line-height: 1;
    font-weight: 300;
    width: 10px;
    height: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    flex-shrink: 0;
}

.selected-user-pill button:hover {
    color: #ff6b6b;
    opacity: 1;
}

/* DM Modal Actions */
.dm-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #333;
}

/* Main Chat Area */
.main-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: calc(var(--vh, 1vh) * 100);
}

.chat-header {
    background: #2d2d2d;
    padding: 15px 20px;
    border-bottom: 2px solid #444;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-header-logo {
    width: 24px;
    height: auto;
}

.chat-header h3 {
    color: #ff6b6b;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Chat Header Favorite Star Button */
.favorite-star-btn {
    background: transparent;
    border: none;
    color: #888;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    transition: all 0.2s ease;
    line-height: 1;
}

.favorite-star-btn:hover {
    color: #ffd700;
    transform: scale(1.1);
}

.favorite-star-btn.favorited {
    color: #ffd700;
}

.favorite-star-btn.favorited .star-icon::before {
    content: '★';
}

.star-icon::before {
    content: '☆';
}

/* Chat Header Mute Notification Button */
.mute-notifications-btn {
    background: transparent;
    border: none;
    color: #888;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    transition: all 0.2s ease;
    line-height: 1;
}

.mute-notifications-btn:hover {
    color: #ff6b6b;
    transform: scale(1.1);
}

.mute-notifications-btn.muted {
    color: #ff6b6b;
}

/* Room Unread Badges */
.room-unread-badge {
    background: #ff6b6b;
    color: white;
    border-radius: 50%;
    font-size: 10px;
    font-weight: bold;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    padding: 0 4px;
    margin-left: 8px;
    display: inline-block;
}

.room-unread-badge.mention {
    background: #ff3333;
    animation: mention-pulse 1s ease-in-out;
}

@keyframes mention-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Search Components */
.search-container {
    flex: 1;
    max-width: 400px;
    margin: 0 20px;
    position: relative;
    min-width: 200px; /* Ensure minimum visibility */
}

.search-input-wrapper {
    display: flex;
    background: #1a1a1a;
    border: 2px solid #444;
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.2s ease;
}

.search-input-wrapper:focus-within {
    border-color: #ff6b6b;
}

.global-search-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #e0e0e0;
    padding: 10px 15px;
    font-size: 14px;
    outline: none;
}

.global-search-input::placeholder {
    color: #888;
}

.search-btn, .advanced-search-btn {
    background: #ff6b6b;
    border: none;
    color: white;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s ease;
}

.advanced-search-btn {
    background: #666;
    border-left: 1px solid #444;
}

.search-btn:hover {
    background: #ff5252;
}

.advanced-search-btn:hover {
    background: #777;
}

.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #2d2d2d;
    border: 2px solid #444;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.search-suggestion {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid #444;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.search-suggestion:hover {
    background: #3d3d3d;
}

.search-suggestion:last-child {
    border-bottom: none;
}

.suggestion-text {
    color: #e0e0e0;
}

.suggestion-type {
    color: #888;
    font-size: 12px;
    background: #444;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Advanced Search Modal */
.form-row {
    display: flex;
    gap: 20px;
}

.form-row .form-group {
    flex: 1;
}

/* Search Results Modal */
.search-results-modal .modal-content {
    width: 90%;
    max-width: 1200px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.search-results-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.search-results-summary {
    padding: 15px 20px;
    border-bottom: 2px solid #444;
    background: #2a2a2a;
}

.search-summary {
    margin-bottom: 15px;
    color: #ccc;
    font-size: 14px;
}

.search-tabs {
    display: flex;
    gap: 5px;
}

.search-tab {
    background: #3d3d3d;
    border: none;
    color: #ccc;
    padding: 8px 16px;
    cursor: pointer;
    border-radius: 6px 6px 0 0;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.search-tab.active {
    background: #ff6b6b;
    color: white;
}

.search-tab:hover:not(.active) {
    background: #4d4d4d;
}

.tab-count {
    background: rgba(0, 0, 0, 0.3);
    color: white;
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
}

.search-results-container {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.search-results-content-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.search-result {
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    transition: all 0.2s ease;
}

.search-result:hover {
    background: #333;
    border-color: #555;
}

.search-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.search-result-meta {
    display: flex;
    align-items: center;
    gap: 15px;
    color: #888;
    font-size: 12px;
}

.search-result-content {
    color: #e0e0e0;
    line-height: 1.5;
    margin-bottom: 10px;
}

.search-result-content mark {
    background: #ff6b6b;
    color: white;
    padding: 1px 3px;
    border-radius: 2px;
}

.search-result-actions {
    display: flex;
    gap: 10px;
}

.search-result-btn {
    background: #ff6b6b;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s ease;
}

.search-result-btn:hover {
    background: #ff5252;
}

.search-result-btn.secondary {
    background: #666;
}

.search-result-btn.secondary:hover {
    background: #777;
}

/* Search Pagination */
.search-pagination {
    padding: 15px 20px;
    border-top: 1px solid #444;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.pagination-btn {
    background: #3d3d3d;
    border: 1px solid #555;
    color: #ccc;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.pagination-btn:hover:not(.disabled) {
    background: #4d4d4d;
    border-color: #666;
}

.pagination-btn.active {
    background: #ff6b6b;
    color: white;
    border-color: #ff6b6b;
}

.pagination-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-info {
    color: #888;
    font-size: 14px;
    margin: 0 15px;
}

/* Header Search Button */
.header-search-btn {
    background: linear-gradient(135deg, #ff6b6b, #ff5252);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(255, 107, 107, 0.3);
    display: flex;
    align-items: center;
    gap: 6px;
}

.header-search-btn:hover {
    background: linear-gradient(135deg, #ff5252, #ff3d3d);
    box-shadow: 0 4px 8px rgba(255, 107, 107, 0.4);
    transform: translateY(-1px);
}

.header-search-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(255, 107, 107, 0.3);
}

.room-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Room members dropdown styling */
.room-members-dropdown {
    position: relative;
    display: inline-block;
    z-index: 10001; /* Ensure dropdown can appear above sticky header */
}

.room-members-count {
    background: var(--background-light);
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    color: var(--text-secondary);
    border: none;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 4px;
}

.room-members-count:hover {
    background: var(--primary-color);
    color: white;
}

.members-dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--background-medium);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-standard);
    z-index: 1000;
    min-width: 200px;
    max-height: 300px;
    overflow-y: auto;
    margin-top: 4px;
}

.members-dropdown-content.show {
    display: block;
}

.member-item {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: var(--transition-fast);
    border-bottom: 1px solid var(--border-color);
}

.member-item:last-child {
    border-bottom: none;
}

.member-item:hover {
    background: var(--background-light);
}

.member-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 10px;
    font-weight: bold;
    flex-shrink: 0;
    position: relative;
}

/* Online status indicator (green dot on avatar) */
.online-status-indicator {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #4caf50;
    border: 2px solid #1e1e1e;
    box-sizing: border-box;
    z-index: 10;
    transition: opacity 0.3s ease;
}

.online-status-indicator.online {
    opacity: 1;
}

/* DM online indicator in sidebar */
.dm-online-indicator {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4caf50;
    border: 1.5px solid #1e1e1e;
    box-sizing: border-box;
    z-index: 10;
}

.room-icon {
    position: relative;
    display: inline-block;
}

/* Read receipts (WhatsApp-style double checkmarks) */
.read-receipts-container {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin-left: 8px;
    margin-right: 4px;
}

.read-checkmarks {
    font-size: 12px;
    color: #4fc3f7;
    cursor: pointer;
    user-select: none;
    transition: color 0.2s ease;
}

.read-checkmarks:hover {
    color: #29b6f6;
}

.read-receipts-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    margin-bottom: 5px;
    z-index: 1000;
}

.read-receipts-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
}

.read-receipts-container:hover .read-receipts-tooltip {
    opacity: 1;
}

/* Mobile adjustments for read receipts */
@media (max-width: 768px) {
    .read-checkmarks {
        font-size: 11px;
    }

    .read-receipts-tooltip {
        font-size: 10px;
        padding: 5px 8px;
    }
}

.member-info {
    flex: 1;
    min-width: 0;
}

.member-name {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
}

.member-email {
    font-size: 11px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.members-list-loading {
    padding: 12px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
}

.manage-room-btn, .delete-room-btn, .admin-panel-btn {
    padding: 8px 12px;
    font-size: 12px;
    border-radius: 4px;
    min-width: auto;
}

.manage-room-btn {
    background: #ff9800;
}

.delete-room-btn {
    background: #f44336;
}

.admin-panel-btn {
    background: #9c27b0;
}

.messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden; /* Prevent horizontal scrolling on mobile */
    background: #1a1a1a;
}

/* Date Separators */
.date-separator {
    display: flex;
    align-items: center;
    margin: 20px 0;
    color: #888;
    font-size: 13px;
    font-weight: 500;
}

.date-separator-line {
    flex: 1;
    height: 1px;
    background: #444;
}

.date-separator-text {
    padding: 0 15px;
    background: #1a1a1a;
    color: #888;
    white-space: nowrap;
}

/* Sticky Date Indicator - Telegram-style floating date while scrolling */
.sticky-date-indicator-wrapper {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    height: 0;
    z-index: 100;
    display: flex;
    justify-content: center;
    pointer-events: none;
}

.sticky-date-indicator {
    position: relative;
    top: 10px;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 8px 16px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    white-space: nowrap;
}

.sticky-date-indicator.visible {
    opacity: 1;
}

.sticky-date-indicator.fade-out {
    opacity: 0;
}

.message {
    margin: 10px 0;
    padding: 12px 16px;
    background: #333;
    border-radius: 8px;
    border-left: 4px solid #ff6b6b;
    animation: fadeIn 0.3s ease-in;
    position: relative;
}

.message.has-mention {
    border-left-color: #ffa726;
    background: rgba(255, 167, 38, 0.1);
    box-shadow: 0 2px 8px rgba(255, 167, 38, 0.2);
}

.message.has-mention .sender {
    color: #ffa726;
}

.message .sender {
    font-weight: bold;
    color: #ff6b6b;
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Clickable username for starting DMs */
.clickable-username {
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 3px;
    padding: 0 4px;
    margin: 0 -4px;
}

.clickable-username:hover {
    text-decoration: underline;
    color: #64b5f6;
    background-color: rgba(100, 181, 246, 0.15);
}

/* Typing indicator */
.typing-indicator {
    padding: 8px 12px;
    font-size: 13px;
    color: #888;
    display: flex;
    align-items: center;
    gap: 6px;
}

.typing-text {
    font-style: italic;
}

.typing-dots {
    display: inline-flex;
    gap: 3px;
}

.typing-dots .dot {
    width: 6px;
    height: 6px;
    background-color: #888;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

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

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

.typing-dots .dot:nth-child(3) {
    animation-delay: 0s;
}

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

/* Room Announcement Banner */
.room-announcement-banner {
    background: linear-gradient(135deg, #f9a825 0%, #fbc02d 100%);
    color: #1a1a1a;
    padding: 12px 16px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 14px;
    line-height: 1.5;
}

.room-announcement-banner .announcement-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.room-announcement-banner .announcement-content {
    flex: 1;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.room-announcement-banner .announcement-content a {
    color: #1a1a1a;
    text-decoration: underline;
    font-weight: 500;
}

.room-announcement-banner .announcement-content a:hover {
    color: #333;
}

/* Message menu (mark as unread, etc.) */
.message-menu-container {
    display: inline-block;
    position: relative;
    margin-left: 8px;
}

.message-menu-btn {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: #999;
    cursor: pointer;
    padding: 4px 8px;
    font-size: 16px;
    border-radius: 4px;
    opacity: 0.7;
    transition: opacity 0.2s, background-color 0.2s, color 0.2s;
}

.message:hover .message-menu-btn {
    opacity: 1;
    background: rgba(255, 255, 255, 0.12);
}

.message-menu-btn:hover {
    opacity: 1 !important;
    background-color: rgba(255, 107, 107, 0.3);
    color: #ff6b6b;
}

.message-menu-dropdown {
    position: absolute;
    top: 100%;
    left: auto;
    right: 0;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    min-width: 160px;
    padding: 4px 0;
    white-space: nowrap;
}

.message-menu-dropdown button {
    display: block;
    width: 100%;
    padding: 8px 12px;
    background: transparent;
    border: none;
    color: #e0e0e0;
    text-align: left;
    cursor: pointer;
    font-size: 13px;
    transition: background-color 0.2s;
}

.message-menu-dropdown button:hover {
    background-color: rgba(255, 107, 107, 0.2);
}

.message .time {
    font-size: 0.8em;
    color: #999;
    font-weight: normal;
}

.message .content {
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
}

/* Offline message status */
.message.offline-pending {
    opacity: 0.8;
    border-left-color: #ff9800;
}

.offline-status {
    animation: pulse-offline 2s infinite;
}

@keyframes pulse-offline {
    0% { opacity: 1; }
    50% { opacity: 0.6; }
    100% { opacity: 1; }
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Mobile header menu - hidden by default, especially on desktop */
.mobile-header-menu-btn, .mobile-header-dropdown {
    display: none;
}

/* Force hide mobile header menu button on desktop screens */
@media (min-width: 769px) {
    button.mobile-header-menu-btn {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
        position: absolute !important;
        left: -9999px !important;
    }

    .mobile-header-dropdown {
        display: none !important;
    }
}

/* Enhanced Mentions and Room References Styling */
.mention {
    background: #4caf50;
    color: white;
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-block;
    margin: 0 1px;
}

.mention:hover {
    background: #45a049;
    transform: scale(1.05);
}

.mention.user-mention {
    background: #2196f3;
    color: white;
}

.mention.user-mention:hover {
    background: #1976d2;
    color: white;
}

.mention.all-mention {
    background: #ff5722;
    color: white;
}

.mention.all-mention:hover {
    background: #e64a19;
    color: white;
}

.room-reference {
    background: linear-gradient(45deg, #9c27b0, #673ab7);
    color: white;
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid rgba(255,255,255,0.2);
    display: inline-block;
    margin: 0 1px;
}

.room-reference:hover {
    background: linear-gradient(45deg, #7b1fa2, #512da8);
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(156, 39, 176, 0.4);
}

/* Message Reactions Styling */
.message-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-top: 8px;
    gap: 10px;
}

.message-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex: 1;
}

.reaction-button {
    background: #444;
    border: 1px solid #555;
    border-radius: 12px;
    padding: 4px 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    min-height: 24px;
    position: relative;
}

.reaction-button:hover {
    background: #555;
    border-color: #ff6b6b;
    transform: scale(1.05);
}

.reaction-button.user-reacted {
    background: #ff6b6b;
    border-color: #ff5252;
    color: white;
}

.reaction-button.user-reacted:hover {
    background: #ff5252;
    border-color: #ff3d3d;
}

.reaction-emoji {
    font-size: 14px;
    line-height: 1;
}

.reaction-count {
    font-size: 11px;
    font-weight: 500;
    margin-left: 2px;
}

.message-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.message:hover .message-actions,
.message:hover .message-footer .message-actions {
    opacity: 1 !important;
}

.message-action-btn {
    background: transparent;
    border: none;
    color: #888;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    font-size: 12px;
    transition: all 0.2s ease;
}

.message-action-btn:hover {
    color: #ff6b6b;
    background: rgba(255, 107, 107, 0.1);
}

/* Pin button styles */
.pin-btn {
    color: #888;
}

.pin-btn:hover {
    color: #ffa726;
    background: rgba(255, 167, 38, 0.1);
}

.pin-btn.pinned {
    color: #ffa726;
}

/* Pinned messages modal styles */
.pinned-message-item {
    background: #2a2a2a;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
    border-left: 3px solid #ffa726;
}

.pinned-message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.pinned-message-sender {
    color: #ff6b6b;
    font-weight: 600;
    font-size: 14px;
}

.pinned-message-time {
    color: #888;
    font-size: 12px;
}

.pinned-message-content {
    color: #e0e0e0;
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: 8px;
    word-wrap: break-word;
}

.pinned-message-files {
    margin-top: 8px;
}

.pinned-file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: #363636;
    border-radius: 4px;
    margin-bottom: 4px;
}

.pinned-file-item a {
    color: #4fc3f7;
    text-decoration: none;
    font-size: 13px;
}

.pinned-file-item a:hover {
    text-decoration: underline;
}

.unpin-btn {
    background: transparent;
    border: 1px solid #ff6b6b;
    color: #ff6b6b;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s ease;
}

.unpin-btn:hover {
    background: #ff6b6b;
    color: #1a1a1a;
}

.no-pinned-messages {
    text-align: center;
    color: #888;
    padding: 40px 20px;
    font-size: 14px;
}

/* Header pinned messages button */
.pinned-messages-btn {
    background: transparent;
    border: 1px solid #ffa726;
    color: #ffa726;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    margin-left: 8px;
}

.pinned-messages-btn:hover {
    background: rgba(255, 167, 38, 0.2);
    transform: scale(1.05);
}

.emoji-picker {
    position: absolute;
    top: -320px;
    right: 0;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 12px;
    padding: 12px;
    display: none;
    z-index: 1000;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    max-width: 400px;
    min-width: 320px;
    max-height: 300px;
    overflow-y: auto;
}

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

/* New comprehensive emoji picker container */
.emoji-picker-container {
    position: absolute;
    top: -450px;
    right: 0;
    z-index: 1000;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6);
    border-radius: 12px;
    overflow: hidden;
}

/* Style the emoji-picker-element component */
emoji-picker.full-emoji-picker {
    --background: #2a2a2a;
    --border-color: #444;
    --border-radius: 12px;
    --button-active-background: #404040;
    --button-hover-background: #353535;
    --category-emoji-size: 1.375rem;
    --emoji-size: 1.75rem;
    --indicator-color: #ff6b6b;
    --input-border-color: #444;
    --input-border-radius: 8px;
    --input-font-color: #e0e0e0;
    --input-font-size: 14px;
    --input-padding: 8px 12px;
    --num-columns: 8;
    --outline-color: #ff6b6b;
    --search-font-color: #e0e0e0;
    --search-placeholder-color: #888;
    --shadow: 0 4px 12px rgba(0,0,0,0.3);
    --skintone-border-radius: 8px;
    width: 420px;
    height: 400px;
    border: 1px solid #444;
}

.emoji-picker-header {
    font-size: 14px;
    font-weight: bold;
    color: #ff6b6b;
    margin-bottom: 12px;
    text-align: center;
    border-bottom: 1px solid #444;
    padding-bottom: 8px;
}

.emoji-category {
    margin-bottom: 8px;
}

.emoji-category-label {
    font-size: 12px;
    color: #b0b0b0;
    margin-bottom: 6px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.emoji-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.emoji-option {
    padding: 6px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 20px;
    line-height: 1;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
}

.emoji-option:hover {
    background: #404040;
    border-color: #ff6b6b;
    transform: scale(1.1);
}

.reaction-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #1a1a1a;
    color: #e0e0e0;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1001;
    border: 1px solid #444;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    margin-bottom: 5px;
}

.reaction-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #444;
}

.reaction-button:hover .reaction-tooltip {
    opacity: 1;
}

/* File Upload and Message Input */
.message-input-container {
    background: #2d2d2d;
    padding: 20px;
    border-top: 2px solid #444;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Quote Preview Bar - shows above message input when quoting */
.quote-preview-bar {
    display: none;
    background: #3a3a3a;
    border-left: 4px solid #9c27b0;
    padding: 10px 12px;
    border-radius: 4px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.quote-preview-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    overflow: hidden;
}

.quote-preview-author {
    color: #9c27b0;
    font-weight: 600;
    font-size: 0.85em;
}

.quote-preview-text {
    color: #b0b0b0;
    font-size: 0.9em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.quote-preview-cancel {
    background: none;
    border: none;
    color: #888;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.quote-preview-cancel:hover {
    background: #4a4a4a;
    color: #e0e0e0;
}

/* Quoted Message Display - Slack-style in chat */
.quoted-message {
    background: #3a3a3a;
    border-left: 3px solid #9c27b0;
    border-radius: 4px;
    padding: 8px 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    gap: 8px;
}

.quoted-message:hover {
    background: #444;
}

.quoted-message-bar {
    display: none; /* Bar is now done via border-left */
}

.quoted-message-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.quoted-message-author {
    color: #9c27b0;
    font-weight: 600;
    font-size: 0.85em;
}

.quoted-message-text {
    color: #b0b0b0;
    font-size: 0.9em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Formatting Toolbar */
.formatting-toolbar {
    display: flex;
    gap: 4px;
    padding: 6px 10px;
    background: #2a2a2a;
    border-bottom: 1px solid #3a3a3a;
    border-radius: 8px 8px 0 0;
}

.format-btn {
    background: transparent;
    border: 1px solid transparent;
    color: #b0b0b0;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    min-width: 28px;
    transition: all 0.15s ease;
}

.format-btn:hover {
    background: #3a3a3a;
    color: #fff;
    border-color: #4a4a4a;
}

.format-btn:active {
    background: #4a4a4a;
    transform: scale(0.95);
}

.format-btn strong {
    font-weight: 700;
}

.format-btn em {
    font-style: italic;
}

.format-btn s {
    text-decoration: line-through;
}

.input-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.file-input {
    display: none;
}

.file-upload-btn {
    background: #555;
    color: #e0e0e0;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.file-upload-btn:hover {
    background: #666;
    transform: scale(1.05);
}

.file-upload-btn:active {
    transform: scale(0.95);
}

.message-input {
    flex: 1;
    padding: 12px;
    background: #333;
    border: 2px solid #555;
    border-radius: 25px;
    color: #e0e0e0;
    caret-color: #ff6b6b; /* Bright red cursor for visibility */
    outline: none;
    transition: border-color 0.3s ease;
    /* Disable browser extensions and autocomplete */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    /* Disable password managers and form autofill */
    autocomplete: off;
    /* Disable browser built-in spell check and autocorrect */
    -webkit-autocorrect: off;
    -webkit-autocapitalize: off;
    -webkit-spell-check: false;
    /* Disable extension overlays */
    position: relative;
    z-index: 1;
    /* Textarea-specific: auto-resize and disable manual resize */
    resize: none;
    overflow-y: auto;
    min-height: 44px;
    max-height: 200px;
    font-family: inherit;
    line-height: 1.5;
}

/* File Preview Area */
.file-preview {
    display: none;
    background: #333;
    border: 1px solid #555;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.file-preview.show {
    display: block;
}

.file-preview-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #444;
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 8px;
    position: relative;
}

.file-preview-item:last-child {
    margin-bottom: 0;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.file-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.file-details {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-weight: 500;
    color: #e0e0e0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 14px;
}

.file-size {
    font-size: 12px;
    color: #aaa;
}

.file-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.file-remove-btn {
    background: #f44336;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.file-remove-btn:hover {
    background: #d32f2f;
}

.file-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    background: #4caf50;
    border-radius: 0 0 6px 6px;
    transition: width 0.3s ease;
}

.file-progress.uploading {
    background: #ff9800;
}

.file-progress.error {
    background: #f44336;
}

/* File Message Display */
.file-message {
    background: #444;
    border: 1px solid #555;
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s ease;
}

.file-message:hover {
    background: #4a4a4a;
    border-color: #666;
}

.file-message-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.file-message-info {
    flex: 1;
    min-width: 0;
}

.file-message-name {
    font-weight: 500;
    color: #e0e0e0;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-message-details {
    font-size: 12px;
    color: #aaa;
    display: flex;
    gap: 12px;
}

.file-message-download {
    background: none !important;
    color: #4caf50 !important;
    border: none !important;
    padding: 0 !important;
    font-size: 13px !important;
    cursor: pointer !important;
    text-decoration: none !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    font-weight: normal !important;
}

.file-message-download:hover {
    color: #66bb6a !important;
    text-decoration: none !important;
}

.file-message-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

.file-preview-btn {
    background: #2196f3;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: background-color 0.3s ease;
}

.file-preview-btn:hover {
    background: #1976d2;
}

/* Inline File Previews */
.file-inline-preview {
    margin: 12px 0;
    border-radius: 8px;
    overflow: hidden;
    background: #2a2a2a;
    border: 1px solid #444;
}

/* Image Inline Preview */
.file-image-preview .inline-image {
    width: 100%;
    max-width: 400px;
    height: auto;
    display: block;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.file-image-preview .inline-image:hover {
    transform: scale(1.02);
}

@media (max-width: 768px) {
    .file-image-preview .inline-image {
        max-width: 100%;
    }
}

/* Video Inline Preview */
.file-video-preview .inline-video {
    width: 100%;
    max-width: 600px;
    display: block;
    background: #000;
}

@media (max-width: 768px) {
    .file-video-preview .inline-video {
        max-width: 100%;
    }
}

/* Audio Inline Preview */
.file-audio-preview .audio-player-wrapper {
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.file-audio-preview .inline-audio {
    flex: 1;
    height: 40px;
}

/* PDF Inline Preview */
.file-pdf-preview .pdf-thumbnail {
    padding: 24px;
    text-align: center;
    cursor: pointer;
    background: #333;
    transition: background 0.3s ease;
}

.file-pdf-preview .pdf-thumbnail:hover {
    background: #3a3a3a;
}

.file-pdf-preview .pdf-icon {
    font-size: 48px;
    margin-bottom: 8px;
}

.file-pdf-preview .pdf-preview-text {
    color: #aaa;
    font-size: 14px;
}

/* Inline File Actions Bar */
.file-inline-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #2a2a2a;
    border-top: 1px solid #444;
    flex-wrap: wrap;
    gap: 8px;
}

.file-inline-name {
    color: #e0e0e0;
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.file-inline-details {
    color: #aaa;
    font-size: 12px;
}

.file-inline-buttons {
    display: flex;
    gap: 6px;
    align-items: center;
}

.file-action-btn {
    background: #444;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.file-action-btn:hover {
    background: #555;
    text-decoration: none;
    color: #fff;
}

/* File Load Error */
.file-load-error {
    padding: 40px 20px;
    text-align: center;
    color: #f44336;
    font-size: 14px;
    background: #2a2a2a;
}

/* Mobile Responsive Adjustments */
@media (max-width: 768px) {
    .file-inline-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .file-inline-buttons {
        justify-content: center;
        width: 100%;
    }

    .file-action-btn {
        flex: 1;
        justify-content: center;
    }
}

.file-delete-btn {
    background: transparent;
    color: #f44336;
    border: 1px solid #f44336;
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.2s ease;
    min-width: 36px;
}

.file-delete-btn:hover {
    background: rgba(244, 67, 54, 0.1);
    color: #d32f2f;
    transform: translateY(-1px);
}

.message-delete-btn {
    background: #f44336 !important;
    color: white !important;
}

.message-delete-btn:hover {
    background: #d32f2f !important;
}

.message-input:focus { border-color: #ff6b6b; }

/* Hide browser extension suggestions and overlays */
.message-input::-webkit-credentials-auto-fill-button,
.message-input::-webkit-strong-password-auto-fill-button,
.message-input::-webkit-caps-lock-indicator,
.message-input::-webkit-contacts-auto-fill-button {
    display: none !important;
    visibility: hidden !important;
}

/* Additional protection against extension overlays */
.message-input-container {
    isolation: isolate;
}

.message-input::before,
.message-input::after {
    display: none !important;
}

/* Aggressively hide browser extension elements */
[class*="extension"],
[id*="extension"],
[data-extension],
[class*="grammarly"],
[id*="grammarly"],
[class*="1password"],
[id*="1password"],
[class*="lastpass"],
[id*="lastpass"],
[class*="dashlane"],
[id*="dashlane"],
[class*="bitwarden"],
[id*="bitwarden"],
[class*="honey"],
[id*="honey"],
[class*="keeper"],
[id*="keeper"],
[class*="chrome-extension"],
[id*="chrome-extension"],
/* Keeper specific selectors */
.keeper-fill-icon,
.keeper-fill-button,
.keeper-tooltip,
.keeper-popup,
#keeper-fill-icon,
#keeper-fill-button,
#keeper-tooltip,
#keeper-popup,
div[data-keeper],
span[data-keeper],
button[data-keeper] {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    position: absolute !important;
    left: -9999px !important;
    top: -9999px !important;
    width: 0 !important;
    height: 0 !important;
    z-index: -1 !important;
    pointer-events: none !important;
    transform: scale(0) !important;
}


/* Hide extension iframes and shadows */
iframe[src*="extension"],
iframe[src*="grammarly"],
iframe[src*="1password"],
iframe[src*="lastpass"],
iframe[src*="keeper"] {
    display: none !important;
}

/* Block extension stylesheets */
link[href*="extension"],
link[href*="grammarly"],
link[href*="1password"],
link[href*="lastpass"],
link[href*="keeper"] {
    display: none !important;
}

/* File Preview Modal Styles */
.file-preview-modal {
    z-index: 10000;
}

.file-preview-modal-content {
    max-width: 90vw;
    max-height: 90vh;
    width: 800px;
    background: #2d2d2d;
    border-radius: 12px;
    overflow: hidden;
}

.file-preview-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: #333;
    border-bottom: 2px solid #444;
}

.file-preview-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.file-preview-container {
    max-height: 60vh;
    overflow: auto;
    padding: 20px;
    background: #222;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
}

.file-preview-content {
    max-width: 100%;
    max-height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.file-preview-content img {
    max-width: 100%;
    max-height: 50vh;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.file-preview-content video {
    max-width: 100%;
    max-height: 50vh;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.file-preview-content audio {
    width: 100%;
    max-width: 500px;
}

.file-preview-content iframe {
    width: 100%;
    height: 50vh;
    border: none;
    border-radius: 8px;
    background: white;
}

.file-preview-content pre {
    background: #1a1a1a;
    color: #e0e0e0;
    padding: 20px;
    border-radius: 8px;
    overflow: auto;
    max-width: 100%;
    max-height: 40vh;
    white-space: pre-wrap;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.4;
}

.file-preview-error {
    text-align: center;
    color: #ff9800;
    padding: 40px;
}

.file-preview-error p {
    margin-bottom: 20px;
    font-size: 16px;
}

.file-preview-info {
    padding: 20px;
    background: #333;
    border-top: 2px solid #444;
}

.file-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.file-info-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.file-info-item label {
    font-weight: bold;
    color: #ff6b6b;
    font-size: 12px;
    text-transform: uppercase;
}

.file-info-item span {
    color: #e0e0e0;
    font-size: 14px;
    word-break: break-all;
}

.file-type-icon {
    font-size: 48px;
    margin-bottom: 20px;
}

.unsupported-file-preview {
    text-align: center;
    padding: 40px;
    color: #ccc;
}

.unsupported-file-preview .file-type-icon {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.7;
}

/* Drag and Drop Styles */
.message-input-container.drag-over {
    background: rgba(76, 175, 80, 0.2);
    border: 2px dashed #4caf50;
    border-radius: 8px;
}

.message-input-container.drag-over::before {
    content: '📎 Drop files here to upload';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(76, 175, 80, 0.9);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    z-index: 1000;
    pointer-events: none;
}

.mention-suggestions {
    position: absolute;
    bottom: 100%;
    left: 20px;
    right: 20px;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.mention-suggestion {
    padding: 10px 15px;
    border-bottom: 1px solid #333;
    cursor: pointer;
    transition: background 0.2s ease;
}

.mention-suggestion:hover {
    background: #333;
}

.mention-suggestion:last-child {
    border-bottom: none;
}

.mention-suggestion.selected {
    background: #404040;
}

.suggestion-name {
    font-weight: 500;
    color: #e0e0e0;
}

.suggestion-email {
    font-size: 12px;
    color: #aaa;
}

.suggestion-type {
    font-size: 11px;
    color: #ff6b6b;
    text-transform: uppercase;
}

/* Enhanced mention notifications */
.mention-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #ff5722;
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    z-index: 1002;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
    max-width: 350px;
    cursor: pointer;
    border-left: 4px solid #d32f2f;
}

.mention-notification.show {
    opacity: 1;
    transform: translateX(0);
}

.mention-notification.user-mention {
    background: #2196f3;
    border-left-color: #1976d2;
}

.mention-notification.all-mention {
    background: #ff5722;
    border-left-color: #d32f2f;
    animation: pulse-notification 1s ease-in-out;
}

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

.mention-notification .mention-content {
    font-size: 14px;
    opacity: 0.9;
}

.mention-notification:hover {
    transform: translateX(-5px);
    box-shadow: 0 6px 25px rgba(0,0,0,0.4);
}

@keyframes pulse-notification {
    0% { transform: translateX(0) scale(1); }
    50% { transform: translateX(0) scale(1.05); }
    100% { transform: translateX(0) scale(1); }
}

/* Notification Center Panel */
.notification-center {
    position: fixed;
    top: 70px;
    right: 20px;
    width: 350px;
    max-height: 400px;
    background: #2d2d2d;
    border: 1px solid #444;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    z-index: 1003;
    display: none;
    flex-direction: column;
}

.notification-center.show {
    display: flex;
}

.notification-center-header {
    padding: 15px 20px;
    border-bottom: 1px solid #444;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.notification-center-header h4 {
    color: #ff6b6b;
    margin: 0;
}

.clear-notifications-btn {
    background: #666;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}

.notification-center-header .close {
    font-size: 20px;
    margin: 0;
}

.notification-center-content {
    flex: 1;
    overflow-y: auto;
    max-height: 320px;
}

.notification-item {
    padding: 12px 20px;
    border-bottom: 1px solid #333;
    cursor: pointer;
    transition: background 0.2s ease;
}

.notification-item:hover {
    background: #3a3a3a;
}

.notification-item:last-child {
    border-bottom: none;
}

.notification-item.unread {
    background: rgba(255, 107, 107, 0.1);
    border-left: 3px solid #ff6b6b;
}

.notification-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.notification-item-title {
    font-weight: 500;
    color: #ff6b6b;
    font-size: 14px;
}

.notification-item-time {
    font-size: 11px;
    color: #888;
}

.notification-item-content {
    font-size: 13px;
    color: #ccc;
    line-height: 1.4;
}

.notification-item-room {
    font-size: 11px;
    color: #aaa;
    margin-top: 5px;
}

.notification-center-empty {
    padding: 40px 20px;
    text-align: center;
    color: #888;
    font-style: italic;
}

/* Form Elements */
input, select, textarea {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    background: #333;
    border: 2px solid #555;
    border-radius: 6px;
    color: #e0e0e0;
    outline: none;
    transition: border-color 0.3s ease;
}

input:focus, select:focus, textarea:focus { border-color: #ff6b6b; }

button {
    padding: 12px 24px;
    background: linear-gradient(45deg, #ff6b6b, #ff5252);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s ease;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

button:disabled:hover {
    transform: none;
    box-shadow: none;
}

.send-btn {
    padding: 12px 20px;
    border-radius: 25px;
    min-width: 80px;
}

/* Inline Image Preview Styles */
.inline-image-preview {
    margin: 12px 0;
    max-width: 500px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.inline-image-preview:hover {
    transform: scale(1.02);
}

.inline-image-preview img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
}

/* Inline image action buttons (below images) - clean, minimal style */
.inline-image-preview + .file-message-actions {
    background: transparent;
    border: none;
    padding: 0;
    margin-top: 8px;
}

/* File Overlay Styles (replaces modal for file preview) */
.file-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.file-overlay-controls {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 2001;
}

.file-overlay-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 10px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.file-overlay-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.file-overlay-close {
    background: rgba(255, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 10px 18px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 20px;
    font-weight: bold;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.file-overlay-close:hover {
    background: rgba(255, 0, 0, 0.8);
    transform: scale(1.1);
}

.file-overlay-content {
    max-width: 95vw;
    max-height: 95vh;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: default;
}

.file-overlay-content img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    cursor: zoom-in;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
}

.modal-content {
    background: #2d2d2d;
    margin: 10% auto;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    position: relative;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #555;
}

.modal-header h3 { color: #ff6b6b; margin: 0; }

.close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close:hover { color: #ff6b6b; }

.form-group {
    margin-bottom: 20px;
    position: relative;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #ccc;
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    margin: 0;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 15px 0;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.error-message {
    padding: 10px;
    margin: 10px 0;
    background: rgba(244, 67, 54, 0.2);
    color: #f44336;
    border-left: 3px solid #f44336;
    border-radius: 4px;
    font-size: 14px;
}

.success-message {
    padding: 10px;
    margin: 10px 0;
    background: rgba(76, 175, 80, 0.2);
    color: #4caf50;
    border-left: 3px solid #4caf50;
    border-radius: 4px;
    font-size: 14px;
}

.settings-section {
    margin-bottom: 30px;
}

.settings-section h4 {
    border-bottom: 1px solid #444;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.btn-secondary {
    background: #666;
}

.btn-secondary:hover {
    background: #777;
    transform: translateY(-1px);
}

.btn-danger {
    background: #f44336;
}

.btn-danger:hover {
    background: #d32f2f;
    transform: translateY(-1px);
}

/* User Search Styles */
.user-search-container {
    position: relative;
    margin-bottom: 15px;
}

.user-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.user-suggestion {
    padding: 10px 12px;
    color: #e0e0e0;
    cursor: pointer;
    border-bottom: 1px solid #333;
}

.user-suggestion:hover {
    background: #333;
}

.user-suggestion .user-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.user-suggestion .user-email {
    font-size: 0.85em;
    color: #999;
}

.selected-users {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.user-tag {
    background: #ff6b6b;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.user-tag .remove {
    cursor: pointer;
    font-weight: bold;
}

/* Room Members List */
.room-members-list {
    max-height: 300px;
    overflow-y: auto;
    background: #333;
    border-radius: 6px;
    padding: 10px;
}

.member-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    margin: 4px 0;
    background: #444;
    border-radius: 4px;
}

.member-info {
    flex: 1;
}

.member-name {
    font-weight: 500;
}

.member-email {
    font-size: 12px;
    color: #aaa;
}

.member-role {
    background: #666;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    text-transform: uppercase;
    margin-right: 8px;
}

.remove-member-btn {
    padding: 4px 8px;
    font-size: 11px;
    background: #f44336;
    border: none;
    border-radius: 4px;
    color: white;
    cursor: pointer;
}

.remove-member-btn:hover {
    background: #d32f2f;
}

/* Notification Styles */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    background: #333;
    border-radius: 8px;
    border-left: 4px solid #ff6b6b;
    color: #e0e0e0;
    z-index: 1001;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
}

.notification.show {
    opacity: 1;
    transform: translateX(0);
}

.notification.warning {
    border-left-color: #ff9800;
}

.notification.error {
    border-left-color: #f44336;
}

.notification.success {
    border-left-color: #4caf50;
}

/* Notification Preferences Modal */
.notification-preferences {
    background: #333;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.notification-preferences h4 {
    color: #ff6b6b;
    margin-bottom: 15px;
}

.preference-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 8px 12px;
    background: #444;
    border-radius: 6px;
}

.preference-toggle {
    position: relative;
    width: 50px;
    height: 25px;
    background: #666;
    border-radius: 15px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.preference-toggle.active {
    background: #4caf50;
}

.preference-toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 21px;
    height: 21px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
}

.preference-toggle.active::after {
    transform: translateX(25px);
}

/* Utility Classes */
.hidden { display: none !important; }
.error {
    color: #f44336;
    margin: 10px 0;
    text-align: center;
    padding: 10px;
    background: rgba(244, 67, 54, 0.1);
    border-radius: 6px;
    border: 1px solid rgba(244, 67, 54, 0.3);
}
.success {
    color: #4caf50;
    margin: 10px 0;
    text-align: center;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Mobile-First Responsive Design */

/* Mobile Layout (default - up to 768px) */
@media (max-width: 768px) {
    body {
        overflow: hidden;
        position: fixed;
        width: 100%;
        /* Use CSS variable set by JavaScript for accurate iOS Safari viewport height */
        /* Falls back to 100vh if --vh is not set */
        height: calc(var(--vh, 1vh) * 100);
    }

    /* Mobile Chat Container */
    .chat-container {
        flex-direction: column;
        height: calc(var(--vh, 1vh) * 100);
        overflow: hidden;
    }

    /* Mobile Sidebar - Hidden by default, shows as overlay */
    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 280px;
        height: calc(var(--vh, 1vh) * 100);
        padding-top: calc(env(safe-area-inset-top) + 10px);
        z-index: 9999;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.3);
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .sidebar.mobile-open {
        left: 0;
    }

    /* Mobile overlay when sidebar is open */
    .mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 9998;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }

    /* Mobile Emoji Picker */
    .emoji-picker-container {
        top: auto;
        bottom: 60px;
        right: 10px;
        left: 10px;
        width: auto;
    }

    emoji-picker.full-emoji-picker {
        width: 100%;
        height: 350px;
        --num-columns: 7;
    }

    .mobile-overlay.active {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    /* Mobile Main Chat Area */
    .main-chat {
        flex: 1;
        min-height: calc(var(--vh, 1vh) * 100); /* Use JS-calculated viewport height for iOS Safari */
        display: flex;
        flex-direction: column;
    }

    /* Mobile Chat Header with hamburger menu */
    .chat-header {
        position: relative;
        padding: 12px 15px;
        padding-top: calc(12px + env(safe-area-inset-top));
        background: #2d2d2d;
        border-bottom: 2px solid #444;
        display: flex;
        align-items: center;
        gap: 15px;
        min-height: calc(60px + env(safe-area-inset-top));
    }

    /* Mobile hamburger menu button - styled EXACTLY like .mobile-header-menu-btn which works perfectly */
    .mobile-menu-btn {
        background: #555;
        color: #ff6b6b;
        border: none;
        border-radius: 4px;
        width: 44px;
        height: 44px;
        font-size: 22px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background 0.2s ease;
        flex-shrink: 0;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        /* Ensure button is above any overlapping elements */
        position: relative;
        z-index: 100;
    }

    .mobile-menu-btn:active {
        background: #666;
    }

    /* Mobile logo adjustments */
    .chat-header-info {
        flex: 1;
        display: flex;
        align-items: center;
        gap: 8px;
        min-width: 0;
    }

    .chat-header-logo {
        width: 20px;
        height: auto;
        flex-shrink: 0;
    }

    .chat-header h3 {
        flex: 1;
        font-size: 16px;
        margin: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        min-width: 0; /* Allow shrinking */
    }

    /* Mobile login logo */
    .login-logo-img {
        width: 60px;
        max-width: 80px;
        height: auto;
    }

    /* Mobile password field - no special overrides needed with flexbox */
    .password-toggle:active {
        background: rgba(255, 107, 107, 0.15);
    }

    /* Mobile sidebar logo (when visible) */
    .sidebar-logo {
        width: 28px;
    }

    /* Mobile search adjustments */
    .search-container {
        max-width: 250px;
        margin: 0 10px;
    }

    .global-search-input {
        padding: 8px 12px;
        font-size: 14px;
    }

    .search-btn, .advanced-search-btn {
        padding: 6px 10px;
        font-size: 12px;
    }

    /* Mobile search modals */
    .search-results-modal .modal-content {
        width: 95%;
        max-height: 95vh;
        margin: 2.5vh auto;
    }

    .modal-content {
        width: 95%;
        margin: 5vh auto;
    }

    .form-row {
        flex-direction: column;
        gap: 15px;
    }

    .search-tabs {
        flex-wrap: wrap;
        gap: 3px;
    }

    .search-tab {
        padding: 6px 12px;
        font-size: 14px;
    }

    .search-result {
        padding: 12px;
        margin-bottom: 12px;
    }

    .search-result-meta {
        flex-direction: column;
        gap: 5px;
        align-items: flex-start;
    }

    .search-result-actions {
        flex-direction: column;
        gap: 8px;
    }

    .search-result-btn {
        width: 100%;
        text-align: center;
    }

    /* MOBILE HEADER CONSOLIDATION - Keep only members count, hide other buttons */
    /* These buttons are accessible via the hamburger menu (top right) */

    /* Hide favorite star button */
    .favorite-star-btn,
    #favoriteStarBtn {
        display: none !important;
    }

    /* Hide mute/notifications bell button */
    .mute-notifications-btn,
    #muteNotificationsBtn {
        display: none !important;
    }

    /* Hide search button (accessible via hamburger menu) */
    .header-search-btn,
    #headerSearchBtn {
        display: none !important;
    }

    /* Hide pinned messages button (accessible via hamburger menu) */
    .pinned-messages-btn,
    #pinnedMessagesBtn {
        display: none !important;
    }

    /* Hide manage/delete buttons on mobile */
    .manage-room-btn, .delete-room-btn {
        display: none !important;
    }

    /* Admin panel button hidden on mobile - controlled by mobile menu */
    #adminPanelBtn {
        display: none !important;
    }

    /* Mobile header menu button (TOP RIGHT - room functionality) */
    .mobile-header-menu-btn {
        background: #3a3a3a;
        color: #ff6b6b;
        border: 1px solid #555;
        border-radius: 6px;
        width: 36px;
        height: 36px;
        font-size: 18px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background 0.2s ease;
        flex-shrink: 0;
        /* Ensure solid background on Android */
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
        opacity: 1;
    }

    .mobile-header-menu-btn:hover,
    .mobile-header-menu-btn:active {
        background: #4a4a4a;
        transform: none;
        box-shadow: none;
    }

    /* Mobile header dropdown menu */
    .mobile-header-dropdown {
        position: absolute;
        top: 100%;
        right: 0;
        background: #2a2a2a;
        border: 1px solid #444;
        border-radius: 6px;
        min-width: 150px;
        box-shadow: 0 4px 20px rgba(0,0,0,0.3);
        z-index: 1100; /* Higher than modal (1000) so it's clickable when modal is open */
        display: none;
        overflow: hidden;
        margin-top: 5px;
    }

    .mobile-header-dropdown.show {
        display: block;
    }

    .mobile-header-menu-item {
        /* Reset button styles */
        background: none;
        border: none;
        border-bottom: 1px solid #333;
        width: 100%;
        text-align: left;
        color: #e0e0e0;
        /* Menu item styles */
        padding: 12px 16px;
        cursor: pointer;
        font-size: 14px;
        transition: background 0.2s ease;
        display: flex;
        align-items: center;
        gap: 8px;
        /* iOS touch fix */
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(255, 255, 255, 0.1);
    }

    .mobile-header-menu-item:last-child {
        border-bottom: none;
    }

    .mobile-header-menu-item:hover {
        background: #333;
    }

    .mobile-header-menu-item.manage {
        color: #ff9800;
    }

    .mobile-header-menu-item.delete {
        color: #f44336;
    }

    .mobile-header-menu-item.admin {
        color: #2196f3;
    }

    /* Mobile Messages Area */
    .messages {
        flex: 1;
        padding: 15px 12px;
        padding-bottom: 240px; /* Increased padding for floating input container (150px bottom + input height) */
        overflow-y: auto;
        overflow-x: hidden; /* Prevent horizontal scrolling - fix for mobile swipe bug */
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    }

    .message {
        margin: 8px 0;
        padding: 12px;
        font-size: 14px;
        border-radius: 12px;
        border-left-width: 3px;
    }

    .message .sender {
        font-size: 13px;
        margin-bottom: 4px;
    }

    .message .content {
        line-height: 1.4;
        word-break: break-word;
    }

    /* Mobile Message Input */
    .message-input-container {
        padding: 12px;
        background: #2d2d2d;
        border-top: 2px solid #444;
        position: fixed; /* Changed from sticky to fixed for reliable keyboard behavior */
        bottom: 20px; /* Default fallback - JavaScript adjusts dynamically via visualViewport API */
        left: 8px;
        right: 8px;
        z-index: 100;
        /* Fully rounded corners for floating card appearance */
        border-radius: 12px;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
        max-width: calc(100% - 16px);
        /* Smooth transition when JavaScript adjusts position */
        transition: bottom 0.2s ease-out;
    }

    .input-controls {
        gap: 8px;
    }

    .file-upload-btn {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    .message-input {
        padding: 10px 15px;
        font-size: 16px; /* Prevent zoom on iOS */
        border-radius: 20px;
        min-height: 36px;
    }

    .send-btn {
        padding: 10px 16px;
        min-width: 60px;
        border-radius: 20px;
        font-size: 14px;
    }

    /* Mobile Login */
    .login-box {
        width: 90%;
        margin: 20px;
        padding: 30px 25px;
    }

    .login-box h2 {
        font-size: 20px;
        margin-bottom: 25px;
    }

    /* Mobile Modals */
    .modal-content {
        width: 95%;
        max-width: 400px;
        margin: 5% auto;
        padding: 20px;
        max-height: 90vh;
    }

    .modal-header h3 {
        font-size: 18px;
    }

    /* Mobile File Preview Modal */
    .file-preview-modal-content {
        width: 95vw;
        max-width: 95vw;
        height: 90vh;
        max-height: 90vh;
    }

    .file-preview-container {
        max-height: 50vh;
        padding: 15px;
    }

    .file-preview-content img,
    .file-preview-content video {
        max-height: 40vh;
    }

    .file-info-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    /* Mobile Notifications */
    .notification, .mention-notification {
        right: 10px;
        left: 10px;
        width: auto;
        padding: 12px 15px;
        font-size: 13px;
        border-radius: 6px;
    }

    .notification-center {
        right: 10px;
        left: 10px;
        width: auto;
        max-width: calc(100vw - 20px);
        top: 60px;
    }

    /* Mobile Room Items */
    .room-item {
        padding: 12px 15px;
        margin: 0; /* Remove all margins to prevent hiding */
        font-size: 14px;
        min-width: 0; /* Allow shrinking */
        min-height: 44px; /* iOS minimum touch target size */
        border-bottom: 1px solid #333; /* Visual separation between rooms */
        /* iOS touch optimization */
        cursor: pointer;
        -webkit-tap-highlight-color: rgba(255, 107, 107, 0.2);
        touch-action: manipulation;
    }

    /* Remove extra spacing - let scrolling handle visibility */
    .room-section {
        margin-bottom: 10px; /* Reduced space between sections */
        padding-top: 5px; /* Small padding to ensure first room is visible */
    }

    /* Ensure first room item is visible */
    .room-section .room-item:first-child {
        margin-top: 0 !important; /* Force no top margin */
        border-top: none; /* No top border for first item */
        padding-top: 8px !important; /* Ensure adequate padding */
        display: block !important; /* Force display */
        visibility: visible !important; /* Force visibility */
    }

    /* Ensure rooms list has enough top padding on mobile */
    .rooms-list {
        padding-top: 8px; /* Add top padding to prevent overlap */
        min-height: 50px; /* Ensure container has minimum height */
    }

    /* Add padding to bottom of rooms container */
    .rooms-container::after {
        content: '';
        display: block;
        height: 20px;
    }

    .room-name {
        font-size: 14px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        flex: 1;
        min-width: 0; /* Allow shrinking */
        max-width: 160px; /* Limit width to prevent overflow */
    }

    .room-actions {
        opacity: 1; /* Always show on mobile */
    }

    .room-manage-btn, .room-delete-btn {
        padding: 6px 8px;
        font-size: 10px;
    }

    /* Mobile Sidebar Sections */
    .sidebar-header {
        padding: 10px 15px 5px 15px; /* Reduced padding */
        background: #2d2d2d;
        flex-shrink: 0; /* Don't shrink when content scrolls */
    }

    .sidebar-header h3 {
        font-size: 16px;
    }

    .create-room-btn {
        padding: 6px 10px;
        font-size: 11px;
    }

    .rooms-container {
        flex: 1; /* Take remaining space */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 0; /* Remove padding to maximize space */
        /* iOS touch optimization: allow vertical scroll while enabling fast taps */
        touch-action: pan-y;
    }

    .room-section-header {
        padding: 8px 15px 6px 15px; /* Reduced padding */
        font-size: 11px;
        position: static; /* Remove sticky positioning that might hide first item */
        background: #2d2d2d;
        margin-bottom: 3px; /* Small margin for separation */
        border-bottom: 1px solid #333; /* Add visual separation */
    }

    /* Mobile User Info */
    .sidebar-footer {
        padding: 12px 15px;
        /* Add extra bottom padding to avoid browser navigation overlap */
        /* Increased to 60px for better clearance on all mobile browsers */
        padding-bottom: max(60px, calc(12px + env(safe-area-inset-bottom, 60px)));
        background: #252525;
        flex-shrink: 0; /* Don't shrink when content scrolls */
        border-top: 1px solid #333; /* Visual separation */
    }

    .user-info {
        gap: 8px;
        margin-bottom: 8px;
    }

    .user-avatar {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    .user-name {
        font-size: 13px;
    }

    .user-role {
        font-size: 10px;
    }

    .logout-btn {
        padding: 6px;
        font-size: 11px;
    }

    /* Mobile Mention Suggestions */
    .mention-suggestions {
        left: 12px;
        right: 12px;
        max-height: 150px;
    }

    .mention-suggestion {
        padding: 8px 12px;
        font-size: 13px;
    }

    /* Mobile File Messages */
    .file-message {
        padding: 10px;
        margin: 6px 0;
        gap: 10px;
    }

    .file-message-icon {
        font-size: 20px;
    }

    .file-message-name {
        font-size: 13px;
    }

    .file-message-details {
        font-size: 11px;
        gap: 8px;
    }

    .file-message-download {
        padding: 5px 10px;
        font-size: 11px;
    }

    /* Mobile Emoji Picker */
    .emoji-picker {
        max-width: 280px;
        min-width: 280px;
        padding: 8px;
        top: -250px;
        max-height: 240px;
    }

    .emoji-picker-header {
        font-size: 12px;
        margin-bottom: 8px;
        padding-bottom: 6px;
    }

    .emoji-category-label {
        font-size: 10px;
        margin-bottom: 4px;
    }

    .emoji-row {
        gap: 2px;
    }

    .emoji-option {
        width: 28px;
        height: 28px;
        font-size: 18px;
        padding: 4px;
    }

    /* Mobile Touch Improvements */
    .room-item, .message-action-btn, .reaction-button, .file-upload-btn, .send-btn {
        -webkit-tap-highlight-color: rgba(255, 107, 107, 0.2);
        touch-action: manipulation;
    }

    /* Disable text selection on UI elements */
    .sidebar-header, .chat-header, .room-section-header, .sidebar-footer {
        -webkit-user-select: none;
        user-select: none;
    }

    /* Mobile form improvements */
    input, select, textarea {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 12px;
    }

    /* Mobile DM Modal */
    .start-dm-content {
        width: 95%;
        max-width: 400px;
        padding: 20px;
    }

    .dm-user-search {
        font-size: 16px;
        padding: 12px;
    }

    .dm-user-suggestion {
        padding: 10px 12px;
    }

    .dm-suggestion-avatar {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    .dm-suggestion-name {
        font-size: 13px;
    }

    .dm-suggestion-email {
        font-size: 11px;
    }
}

/* Desktop Layout (769px and up) */
@media (min-width: 769px) {
    /* Password field uses flexbox - no special positioning needed */

    /* Hide mobile header menu button on all desktop sizes */
    .mobile-header-menu-btn, .mobile-header-dropdown {
        display: none !important;
    }
}

/* Tablet Landscape (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 240px;
    }

    .chat-header {
        padding: 12px 18px;
    }

    .messages {
        padding: 18px;
    }

    .message-input-container {
        padding: 16px;
    }

    .modal-content {
        width: 80%;
        max-width: 600px;
    }
}

/* Desktop (1025px and up) */
@media (min-width: 1025px) {
    /* Ensure desktop layout is preserved */
    .sidebar {
        position: static;
        width: 280px;
    }

    .main-chat {
        flex: 1;
    }

    .mobile-menu-btn {
        display: none;
    }

    .mobile-overlay {
        display: none;
    }

    /* Show desktop buttons, hide mobile menu - JavaScript controls visibility with .hidden class */
    .manage-room-btn:not(.hidden), .delete-room-btn:not(.hidden) {
        display: block;
    }

    /* Admin panel button controlled by JavaScript based on role */
    #adminPanelBtn:not(.hidden) {
        display: block;
    }

    .mobile-header-menu-btn, .mobile-header-dropdown {
        display: none !important;
    }
}

/* Large Desktop (1440px and up) */
@media (min-width: 1440px) {
    .sidebar {
        width: 320px;
    }

    .messages {
        padding: 25px 30px;
    }

    .message {
        padding: 16px 20px;
        max-width: 800px;
    }

    .modal-content {
        max-width: 600px;
    }
}

/* Ultra Wide (1920px and up) */
@media (min-width: 1920px) {
    .chat-container {
        max-width: 1600px;
        margin: 0 auto;
    }

    .messages {
        padding: 30px 40px;
    }

    .message {
        max-width: 900px;
    }
}

/* ==================== RICH TEXT FORMATTING STYLES ==================== */

/* Auto-linked URLs - NUCLEAR OVERRIDE */
/* Traditional hyperlink styling - classic blue, underlined, no box */
a:not(.file-message-download):not(.file-preview-btn),
a.auto-link,
.message-content a:not(.file-message-download),
.message-content a.auto-link,
.message-content .auto-link,
.auto-link,
a[class*="auto-link"],
a[href*="http"]:not(.file-message-download),
a[href*="www"]:not(.file-message-download) {
    color: #0066cc !important; /* Traditional blue hyperlink color */
    text-decoration: underline !important;
    transition: color 0.2s ease, text-decoration-color 0.2s ease !important;
    font-weight: 500 !important;
    /* Removed: background-color, padding, border-radius, border */
}

a.auto-link:hover,
.message-content a.auto-link:hover,
.message-content .auto-link:hover,
.auto-link:hover,
a[class*="auto-link"]:hover {
    color: #0052a3 !important; /* Darker blue on hover */
    text-decoration: underline !important;
    font-weight: 600 !important;
    /* Removed: background-color */
}

/* File download button override - NO BORDER/BACKGROUND */
a.file-message-download,
.file-message a.file-message-download,
.file-message-actions a.file-message-download,
.message-content a.file-message-download,
div.file-message a[class="file-message-download"] {
    background: none !important;
    background-color: transparent !important;
    color: #4caf50 !important;
    border: none !important;
    padding: 0 !important;
    font-weight: normal !important;
    text-decoration: none !important;
}

a.file-message-download:hover,
.file-message a.file-message-download:hover,
.file-message-actions a.file-message-download:hover,
.message-content a.file-message-download:hover,
div.file-message a[class="file-message-download"]:hover {
    background: none !important;
    background-color: transparent !important;
    color: #66bb6a !important;
    text-decoration: none !important;
}

/* Mentions */
.mention {
    background: rgba(79, 195, 247, 0.2);
    color: #4fc3f7;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    border: 1px solid rgba(79, 195, 247, 0.3);
}

/* Markdown formatting in messages */
.message-content strong,
.message-content b {
    color: #ffffff;
    font-weight: 700;
}

.message-content em,
.message-content i {
    color: #e0e0e0;
    font-style: italic;
}

.message-content code {
    background: rgba(255, 255, 255, 0.1);
    color: #ff9800;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.message-content pre {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    margin: 8px 0;
    overflow-x: auto;
}

.message-content pre code {
    display: block;
    padding: 12px 16px;
    background: transparent;
    color: #e0e0e0;
    border-radius: 0;
    white-space: pre;
    line-height: 1.4;
}

/* Blockquote styling for quoted text */
.message-content blockquote {
    border-left: 3px solid #6b7280;
    padding-left: 12px;
    margin: 8px 0;
    color: #9ca3af;
    font-style: italic;
}

.message-content blockquote p {
    margin: 0;
}

/* Syntax highlighting support */
.language-javascript { color: #f39c12; }
.language-python { color: #3498db; }
.language-html { color: #e74c3c; }
.language-css { color: #9b59b6; }
.language-sql { color: #2ecc71; }
.language-json { color: #f39c12; }

/* Make sure rich text is properly displayed in message content */
.message-content {
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    line-height: 1.5;
    max-width: 100%;
    white-space: pre-wrap;
}

.message-content p {
    margin: 0;
}

.message-content p + p {
    margin-top: 8px;
}

/* =================================================================
   TOAST NOTIFICATION SYSTEM
   ================================================================= */

.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast-notification {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    min-width: 300px;
    max-width: 400px;
    pointer-events: auto;
    cursor: pointer;
    animation: slideIn 0.3s ease-out;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast-notification:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}

.toast-notification.hiding {
    opacity: 0;
    transform: translateX(400px);
}

.toast-notification .toast-title {
    font-weight: bold;
    font-size: 15px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast-notification .toast-icon {
    font-size: 20px;
}

.toast-notification .toast-body {
    font-size: 14px;
    opacity: 0.95;
    line-height: 1.4;
}

.toast-notification .toast-room {
    font-size: 12px;
    opacity: 0.8;
    margin-top: 6px;
    font-style: italic;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(400px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .toast-container {
        top: 70px;
        right: 10px;
        left: 10px;
    }

    .toast-notification {
        min-width: auto;
        max-width: none;
    }
}
/* Notification Status Banner (Mobile) */
.notification-status-banner {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
    color: white;
    padding: 12px 15px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    border-bottom: 2px solid rgba(255,255,255,0.3);
}

.notification-status-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
}

#notificationStatusText {
    flex: 1;
    line-height: 1.4;
}

.enable-notifications-btn {
    background: white;
    color: #ee5a24;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.enable-notifications-btn:active {
    transform: scale(0.95);
    background: #f8f8f8;
}

/* Hide on desktop */
@media (min-width: 769px) {
    .notification-status-banner {
        display: none !important;
    }
}

/* ==================== SCROLL TO BOTTOM BUTTON ==================== */
#scrollToBottomBtn {
    position: fixed;
    bottom: 90px;
    right: 30px;
    width: 48px;
    height: 48px;
    background: #ee5a24;
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    z-index: 1000;
}

#scrollToBottomBtn:hover {
    background: #d94e1f;
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

#scrollToBottomBtn:active {
    transform: scale(0.95);
}

#scrollToBottomBtn.show {
    display: flex;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    #scrollToBottomBtn {
        bottom: 80px;
        right: 20px;
        width: 44px;
        height: 44px;
        font-size: 22px;
    }
}

/* =============================================================================
   iOS TOUCH FIX
   Fixes "sticky hover" issue where first tap triggers :hover, second tap clicks.
   - touch-action: manipulation prevents 300ms delay and double-tap zoom
   - @media (hover: none) disables hover effects on touch-only devices
   ============================================================================= */

/* Add touch-action to all clickable elements for faster response */
.room-item,
.mobile-menu-btn,
.mobile-header-menu-btn,
.mobile-header-menu-item,
.mobile-overlay,
.start-dm-btn,
.room-manage-btn,
.room-delete-btn,
.room-favorite-btn,
.send-btn,
.message-input,
.room-section,
.room-section-header,
.sidebar,
button,
a {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Disable hover effects on touch-only devices (prevents sticky hover on iOS) */
@media (hover: none) {
    .room-item:hover {
        background: inherit;
    }

    #unreadSection .room-item:hover {
        background: rgba(255, 107, 107, 0.05);
    }

    .room-item:hover .room-actions {
        opacity: 0;
    }

    .mobile-menu-btn:hover {
        background: none;
    }

    .start-dm-btn:hover {
        transform: none;
        background: #ff6b6b;
    }

    /* Use :active for touch feedback instead of :hover */
    .room-item:active {
        background: #3a3a3a;
    }

    #unreadSection .room-item:active {
        background: rgba(255, 107, 107, 0.15);
    }

    .mobile-menu-btn:active {
        background: rgba(255, 107, 107, 0.1);
    }
}

/* =============================================================================
   iOS SAFARI VIEWPORT FIX
   Fixes the issue where 100vh is larger than the visible area on iOS Safari
   because it includes the space behind the address bar/toolbar.

   Solution: Use dvh (dynamic viewport height) with fallbacks for older browsers.
   - 100vh: Fallback for older browsers
   - -webkit-fill-available: iOS Safari fallback
   - 100dvh: Modern browsers (dynamic, accounts for browser chrome)
   ============================================================================= */

/* iOS Safari and Modern Viewport Fixes
   Primary approach: Use JavaScript-set --vh variable (most reliable)
   The --vh variable is updated by visualViewport API listeners in app.js
   Falls back to 100dvh or -webkit-fill-available if --vh not available */

@supports (-webkit-touch-callout: none) {
    /* iOS Safari specific fixes - use --vh variable (set by visualViewport API in app.js) */
    body {
        /* --vh is set by JavaScript using visualViewport.height for accuracy */
        /* Falls back to 1vh * 100 = 100vh if --vh not yet set */
        height: calc(var(--vh, 1vh) * 100);
    }

    .login-container {
        height: calc(var(--vh, 1vh) * 100);
        min-height: calc(var(--vh, 1vh) * 100);
    }

    .chat-container {
        height: calc(var(--vh, 1vh) * 100);
        min-height: calc(var(--vh, 1vh) * 100);
    }

    .sidebar {
        height: calc(var(--vh, 1vh) * 100);
    }

    .main-chat {
        height: calc(var(--vh, 1vh) * 100);
        min-height: calc(var(--vh, 1vh) * 100);
    }
}

/* Modern viewport units - use --vh variable with 100dvh fallback */
@supports (height: 100dvh) {
    body {
        height: calc(var(--vh, 1vh) * 100);
    }

    .login-container {
        height: calc(var(--vh, 1vh) * 100);
        min-height: calc(var(--vh, 1vh) * 100);
    }

    .chat-container {
        height: calc(var(--vh, 1vh) * 100);
        min-height: calc(var(--vh, 1vh) * 100);
    }

    .sidebar {
        height: calc(var(--vh, 1vh) * 100);
    }

    .main-chat {
        height: calc(var(--vh, 1vh) * 100);
        min-height: calc(var(--vh, 1vh) * 100);
    }
}

/* =============================================================================
   MOBILE HEADER MENU ITEM COLORS
   ============================================================================= */

@media (max-width: 768px) {
    /* Style for action menu items */
    .mobile-header-menu-item.search {
        color: #4fc3f7;
    }

    .mobile-header-menu-item.members {
        color: #81c784;
    }

    .mobile-header-menu-item.favorite {
        color: #ffd54f;
    }

    .mobile-header-menu-item.mute {
        color: #ffb74d;
    }

    .mobile-header-menu-item.pinned {
        color: #ba68c8;
    }
}

/* =============================================================================
   MOBILE HEADER CLEANUP - FINAL OVERRIDE
   Hide interactive buttons on mobile/tablet, keep only members count + hamburger menu
   Covers: phones (portrait/landscape), tablets (portrait)
   ============================================================================= */
@media (max-width: 1024px) {
    /* Hide star button on mobile */
    button.favorite-star-btn,
    button#favoriteStarBtn,
    .chat-header .favorite-star-btn,
    .chat-header-info .favorite-star-btn {
        display: none !important;
        visibility: hidden !important;
    }

    /* Hide bell/mute button on mobile */
    button.mute-notifications-btn,
    button#muteNotificationsBtn,
    .chat-header .mute-notifications-btn,
    .chat-header-info .mute-notifications-btn {
        display: none !important;
        visibility: hidden !important;
    }

    /* Hide search button on mobile */
    button.header-search-btn,
    button#headerSearchBtn,
    .chat-header .header-search-btn,
    .room-info .header-search-btn {
        display: none !important;
        visibility: hidden !important;
    }

    /* Hide pin button on mobile */
    button.pinned-messages-btn,
    button#pinnedMessagesBtn,
    .chat-header .pinned-messages-btn,
    .room-info .pinned-messages-btn {
        display: none !important;
        visibility: hidden !important;
    }
}

/* =============================================================================
   ANDROID KEYBOARD FIX
   Prevents sidebar from moving/shrinking when keyboard opens on Android
   ============================================================================= */

/* When Android keyboard is open, lock sidebar in place */
.sidebar.android-keyboard-open {
    /* Force GPU layer to prevent repaints */
    will-change: transform;
    transform: translateZ(0) !important;
    -webkit-transform: translateZ(0) !important;

    /* Lock position absolutely */
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: auto !important;
    bottom: 0 !important;
    width: 280px !important;
    height: 100% !important;
    min-height: 100% !important;
    max-height: none !important;

    /* Disable ALL transitions to prevent animation during keyboard */
    transition: none !important;
    -webkit-transition: none !important;

    /* Prevent any layout recalculation */
    contain: layout style paint !important;
}

/* Prevent body from scrolling when Android keyboard is open */
body.android-keyboard-open {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    overflow: hidden !important;
}

/* Prevent html from scrolling too */
html:has(body.android-keyboard-open) {
    overflow: hidden !important;
    height: 100% !important;
}

/* Ensure rooms container doesn't scroll unexpectedly */
.sidebar.android-keyboard-open .rooms-container {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ==================== SKELETON LOADING UI ==================== */
/* Phase 2: Slow connection optimizations - skeleton placeholders */

.skeleton {
    background: linear-gradient(90deg, #2a2a2a 25%, #3a3a3a 50%, #2a2a2a 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Skeleton message layout */
.skeleton-message {
    display: flex;
    gap: 10px;
    padding: 10px 15px;
    margin-bottom: 8px;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
}

.skeleton-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.skeleton-line {
    height: 14px;
}

.skeleton-line.short { width: 30%; }
.skeleton-line.medium { width: 60%; }
.skeleton-line.long { width: 85%; }

/* Skeleton room item layout */
.skeleton-room-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    margin-bottom: 4px;
}

.skeleton-room-item .skeleton-avatar {
    width: 32px;
    height: 32px;
}

/* Light mode skeleton colors */
body.light-mode .skeleton {
    background: linear-gradient(90deg, #e0e0e0 25%, #f0f0f0 50%, #e0e0e0 75%);
    background-size: 200% 100%;
}

/* Loading indicator for stale-while-revalidate pattern */
.messages-loading-indicator {
    text-align: center;
    padding: 8px;
    color: #888;
    font-size: 12px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    margin: 10px 15px;
}

body.light-mode .messages-loading-indicator {
    background: rgba(0, 0, 0, 0.1);
    color: #666;
}
