* { box-sizing: border-box; margin: 0; padding: 0;}

/* 1. Stop the whole webpage from bouncing & fix mobile keyboard squish */
/* 1. Stop the whole webpage from bouncing & fix mobile keyboard squish */
html, body {
    height: 100%; /* Fallback for very old browsers */
    height: 100dvh; /* THE MODERN FIX: Dynamic Viewport Height */
    overflow: hidden;
    overscroll-behavior-y: none;
    position: fixed;
    width: 100%;
    margin: 0;
    padding: 0;
}
input, button, textarea, select {
    font-family: inherit;
}
/* 2. Lock the app exactly to the visible window */
.app-container {
    display: flex;
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    height: 100%; /* Fallback */
    height: 100dvh; /* THE MODERN FIX */
    width: 100vw;
    background: #f4f7f6;
    overflow: hidden;
}

/* 3. Main Chat Window - strictly confined so the header never moves */
.chat-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background: white;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    transition: margin-right 0.3s ease-in-out; /* <-- ADD THIS LINE */
}

/* 4. Smooth scrolling only inside the message area */
#chat-box {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
	/* Apply the background specifically to the message area */
    background-image: url('light-mode.png');
    background-size: cover; /* 'cover' usually looks better than 100% 100% so it doesn't warp, but you can use 100% 100% if you prefer! */
    background-position: bottom right; /* Pin it to the bottom right so your logo stays anchored */
    background-repeat: no-repeat;
    /*background: transparent !important;*/
}

/* =========================================
   MOBILE SIDEBAR RULES
   ========================================= */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        top: 0;
        bottom: 0;
        left: -260px; /* Always hidden by default on phone load! */
        z-index: 1000;
        transition: left 0.3s ease-in-out;
        box-shadow: 2px 0 10px rgba(0,0,0,0.5); /* Optional: Adds a nice shadow over the chat when open */
    }

    /* This class is what Javascript will use to open the menu */
    .sidebar.active {
        left: 0;
    }
}
/* Sidebar Styling */
.sidebar {
    width: 260px;
    background: #2c3e50;
    color: white;
    padding: 20px;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.sidebar h3 { margin-bottom: 20px; color: #bdc3c7; font-size: 0.9rem; text-transform: uppercase; }

#channel-list { list-style: none; flex-grow: 1; }

#channel-list li {
    padding: 5px;
    cursor: pointer;
    border-radius: 4px;
    margin-bottom: 5px;
}

#channel-list li.active, #channel-list li:hover { background: #34495e; }

/* Main Chat Window */
.chat-messages {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden; /* Prevents accidental horizontal scrolling */
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Message Bubbles */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.message {
    background: white;
    padding: 10px 15px;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    max-width: 98%;
    animation: fadeIn 0.3s ease-out;
}

.message .user { font-weight: bold; color: #2980b9; display: block; }

.message-body {
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Input Area */
.chat-input {
    padding: 20px;
    background: white;
    display: flex;
    gap: 10px;
}

.chat-input input {
    flex-grow: 1;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    outline: none;
}

.chat-input button {
    padding: 10px 20px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.input-area {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 15px;
    width: 100%;
    box-sizing: border-box;
}

#send-button {
    padding: 10px 20px;
    flex-shrink: 0;
}

/* User Profile & Utilities */
.user-profile {
    margin-top: auto;
    padding-top: 15px;
    border-top: 1px solid #3e4f5f;
    font-size: 0.9rem;
}

ul { list-style-type: none; }

.unread-dot {
    display: none;
    width: 8px;
    height: 8px;
    background-color: #e74c3c;
    border-radius: 50%;
    margin-left: 8px;
    vertical-align: middle;
}

li.has-unread .unread-dot { display: inline-block; }

#clear-search:hover { color: #666 !important; }

/* Buttons */
.edit-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    outline: inherit;
    color: #333;
    font-size: 0.8rem;
    transition: color 0.3s;
}

.edit-btn:hover { color: #007bff; }

.delete-btn {
    background-color: #f44336;
    color: white;
    padding: 1px 1.5px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.delete-btn:hover { background-color: #da190b; }

/* --- Desktop Styles --- */
.sidebar-overlay { display: none; }

/* Hide pancake menu on larger screens (Moved outside the mobile query!)
@media (min-width: 768px) {
    #mobile-menu-btn {
        display: none !important;
    }
}
*/

/* --- Mobile Styles --- */
@media (max-width: 767px) {
    .app-container {
        flex-direction: column;
        overflow: hidden;
        height: 100vh;
    }

    /* 1. Sidebar Sliding Magic (Kept intact) */
    .sidebar {
        position: fixed !important;
        left: -280px;
        top: 0;
        bottom: 0;
        width: 280px !important;
        z-index: 9999;
        transition: left 0.3s ease;
        background: #1a1a1a;
        box-shadow: 5px 0 15px rgba(0,0,0,0.5);
    }

    .sidebar.active { left: 0 !important; }

    .sidebar.active + .sidebar-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 9998; /* Ensures overlay sits under sidebar but over chat */
    }

    /* 2. Header Compression */
    .chat-header {
        padding: 10px;
    }

    .header-left, .header-right {
        gap: 8px; /* Tighter spacing */
    }

    /* Prevent long channel names from breaking the layout */
    .header-left h2 {
        font-size: 1.1rem;
        max-width: 100px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Shrink the search bar */
    .search-container input {
        width: 80px;
        padding: 6px;
        font-size: 0.8rem;
    }

    /* Hide text on buttons, show only icons to save space */
    #toggle-pinned-btn {
        font-size: 0; /* Hides the word "Pinned" */
        padding: 8px;
    }
    #toggle-pinned-btn::before {
        content: "📌";
        font-size: 1rem;
    }

    #manage-members-btn {
        font-size: 0; /* Hides the word "Manage" */
        padding: 8px;
    }
    #manage-members-btn i {
        font-size: 1rem;
    }

    /* Keep dropdown menu on-screen */
    .header-user-settings {
        right: -10px;
        min-width: 180px;
    }

    /* 4. Fix Modals (Admin / Manage) */
    .admin-card {
        width: 95%; /* Take up almost full screen width */
        height: 90vh;
    }

    .admin-header h2 {
        font-size: 1.1rem;
    }

    /* Stack Admin Layout: Tabs on top, content on bottom */
    .admin-body {
        flex-direction: column !important;
    }

    .admin-tabs {
        width: 100%;
        flex-direction: row; /* Horizontal scrolling tabs */
        overflow-x: auto;
        padding: 10px;
    }

    .tab-btn {
        white-space: nowrap;
        padding: 8px 15px;
        flex-shrink: 0;
    }

    /* Ensure tables can scroll horizontally if data is too wide */
    .tab-content {
        padding: 10px;
        overflow-x: auto;
    }
}

/* This is the dark background */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7); /* Dim the background */
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

/* This is the ACTUAL box that should be white/solid */
.modal-content.small {
    background: white;
    color: #333;
    padding: 25px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Ensure inputs inside modals are visible */
.modal-content input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    margin-bottom: 10px;
}

/* Helper for the "Save" buttons in modals */
.primary-btn {
    background: #27ae60;
    color: white;
    border: none;
    padding: 10px;
    border-radius: 5px;
    cursor: pointer;
}

.admin-card {
    background: #1e1e1e;
    color: white;
    width: 80%;
    max-width: 900px;
    height: 80vh;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.admin-header {
    padding: 20px;
    background: #2c3e50;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-body { display: flex; flex: 1; overflow: hidden; }

.admin-tabs {
    width: 200px;
    background: #121212;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.tab-btn {
    background: none; border: none; color: #888;
    padding: 12px; text-align: left; cursor: pointer;
    border-radius: 5px; transition: 0.3s;
}

.tab-btn.active, .tab-btn:hover { background: #2c3e50; color: white; }

.tab-content { flex: 1; padding: 20px; display: none; overflow-y: auto; }
.tab-content.active { display: block; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: #bdc3c7; border-bottom: 1px solid #333; padding: 10px; }
td { padding: 10px; border-bottom: 1px solid #222; }

.btn-danger { background: #e74c3c; color: white; border: none; padding: 5px 10px; border-radius: 4px; cursor: pointer; }

.btn-success {
    background: #27ae60;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    margin-right: 5px;
}

.btn-warning {
    background: #f39c12; /* Orange for demote/caution */
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    margin-right: 5px;
}

.btn-success:hover { background: #219150; }
.btn-warning:hover { background: #d68910; }

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}
/* Fix: Clean up the header and avatar logic */
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center; /* Changed from flex-start to center */
    padding: 10px 20px;
    background: white;
    border-bottom: 1px solid #ddd;
    z-index: 10;
    flex-shrink: 0; /* Prevents the header from being squished */
}

.avatar {
    display: flex;
    align-items: center;
}

/* --- Dropdown Menu Styles --- */
.user-dropdown-container {
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.dropdown-hidden {
    display: none !important;
}

.header-user-settings {
    position: absolute;
    top: 50px; /* Pushes it just below the avatar */
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    min-width: 200px;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
}

.dropdown-header-info {
    padding: 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    text-align: center;
    color: #333;
}

.admin-tag {
    display: inline-block;
    background: #e74c3c;
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    margin-top: 5px;
    font-weight: bold;
}

.dropdown-item {
    padding: 12px 15px;
    text-decoration: none;
    color: #333;
    display: block;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.dropdown-item i {
    width: 20px;
    color: #888;
    margin-right: 8px;
    text-align: center;
}

.dropdown-item:hover {
    background: #f1f3f5;
}

.dropdown-divider {
    height: 1px;
    background: #eee;
    margin: 0;
}

.text-danger {
    color: #e74c3c !important;
}

.text-danger i {
    color: #e74c3c !important;
}

#my-header-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    object-fit: cover;
}

.unread-dot {
    display: none; /* Hidden by default */
    width: 8px;
    height: 8px;
    background-color: #ff4757; /* Bright red */
    border-radius: 50%;
    margin-left: auto; /* Pushes it to the right of the name */
}

li.has-unread .unread-dot {
    display: inline-block; /* Show when parent has class */
}

/* Make sidebar list items use flex so the dot stays on the right */
.sidebar li {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Lightbox Overlay */
#lightbox {
    display: none;
    position: fixed;
    z-index: 9999;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9);
    align-items: center;
    justify-content: center;
}
#lightbox img { max-width: 90%; max-height: 90%; box-shadow: 0 0 20px #000; }
#lightbox span {
    position: absolute; top: 20px; right: 30px;
    color: white; font-size: 40px; cursor: pointer;
}

/* Constrain all chat images and videos (Attachments & Inline Media) */
.chat-preview-img,
.chat-media, .chat-video {
    max-width: 200px;
    max-height: 200px;
    width: auto;
    height: auto;
    border-radius: 8px;
    cursor: zoom-in;
    margin-top: 5px;
    border: 1px solid #555;
    display: block;
    object-fit: contain; /* Ensures the aspect ratio stays perfect */
}

/* --- Full Width Input Bar --- */
.input-container {
    width: 100%;
    flex-shrink: 0;
    background: white;
}

.chat-input-container {
    display: flex;
    align-items: stretch;
    gap: 10px;
    width: 100%;
    padding: 15px 20px;
    background: white;
    border-top: 1px solid #ddd;
    box-sizing: border-box; 
    flex-shrink: 0; /* <-- ADD THIS LINE to prevent overlapping/squishing */
    /* z-index: 10; <-- You can also add this if something is still floating over it */
}

#message-input {
    flex-grow: 1;
    min-height: 44px; /* Set a standard baseline height */
    max-height: 120px; /* Prevent it from growing infinitely if they type a novel */
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    resize: none; /* Disable manual drag-resizing so it doesn't break flexbox */
    font-family: inherit;
    font-size: 1rem;
}

/* --- Attachment Preview Area --- */
#attachment-preview {
    padding: 10px 20px;
    background: #f9f9f9;
    border-top: 1px solid #ddd;
}

.preview-wrapper {
    position: relative;
    display: inline-block;
    margin-top: 10px;
}

#preview-image, #preview-video {
    max-height: 120px;
    max-width: 300px;
    border-radius: 8px;
    border: 2px solid #ccc;
    object-fit: contain;
}

.clear-preview {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.sidebar {
    width: 260px;
    background: #2c3e50;
    color: white;
    display: flex;
    flex-direction: column;
    height: 100vh;
    flex-shrink: 0; /* Keeps sidebar from getting squashed */
}

.sidebar-content {
    flex: 1;
    overflow-y: auto; /* Makes only the list scrollable */
    padding: 20px;
}

.user-profile-footer {
    padding: 15px;
    background: rgba(0,0,0,0.2);
    flex-shrink: 0;
}

#manage-modal {
    z-index: 5000 !important; /* Forces it over the Admin Modal */
}

/* Center the modal content and its header */
#manage-modal .modal-content {
    text-align: center;
    background: white;
    color: #333;
}

#manage-modal .modal-header {
    display: flex;
    flex-direction: column; /* Stack title and close button or keep side-by-side */
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 10px;
}

/* Fix the close button position if the title is centered */
#manage-modal .close-x {
    position: absolute;
    top: 15px;
    right: 15px;
    color: #888;
}

/* Ensure the scrollable list container stays neat */
.manage-list-container {
    max-height: 60vh;
    overflow-y: auto;
    width: 100%;
}

.manage-table tr:hover {
    background-color: #f1f1f1;
}

.manage-table td {
    font-size: 0.95rem;
    color: #333;
}

.select-all-bar {
    background-color: #f1f3f5;
    border-radius: 4px;
    margin: 10px;
}

#manage-modal .modal-content {
    border: none;
    box-shadow: 0 15px 50px rgba(0,0,0,0.3);
}/* Ensure the Manage Members table looks like the Admin one */
/* Ensure the Manage Members table looks like the Admin one */
#manage-user-list table {
    width: 100%;
    border-collapse: collapse;
}

#manage-user-list td {
    padding: 12px;
    border-bottom: 1px solid #222;
}

#manage-user-list th {
    background: #1a1a1a;
    position: sticky;
    top: 0;
    z-index: 1;
}

/* Style for the select all area in dark mode */
.select-all-bar:hover {
    background: #1a1a1a !important;
}

.ac-factset span,
.ac-factset div,
.ac-textBlock span {
    text-decoration: none !important;
    border-bottom: none !important;
}

/* Target the Adaptive Card FactSet table specifically */
.ac-factset,
.ac-factset tr,
.ac-factset td {
    border: none !important;
    border-bottom: none !important;
    box-shadow: none !important;
}

/* Ensure the text blocks inside the cards don't have strange spacing */
.ac-factset .ac-textBlock p {
    margin-bottom: 0 !important;
}


/* Invitation Form Styling */
.invite-section {
    display: none;
    background: #252525; /* Matches admin modal depths */
    border: 1px solid #444;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 25px;
    text-align: left;
    color: #efefef;
}

.invite-section h4 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #fff;
    border-bottom: 1px solid #444;
    padding-bottom: 10px;
}

.invite-field-group {
    margin-bottom: 15px;
}

.invite-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #bbb;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.invite-input {
    width: 100%;
    background: #1a1a1a;
    border: 1px solid #444;
    color: white;
    padding: 10px;
    border-radius: 4px;
    outline: none;
}

.invite-input:focus {
    border-color: #3498db;
}

/* The scrollable channel list */
.invite-channels-container {
    max-height: 150px;
    overflow-y: auto;
    background: #1a1a1a;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 10px;
}

.invite-ch-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    cursor: pointer;
    border-radius: 3px;
    transition: background 0.2s;
}

.invite-ch-item:hover {
    background: #333;
}

.invite-ch-item input[type="checkbox"] {
    cursor: pointer;
}

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

/* Masked Links styling */
.message-text a {
    color: #0000EE;
    text-decoration: none;
    font-weight: bold;
}
.dark-theme .message-text a {
    color: yellow;
    text-decoration: none;
    font-weight: bold;
}
.message-text a:hover { text-decoration: underline; }

/* URL Preview Card */
.link-preview-card {
    display: flex;
    flex-direction: column;
    background: #1e1e1e;
    border-left: 3px solid #3498db;
    margin-top: 10px;
    border-radius: 4px;
    overflow: hidden;
    max-width: 400px;
    text-decoration: none !important;
}

.preview-image {
    width: 100%;
    max-height: 400px;
    object-fit: cover;
    background: #252525;
}

.preview-content {
    padding: 12px;
}

.preview-title {
    font-weight: bold;
    color: #fff;
    font-size: 0.95rem;
    margin-bottom: 5px;
    display: block;
}

.preview-desc {
    color: #bbb;
    font-size: 0.85rem;
    line-height: 1.3;
}


/* Remove default Markdown paragraph margins to fix chat bubble spacing */
.message-text p {
    margin-bottom: 0 !important;
    margin-top: 0 !important;
}

/* Add a tiny bit of space if someone types multiple paragraphs in one message */
.message-text p + p {
    margin-top: 8px !important;
}

/* Ensure empty preview containers don't take up space */
.url-preview-container:empty {
    display: none !important;
    margin: 0 !important;
}
/* Override old pre-wrap rules since Markdown now handles line breaks */
.message-body,
.message .content,
.message-text {
    white-space: normal !important;
}
/* Add this to the very bottom of style.css */
@media (max-width: 768px) {
    .url-preview-container img,
    .url-preview-container video {
        height: 250px !important; /* Shorter uniform height for narrow screens */
    }
}
/* Base styles for the action buttons in the input row */
.chat-action-btn, #send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: auto; /* Let 'align-items: stretch' control the height */
    min-width: 44px;
    padding: 0 15px; /* Give text buttons some width, icon buttons can just be 0 10px */
    border: none;
    border-radius: 4px;
    cursor: pointer;
    background: #3498db;
    color: white;
    transition: background 0.2s;
}

.chat-action-btn:hover, #send-btn:hover {
    background: #2980b9;
}

/* Specific tweak for the square icon button so it doesn't get too wide */
#add-link-btn {
    padding: 0 12px;
    background: #ecf0f1; /* Subtle grey for secondary actions */
    color: #2c3e50;
}

#add-link-btn:hover {
    background: #bdc3c7;
}


.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    cursor: pointer;
    background: rgba(0,0,0,0.05); /* Subtle background */
    user-select: none;
}

.section-header h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0;
}

.toggle-icon {
    transition: transform 0.3s ease;
    font-size: 0.8rem;
}

/* When hidden */
.collapsed + ul {
    display: none;
}

.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

/* Sidebar Header Layout */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 10px;
    background: rgba(0,0,0,0.2);
    cursor: pointer;
    user-select: none;
}

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

.header-actions {
    display: flex;
    gap: 5px;
}

.header-actions button {
    background: transparent;
    border: none;
    color: #95a5a6;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 5px;
    transition: color 0.2s;
}

.header-actions button:hover {
    color: white;
}

/* The Toggle Logic */
.toggle-icon {
    font-size: 0.7rem;
    transition: transform 0.2s;
}

/* This targets the <ul> immediately following a header with the 'collapsed' class */
.section-header.collapsed + ul {
    display: none !important;
}

.section-header.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.sidebar-controls {
    display: flex;
    padding: 10px;
    gap: 5px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.sort-btn {
    flex: 1;
    background: #34495e;
    color: white;
    border: none;
    padding: 5px;
    font-size: 0.75rem;
    border-radius: 3px;
    cursor: pointer;
}
.active-sort {
    background-color: #2980b9 !important; /* Darker blue than your standard buttons */
    color: white !important;
    font-weight: bold;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2); /* Gives it a "pressed" look */
}
/* The highlighted channel/DM in the sidebar */
.sidebar li.active {
    background-color: rgba(255, 255, 255, 0.2);
    border-left: 4px solid #fff;
    font-weight: bold;
}

/* The active Sort Button */
.active-sort {
    background-color: #2980b9 !important; /* Darker blue */
    color: white !important;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
    border: 1px solid #fff !important;
}

/* Visual cue when a file is hovered over the window */
.app-container.drag-active {
    outline: 5px dashed #3498db;
    outline-offset: -10px;
    background-color: rgba(52, 152, 219, 0.1);
    transition: all 0.2s ease;
}

/* Optional: Overlay text to tell them to drop */
.app-container.drag-active::after {
    content: "Drop file to attach";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    font-weight: bold;
    color: #3498db;
    pointer-events: none;
    z-index: 9999;
}
/* Hides the raw URL text for media files since the preview handles them */
.hidden-media-link {
    display: none !important;
}

/* The container holding the bubbles */
.reaction-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 5px;
}

/* The individual bubble */
.reaction-bubble {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 2px 6px;
    font-size: 0.85em;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    color: inherit;
    transition: all 0.2s ease;
}

.reaction-bubble:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Highlight if the logged-in user clicked this emoji */
.reaction-bubble.reacted-by-me {
    background: rgba(52, 152, 219, 0.2); /* A nice light blue */
    border-color: #3498db;
}


#input-emoji-picker {
    display: flex;
    justify-content: flex-start;
    gap: 8px;
    padding: 10px;
}

/* Emoji Autocomplete Popup */
#emoji-autocomplete-popup {
    position: absolute;
    bottom: 100%; /* Floats it right above the input */
    left: 0;
    width: 300px;
    max-height: 200px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid rgba(128, 128, 128, 0.2);
    border-radius: 8px;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.1);
    display: none; /* Hidden by default */
    z-index: 1000;
    margin-bottom: 10px;
}

/* Dark mode support - it will inherit your app's theme if you have one */
.theme-dark #emoji-autocomplete-popup {
    background: #2c2f33;
    border-color: #1e1f22;
}

.autocomplete-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.1s;
    font-weight: bold;
}

.autocomplete-item:hover {
    background: rgba(52, 152, 219, 0.1);
}

.autocomplete-item img {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

/* ==========================================
   DARK THEME OVERRIDES
   ========================================== */

/* 1. Main Backgrounds */
body.dark-theme,
body.dark-theme .app-container,
body.dark-theme .chat-area {
    background-color: #1a1c1e !important;
    color: #e1e2e1 !important;
}

/* 2. Message Container & Input Area */
body.dark-theme .messages-container {
    background-color: #1a1c1e !important;
}

body.dark-theme .message-input-area {
    background-color: #2d2f31 !important;
    border-top: 1px solid #3f4143;
}

body.dark-theme #message-input {
    background-color: #1a1c1e !important;
    color: #fff !important;
    border-color: #3f4143;
}

/* 3. Message Bubbles */
/* ==========================================
   BULLETPROOF DARK MODE MESSAGES
   ========================================== */

/* 1. The Main Bubble Container */
body.dark-theme .message.received {
    background-color: #2d2f31 !important;
    border-color: #3f4143 !important;
    color: #e1e2e1 !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.3) !important;
}

body.dark-theme .message.sent {
    background-color: #004a77 !important;
    color: #ffffff !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.3) !important;
}

/* 2. Target the Markdown-generated tags inside the bubbles */
/* Markdown-it wraps everything in <p>. We must ensure they don't have their own backgrounds */
body.dark-theme .message.received .message-text,
body.dark-theme .message.received .message-text p,
body.dark-theme .message.sent .message-text,
body.dark-theme .message.sent .message-text p {
    background: transparent !important;
    color: inherit !important;
}

/* 3. Fix Markdown spacing (Markdown <p> tags add big gaps by default) */
.message-text p {
    margin: 0;
    padding: 0;
}
.message-text p:not(:last-child) {
    margin-bottom: 8px; /* Adds space between paragraphs if there are multiple */
}

/* 4. Secondary Text (Timestamps and Usernames) */
body.dark-theme .message-username {
    color: #3498db !important; /* Keep usernames blue or a highlight color */
    filter: brightness(1.2);    /* Make it pop slightly more on dark */
}

body.dark-theme .message-timestamp {
    color: #888 !important;
}

/* 5. Reactions in Dark Mode */
body.dark-theme .reaction-bubble {
    background: rgba(255, 255, 255, 0.05) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    color: #ccc !important;
}

body.dark-theme .reaction-bubble:hover {
    background: rgba(255, 255, 255, 0.1) !important;
}

/* 4. Modals & Popups */
body.dark-theme .modal-content,
body.dark-theme .admin-modal-content,
body.dark-theme #emoji-autocomplete-popup {
    background-color: #2d2f31 !important;
    color: #fff !important;
    border: 1px solid #3f4143;
}

/* 5. Sidebar Adjustments */
body.dark-theme .sidebar {
    background-color: #111315 !important;
    border-right: 1px solid #3f4143;
}

body.dark-theme .channel-item:hover,
body.dark-theme .dm-item:hover,
body.dark-theme .active-channel {
    background-color: rgba(255, 255, 255, 0.05) !important;
}

/* 6. Text Contrast */
body.dark-theme .message-username,
body.dark-theme .channel-name-header {
    color: #fff !important;
}

body.dark-theme .message-timestamp {
    color: #909ea1 !important;
}


/* 1. Target the main chat area and message container */
body.dark-theme .chat-area,
body.dark-theme .chat-input-container {
    background-color: #1a1c1e !important;
    color: #e1e2e1 !important;
}

/* 2. Target the Chat Header */
body.dark-theme .chat-header {
    background-color: #2d2f31 !important;
    color: #fff !important;
    border-bottom: 1px solid #3f4143;
}

/* 3. Sidebar text visibility (if it's not already correct) */
body.dark-theme .sidebar {
    background-color: #121212 !important;
}
/* 1. Make the Edit Pen stand out (Light & Dark) */
.edit-btn i {
    color: #orange; /* A bright, standing-out blue */
    transition: color 0.2s;
}

.edit-btn:hover i {
    color: #2980b9;
}

/* 2. Fix Pin and Reaction text in Dark Mode */
body.dark-theme .message-meta button {
    color: #e1e2e1 !important; /* Lighter text for dark backgrounds */
    opacity: 0.8 !important;   /* Increase opacity so it's readable */
}

/* 3. Give the Reaction button a slight hover effect in Dark Mode */
body.dark-theme .add-reaction-btn:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
    opacity: 1 !important;
}

/* 1. Make sure your toggle button is always visible */
#mobile-menu-btn,
.menu-toggle-btn { /* Replace with your actual button ID/Class */
    display: inline-block !important;
    cursor: pointer;
}

/* 2. Add a hidden state for the sidebar */
.sidebar {
    transition: all 0.3s ease; /* Smooth sliding effect */
    /* Ensure it has a fixed width here, e.g., width: 260px; */
}

/* When this class is applied, the sidebar disappears and the chat area expands */
.sidebar.hidden-all {
    margin-left: -260px; /* Match this to your sidebar's exact width */
    opacity: 0;
    pointer-events: none;
}

/* Ensure the chat area takes up the remaining space smoothly */
.chat-area {
    transition: width 0.3s ease, margin 0.3s ease;
    flex-grow: 1;
}

/* 1. Ensure the toggle button is visible on Desktop too */
#mobile-menu-btn {
    display: inline-block !important; /* Forces it to show on large screens */
    cursor: pointer;
}

/* =========================================
   DESKTOP SIDEBAR RULES (> 768px)
   ========================================= */
@media (min-width: 769px) {
    .sidebar {
        margin-left: 0;
        transition: margin-left 0.3s ease-in-out;
    }

    /* On Desktop, adding '.active' HIDES the sidebar */
    .sidebar.active {
        margin-left: -260px; /* Matches your sidebar width */
    }
}


.custom-emoji {
    max-height: 24px;
    vertical-align: middle;
    display: inline-block;
}

/* If you have a specific class for "Jumbo" emojis (when sent all by themselves) */
.jumbo-emoji,
.message-content > .custom-emoji:only-child {
    max-height: 48px; /* Or 64px, whatever looks good to you */
    margin: 5px 0;
}
/* ==========================================
   Modal Dark Mode Styles
   ========================================== */

/* 1. The Main Modal Container */
body.dark-theme .modal-overlay,
body.dark-theme #user-dropdown-menu, /* Swap with your exact modal ID if needed */
body.dark-theme .admin-modal {
    background-color: #2d2f31 !important; /* Matches your dark chat header */
    color: #e1e2e1 !important;
    border: 1px solid #3f4143;
}

/* 2. Text and Headers inside the Modal */
body.dark-theme .modal-content h2,
body.dark-theme .modal-content h3,
body.dark-theme .modal-content label {
    color: #ffffff !important;
}

/* 3. Inputs, Textareas, and Dropdowns */
body.dark-theme .modal-content input[type="text"],
body.dark-theme .modal-content input[type="password"],
body.dark-theme .modal-content input[type="file"],
body.dark-theme .modal-content select {
    background-color: #1a1c1e !important; /* Matches dark chat area */
    color: #e1e2e1 !important;
    border: 1px solid #444 !important;
}

/* 4. The Privacy Toggle Row (and similar setting rows) */
body.dark-theme .setting-row {
    background: rgba(255, 255, 255, 0.05) !important; /* Swaps black shadow for a subtle white highlight */
    border: 1px solid #444 !important;
}

/* 5. Tables inside the Modal (like your Admin Emoji Table) */
body.dark-theme .modal-content table th {
    background-color: #1a1c1e !important;
    color: #fff !important;
    border-bottom: 1px solid #444 !important;
}

body.dark-theme .modal-content table td {
    border-bottom: 1px solid #3f4143 !important;
    color: #e1e2e1 !important;
}
/* ==========================================
   Sidebar DM Avatars
   ========================================== */
.sidebar-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 8px;
    flex-shrink: 0;
}

/* Ensure the DM container aligns the image and text horizontally */
.dm-item {
    display: flex;
    align-items: center;
}

/* ==========================================
   SUPPORT MODAL DARK MODE OVERRIDES
   ========================================== */

/* 1. Main Modal Background */
body.dark-theme #support-modal .modal-content {
    background-color: #2d2f31 !important;
    border: 1px solid #3f4143 !important;
}

/* 2. Header and Footer areas (Overriding the light grey #f8f9fa) */
body.dark-theme #support-modal .modal-content > div:first-child,
body.dark-theme #support-modal .modal-content > div:last-child {
    background-color: #1a1c1e !important;
    border-color: #444 !important;
}

/* 3. Headings and Labels */
body.dark-theme #support-modal h2,
body.dark-theme #support-modal label,
body.dark-theme #support-modal .modal-content > div:first-child button {
    color: #e1e2e1 !important;
}

/* 4. Form Inputs (Text, Email, Select, Textarea) */
body.dark-theme #support-modal input[type="text"],
body.dark-theme #support-modal input[type="email"],
body.dark-theme #support-modal select,
body.dark-theme #support-modal textarea {
    background-color: #1a1c1e !important;
    color: #ffffff !important;
    border: 1px solid #555 !important;
}

/* Optional: Darken the Cancel button so it isn't bright grey */
body.dark-theme #support-modal button[onclick*="display='none'"]:not([style*="none"]) {
    background-color: #444 !important;
    color: #e1e2e1 !important;
}

/* ==========================================
   CUSTOM BACKGROUND & FROSTED GLASS BUBBLES
   ========================================== */

/* 1. The Custom Chat Background */
.chat-area {
    /* Set the background on the absolute bottom layer 
    background-image: url('light-mode.png');
    background-size: 100% 100%;
    background-position: center;
    background-attachment: fixed;
	*/
}

/* 2. Light Theme - Transparent Sent Bubbles */
.message.sent {
    background-color: rgba(227, 242, 253, 0.2) !important; /* 75% opaque so text remains readable */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.6) !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

/* 3. Light Theme - Transparent Received Bubbles */
.message.received {
    background-color: rgba(255, 255, 255, 0.2) !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.6) !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

/* ==========================================
   DARK MODE OVERRIDES FOR GLASS BUBBLES
   ========================================== */
body.dark-theme #chat-box {
    background-image: url('dark-mode.png');
}

body.dark-theme .message.sent {
    background-color: rgba(41, 128, 185, 0.2) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

body.dark-theme .message.received {
    background-color: rgba(30, 32, 34, 0.2) !important;
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
}
/* ==========================================
   MOBILE MESSAGE BUBBLE EXPANSION
   ========================================== */
@media (max-width: 767px) {
    /* Allow message bubbles to take up almost the entire screen */
    .message {
        max-width: 100% !important;
    }

    /* Optional: Slightly reduce the empty padding on the left/right
       of the mobile screen to give the Adaptive Cards maximum room */
    .chat-messages {
        padding: 10px !important;
        overflow-x: hidden; /* Prevent horizontal scrolling */
    }

    /* --- MOBILE CHANNEL ACTIONS DROPDOWN --- */
      #mobile-actions-toggle {
          display: flex !important;
          background: transparent;
          border: none;
          color: var(--text-muted);
          font-size: 1.2rem;
          cursor: pointer;
          padding: 5px;
      }

      .channel-actions-content {
          display: none; /* Hidden strictly by default */
          position: absolute;
          top: 40px;
          right: 0;
          background: var(--input-bg);
          border: 1px solid var(--border-color);
          border-radius: 8px;
          box-shadow: 0 8px 20px rgba(0,0,0,0.4);
          flex-direction: column;
          min-width: 180px;
          z-index: 1000;
          padding: 5px 0;
          gap: 0;
      }

      /* This class is activated by the onclick Javascript! */
      .channel-actions-content.show-menu {
          display: flex !important;
      }

      .channel-actions-content .action-item {
          width: 100%;
          padding: 12px 20px;
          justify-content: flex-start;
          font-size: 1rem;
          color: var(--text-color) !important;
      }

      .channel-actions-content .action-item i {
          width: 20px;
          text-align: center;
          margin-right: 12px;
      }

      .channel-actions-content .action-item:hover {
          background: var(--hover-bg);
      }

      .action-label {
          display: inline; /* Show text in the mobile menu */
      }

}
/* ==========================================
   SENDER NAME COLORS
   ========================================== */

/* 1. Light Theme - Other Person's Name (Received) */
.message.received .message-meta strong {
    color: #2c3e50 !important; /* A strong, dark slate blue */
    font-weight: 700;
}

/* 2. Light Theme - Your Name (Sent) */
.message.sent .message-meta strong {
    color: #0d47a1 !important; /* A deep navy blue */
    font-weight: 700;
}

/* ==========================================
   DARK MODE OVERRIDES FOR NAMES
   ========================================== */

/* 3. Dark Theme - Other Person's Name (Received) */
body.dark-theme .message.received .message-meta strong {
    color: #64b5f6 !important; /* A bright, crisp pastel blue */
}

/* 4. Dark Theme - Your Name (Sent) */
body.dark-theme .message.sent .message-meta strong {
    color: #90caf9 !important; /* A slightly softer light blue */
}

/* ==========================================
   SNIPPET AUTOCOMPLETE MENU
   ========================================== */
#snippet-suggestions {
    position: absolute;
    bottom: 100%; /* Pushes it right above the input box */
    left: 10px;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.1);
    max-height: 200px;
    overflow-y: auto;
    width: 300px;
    max-width: 90vw;
    z-index: 1000;
    display: none; /* Hidden until triggered */
    flex-direction: column;
    padding: 5px;
    margin-bottom: 10px; /* Space between menu and text box */
}

.snippet-option {
    padding: 10px 12px;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: background 0.1s;
}

/* Hover and Keyboard Active States */
.snippet-option:hover,
.snippet-option.active {
    background-color: #e3f2fd;
}

.snippet-option strong {
    font-size: 14px;
    color: #0d47a1;
}

.snippet-option span {
    font-size: 12px;
    color: #555;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* Adds '...' if text is too long */
}

/* Dark Mode Overrides */
body.dark-theme #snippet-suggestions {
    background: #1e2124;
    border-color: #333;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.4);
}
body.dark-theme .snippet-option:hover,
body.dark-theme .snippet-option.active {
    background-color: #2c3e50;
}
body.dark-theme .snippet-option strong {
    color: #90caf9;
}
body.dark-theme .snippet-option span {
    color: #aaa;
}

/* ==========================================
   CHANNEL ACTIONS DROPDOWN
   ========================================== */
.channel-actions-dropdown {
    position: relative;
    display: inline-block;
}

/* ==========================================
   CHANNEL ACTIONS (DESKTOP)
   ========================================== */
#mobile-actions-toggle {
    display: none; /* Hide kebab on desktop */
}

.channel-actions-content {
    display: flex;
    align-items: center;
    gap: 15px; /* Spaces the icons cleanly */
}

/* Restore the exact original look for the buttons */
.channel-actions-content .action-item {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
}

.channel-actions-content .action-item:hover { color: var(--primary-color); }
.channel-actions-content .danger-btn:hover { color: var(--danger-color) !important; }
.action-label { display: none; /* Hide text on desktop */ }


    .header-right {
        display: flex;
        flex-direction: row;
        align-items: center;
        height: 100%;
        flex-shrink: 0; /* PREVENTS SCRUNCHING */
        white-space: nowrap; /* Forces everything to stay on one line */
    }

    .header-controls {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 15px;
        flex-shrink: 0;
    }

    /* ==========================================
   MOBILE OPTIMIZATIONS (ALL CONSOLIDATED)
   ========================================== */
@media (max-width: 768px) {

    /* ... your other mobile sidebar code is up here ... */

    /* --- MOBILE CHANNEL ACTIONS DROPDOWN --- */
    #mobile-actions-toggle {
        display: flex !important; /* This only runs on small screens now! */
        background: transparent;
        border: none;
        color: var(--text-muted);
        font-size: 1.2rem;
        cursor: pointer;
        padding: 5px;
    }

    .channel-actions-content {
        display: none !important; /* FORCED HIDDEN ON MOBILE BY DEFAULT */
        position: absolute;
        top: 40px;
        right: 0;
        background: var(--input-bg);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        box-shadow: 0 8px 20px rgba(0,0,0,0.4);
        flex-direction: column;
        min-width: 180px;
        z-index: 1000;
        padding: 5px 0;
        gap: 0;
    }

    /* This class is activated by the JS onclick to open it */
    .channel-actions-content.show-menu {
        display: flex !important;
    }

    .channel-actions-content .action-item {
        width: 100%;
        padding: 12px 20px;
        justify-content: flex-start;
        font-size: 1rem;
        color: var(--text-color) !important;
    }

    .channel-actions-content .action-item i {
        width: 20px;
        text-align: center;
        margin-right: 12px;
    }

    .channel-actions-content .action-item:hover {
        background: var(--hover-bg);
    }

    .action-label {
        display: inline;
    }
}

/* ==========================================
   ADMIN UNLOCK BUTTON
   ========================================== */
.unlock-btn {
    background: transparent;
    color: #2ecc71; /* A nice secure green */
    border: 1px solid #2ecc71;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.unlock-btn:hover {
    background: #2ecc71;
    color: white;
    box-shadow: 0 4px 10px rgba(46, 204, 113, 0.2);
    transform: translateY(-1px);
}

/* Make sure it adapts slightly in dark mode if needed */
.dark-theme .unlock-btn {
    border-color: #27ae60;
    color: #27ae60;
}

.dark-theme .unlock-btn:hover {
    background: #27ae60;
    color: white;
}

/* ==========================================
   ADMIN MANAGE CHANNELS BUTTON
   ========================================== */
.manage-channels-btn {
    background: transparent;
    color: #3498db; /* A nice distinct blue */
    border: 1px solid #3498db;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.manage-channels-btn:hover {
    background: #3498db;
    color: white;
    box-shadow: 0 4px 10px rgba(52, 152, 219, 0.2);
    transform: translateY(-1px);
}

/* Adapt for dark mode */
.dark-theme .manage-channels-btn {
    border-color: #2980b9;
    color: #2980b9;
}

.dark-theme .manage-channels-btn:hover {
    background: #2980b9;
    color: white;
}

/* Ensure the admin modal has its baseline z-index*/
#admin-modal-class-or-id {
    position: fixed;
    z-index: 1000;
}

/* Set the new modal to be higher so it layers on top */
#manage-channels-modal {
    position: fixed; /* z-index only works on positioned elements! */
    z-index: 1050;
}

#mention-popup {
    position: absolute;
    bottom: 100%; /* Floats it right above the input */
    left: 0;
    width: 300px;
    max-height: 200px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid rgba(128, 128, 128, 0.2);
    border-radius: 8px;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.1);
    display: none; /* Hidden by default */
    z-index: 1000;
    margin-bottom: 10px;
}

/* Dark mode support - it will inherit your app's theme if you have one */
.theme-dark #mention-popup {
    background: #2c2f33;
    border-color: #1e1f22;
}
/* ==========================================
   MENTION POPUP STYLES (Light & Dark Mode)
   ========================================== */

/* Light Mode (Default) List Items */
#mention-list li {
    padding: 8px 15px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    color: #2c3e50;
    transition: background 0.1s ease;
}

#mention-list li:hover {
    background-color: #f0f8ff; /* Light blue hover */
}

/* --- Dark Mode Overrides --- */
.dark-theme #mention-popup {
    background-color: #2c3e50 !important; /* Match dark chat background */
    border-color: #1a252f !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5) !important;
}

.dark-theme #mention-list li {
    border-bottom-color: #34495e;
    color: #ecf0f1;
}

.dark-theme #mention-list li:hover {
    background-color: #34495e; /* Darker highlight on hover */
}
/* ==========================================
   EMOJI PICKER STYLES (Light & Dark Mode)
   ========================================== */

/* The Main Container */
.emoji-popup {
    position: absolute;
    width: 280px;
    max-height: 320px;
    overflow-y: auto;
    background: #ffffff;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    z-index: 1000;
    padding: 5px;
    display: flex;
    flex-direction: column; /* THE FIX: Forces the accordions to stack vertically! */
    max-width: 90vw; /* Never let it be wider than the phone screen */
    max-height: 250px; /* Set a strict maximum height */
    overflow-y: auto; /* Add a vertical scrollbar if emojis exceed 250px */
    overflow-x: hidden; /* Prevent sideways scrolling */
    z-index: 9999; /* Ensure it floats above the keyboard and header */
}

/* Optional: Make the scrollbar look elegant inside the popup */
.emoji-popup::-webkit-scrollbar {
    width: 6px;
}
.emoji-popup::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

/* The Accordion Sections */
.emoji-accordion {
    margin-bottom: 5px;
}

.emoji-accordion summary {
    padding: 8px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.9rem;
    background: #f4f7f6;
    border-radius: 4px;
    user-select: none;
    transition: background 0.2s ease;
}

.emoji-accordion summary:hover {
    background: #e9ecef;
}

/* The Grid inside the Accordion */
.emoji-grid {
    display: flex;
    flex-wrap: wrap;
    padding: 5px 0;
    gap: 4px;
}

/* The Individual Emoji Buttons */
.emoji-btn {
    cursor: pointer;
    padding: 4px;
    font-size: 1.4rem;
    border-radius: 4px;
    transition: background 0.1s, transform 0.1s;
}

.emoji-btn:hover {
    background: #eee;
    transform: scale(1.1); /* Adds a nice little pop when you hover */
}

/* --- DARK MODE OVERRIDES --- */
body.dark-theme .emoji-popup {
    background: #2c2f33;
    border-color: #1e1f22;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}

body.dark-theme .emoji-accordion summary {
    background: #23272a;
    color: #ffffff;
}

body.dark-theme .emoji-accordion summary:hover {
    background: #1e1f22;
}

body.dark-theme .emoji-btn:hover {
    background: #3a3f44;
}

/* ==========================================
   JUMBO EMOJIS (V3)
   ========================================== */
/* Delete the chat bubble background so they float! */
.jumbo-bubble {
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
}

.jumbo-bubble .message-text {
    font-size: 80px !important;
    line-height: 1.1 !important; /* Prevents vertical slicing */
    text-align: left !important;
    display: inline-block;
}

.jumbo-bubble .message-text p {
    margin: 0 !important;
    padding: 0 !important;
}

/* Target ANY image inside a jumbo message */
.jumbo-bubble img,
.jumbo-bubble .custom-emoji {
    width: auto !important;
    height: 80px !important;
    min-height: 80px !important; /* Overrides any base min-heights */
    object-fit: contain;
    vertical-align: middle;
    margin-right: 8px; /* Spacing if someone sends 3 custom emojis in a row */
}

/* ==========================================
   PLAIN BACKGROUND OVERRIDES
   ========================================== */
/* Light Mode - Plain Background */
body.no-bg-image #chat-box {
    background-image: none !important;
    background-color: #f4f7f6 !important; /* A soft, theme-matching light gray */
}

/* Dark Mode - Plain Background */
body.dark-theme.no-bg-image #chat-box {
    background-image: none !important;
    background-color: #1e1f22 !important; /* A deep, theme-matching dark slate */
}
/* ==========================================
   THREAD PANEL & REPLY STYLES
   ========================================== */
.thread-panel {
    position: fixed;
    top: 0;
    right: -400px; /* Hidden off-screen initially */
    width: 400px;
    max-width: 100vw; /* Responsive for mobile */
    height: 100dvh;
    background: #ffffff;
    box-shadow: -4px 0 15px rgba(0,0,0,0.1);
    transition: right 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    z-index: 9999;
    display: flex;
    flex-direction: column;
}

body.dark-theme .thread-panel { background: #2b2d31; }

.thread-panel.open { right: 0; }
.thread-panel.open {
    transform: translateX(0);
    box-shadow: -4px 0 15px rgba(0,0,0,0.05);
}

/* --- ADD THIS NEW BLOCK --- */
/* If the thread panel is open, shrink the chat window to make room! */
body:has(.thread-panel.open) .chat-area {
    margin-right: 350px;
}

.thread-header { padding: 15px; border-bottom: 1px solid #ddd; display: flex; justify-content: space-between; align-items: center; }
body.dark-theme .thread-header { border-bottom-color: #1e1f22; }

.thread-messages { flex-grow: 1; overflow-y: auto; padding: 15px; display: flex; flex-direction: column; gap: 10px; }

.thread-input-area { padding: 15px; border-top: 1px solid #ddd; display: flex; gap: 10px; background: #f9f9f9; }
body.dark-theme .thread-input-area { background: #232428; border-top-color: #1e1f22; }

/* In-Chat Reply Indicator */
.reply-indicator {
    font-size: 0.85em;
    color: #888;
    margin-bottom: 5px;
    padding-left: 8px;
    border-left: 3px solid #ccc;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}
.reply-indicator:hover { color: #555; }

/* Reply Button on Hover */
.reply-btn {
    background: none; border: none; color: #888; cursor: pointer; padding: 5px;
}
.reply-btn:hover { color: var(--primary-color); }

/* ==========================================
   MESSAGE TEXT FORMATTING
   ========================================== */
.message-text {
    white-space: pre-wrap !important; /* Forces the browser to render \n as real line breaks */
    word-wrap: break-word !important; /* Prevents long URLs from breaking out of the bubble */
}

/* Ensure paragraph tags generated by the Markdown parser don't add huge double-spaces */
.message-text p {
    margin: 0 0 5px 0;
}
.message-text p:last-child {
    margin: 0;
}

/* ==========================================
   SMART KEBAB DROPDOWN (CONTAINER QUERIES)
   ========================================== */
/* 1. Tell the message bubble to monitor its own physical width */
.message {
    container-type: inline-size;
}

/* 2. Base styles for the normal wide layout */
.message-actions-container {
    position: relative;
    margin-left: auto;
    display: flex;
    align-items: center;
}
.kebab-toggle {
    display: none; /* Hidden by default on wide screens */
    background: none; border: none; cursor: pointer;
    font-size: 1.2em; color: inherit; opacity: 0.6; padding: 4px 8px;
}
.kebab-toggle:hover { opacity: 1; }

.message-actions {
    display: flex; align-items: center; gap: 6px;
}
.generic-action-btn { font-size: 0.85em; cursor: pointer; background: none; border: none; opacity: 0.6; transition: 0.2s; color: inherit; }
.generic-action-btn:hover { opacity: 1; }
.jump-btn { font-size: 0.8em; margin-right: 6px; cursor: pointer; background: var(--primary-color, #3498db); color: white; border: none; padding: 4px 8px; border-radius: 4px; }


/* 3. The magic! When the bubble shrinks below 400px... */
@container (max-width: 400px) {
    .kebab-toggle {
        display: block; /* Show the 3 dots */
    }

    .message-actions {
        display: none;
        position: absolute;
        top: -5px; /* Float slightly above the bottom edge */
        right: 30px; /* Anchor it to the left of the kebab so it NEVER runs off screen! */
        background: #fff;
        border: 1px solid #ddd;
        border-radius: 30px; /* Nice horizontal pill shape */
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        flex-direction: row; /* Horizontal Row! */
        padding: 4px 8px;
        z-index: 100;
        width: max-content; /* Don't wrap the buttons */
        max-width: calc(100vw - 60px); /* Absolute safety boundary for tiny phones */
        overflow-x: auto; /* Allow side-scrolling if they have a ton of buttons */
        gap: 2px;
    }

    body.dark-theme .message-actions {
        background: #2b2d31;
        border-color: #1e1f22;
    }

    /* The JS toggle class */
    .message-actions.show-menu {
        display: flex !important;
    }

    /* Re-style buttons to fit nicely in the horizontal pill */
    .message-actions button,
    .message-actions .jump-btn,
    .message-actions .edit-btn,
    .message-actions .delete-btn,
    .message-actions .reply-btn,
    .message-actions .generic-action-btn {
        text-align: center;
        width: auto;
        padding: 6px 10px;
        border-radius: 20px;
        background: transparent !important;
        color: inherit !important;
        opacity: 1 !important;
        border: none !important;
        margin: 0 !important;
        white-space: nowrap; /* Force text to stay on one line */
    }

    .message-actions button:hover {
        background: #f0f0f0 !important;
    }
    body.dark-theme .message-actions button:hover {
        background: #3a3c41 !important;
    }
}
