
* { box-sizing: border-box; font-family: system-ui, Arial, sans-serif; }
body { margin: 0; background: #f5f6f8; }

/* Topbar */
#topbar { height: 48px; background: #1f2937; color: #fff; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; font-weight: 500; z-index: 10;font-family: Verdana, sans-serif;}
#me { opacity: 0.85; font-size: 14px; }

/* Contacts Pane */
#contactsPane { position: fixed; top: 48px; right: 0; width: 280px; height: calc(100vh - 48px); background: #fff; border-left: 1px solid #e5e7eb; box-shadow: -4px 0 16px rgba(0,0,0,0.05); transition: transform 0.2s ease-in-out; display: flex; flex-direction: column; z-index: 20; }
#contactsPane.open { transform: translateX(0); }
#contactsHeader, #groupsHeader { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-bottom: 1px solid #eee; font-weight: 600; gap: 6px;font-family: Verdana, sans-serif;font-size: 14px;}
#contactsHeader input { flex: 1; padding: 6px 8px; border: 1px solid #e5e7eb; border-radius: 6px; font-size: 13px; }
#togglePane, #newGroup { border: 0; background: #f0f2f5; width: 28px; height: 28px; border-radius: 6px; cursor: pointer; }

/* Contacts & Groups List */
#contacts, #groups { overflow: auto; flex: 1; }
.item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; cursor: pointer; border-bottom: 1px solid #f3f4f6; }
.item:hover { background: #f9fafb; }
.avatar { width: 28px; height: 28px; border-radius: 50%; }
.name { flex: 1; }
.presence { width: 8px; height: 8px; border-radius: 50%; }
.presence.online { background: #10b981; }
.presence.offline { background: #94a3b8; }

/* Dock & Chat Boxes */
#dock{position: fixed;bottom: 8px; left: 8px;right: 300px;display: flex;gap: 8px;flex-wrap: wrap;z-index: 5;max-height: 535px;overflow-y: auto;align-items: flex-end;}
#dock::-webkit-scrollbar-track{border-radius: 10px;background-color: transparent;}
#dock::-webkit-scrollbar{width: 8px;background-color: transparent;}
#dock::-webkit-scrollbar-thumb{border-radius: 10px;;background-color: #a9a8a8;}

.chatbox{ width: 320px; background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; box-shadow: 0 6px 18px rgba(0,0,0,0.06); display: flex; flex-direction: column; }
.chatbox.minimized .cb-log, .chatbox.minimized .cb-input { display: none; }
.cb-header {background: #f3f4f6;padding: 8px 10px;display: flex;gap: 8px;align-items: center;font-family: Verdana, sans-serif;font-size: 13px;}
.cb-title {font-weight: 600; flex: 1; }
.cb-actions button { border: 0; background: transparent; cursor: pointer; font-size: 16px; }
.cb-log{height: 220px;overflow: auto;padding: 8px;background: #fafafa;font-family: Verdana, sans-serif;font-size: 13px;}

.cb-log::-webkit-scrollbar-track{border-radius: 10px;background-color: transparent;}
.cb-log::-webkit-scrollbar{width: 4px;background-color: transparent;}
.cb-log::-webkit-scrollbar-thumb{border-radius: 10px;;background-color: #cfcfcf;}

/* Messages */
.msg { display: flex; flex-direction: column; margin: 6px 0; }
.msg.me { align-items: flex-end; }
.msg.them { align-items: flex-start; }
.bubble { padding: 6px 12px; border-radius: 14px; background: #e5e7eb; max-width: 85%; word-wrap: break-word; }
.msg.me .bubble { background: #d1fae5; }
.chat-img { max-width: 200px; height: auto; border-radius: 8px; margin-top: 4px; display: block; }
.attachment-link { color: #0056b3; text-decoration: underline; }

/* Chat Input Area */
.cb-input { display: flex; gap: 6px; padding: 8px; border-top: 1px solid #eee; align-items: center; position: relative; }
.cb-input .text-input { flex: 1; padding: 8px; border: 1px solid #e5e7eb; border-radius: 4px;outline: none;}
.cb-input .file-input { display: none; }
.cb-input .btn-attach, .cb-input .btn-emoji, .cb-input .btn-send { border: 0; background: none; cursor: pointer; padding: 5px; font-size: 18px; flex-shrink: 0; }
.hidden { display: none !important; }

/* Emoji Popover */
.emoji-pop { position: absolute; bottom: 100%; right: 0; background: #fff; border: 1px solid #ccc; padding: 5px; display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); border-radius: 8px; }
.emoji-pop button { font-size: 20px; cursor: pointer; border: 0; background: transparent; }

/* File Preview */
.file-preview-container { display: flex; align-items: center; background-color: #f0f2f5; border-radius: 8px; padding: 5px; gap: 8px; flex: 1; min-width: 0; }
.file-preview-thumbnail { width: 32px; height: 32px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.file-preview-name { flex: 1; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-preview-remove { background: none; border: none; font-size: 18px; cursor: pointer; color: #666; }

/* Modal styles */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-content { background: white; padding: 20px; border-radius: 8px; width: 400px; max-width: 90%; }
.modal-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #eee; padding-bottom: 10px; margin-bottom: 15px; }
.modal-header h2{margin: 0;font-family: Verdana, sans-serif;font-size: 16px;}
.modal-body #group-name-input { width: 100%; padding: 10px; margin-bottom: 10px; border: 1px solid #ccc; border-radius: 4px;font-family: Verdana, sans-serif;font-size: 14px;outline: none;}
.modal-footer { text-align: right; margin-top: 20px; }
#btn-submit-group, #btn-submit-add-members { padding: 10px 20px; background-color: #3498db; color: white; border: none; border-radius: 4px; cursor: pointer; }
#btn-add-member { font-size: 20px; background-color: #2ecc71; color: white; border: none; border-radius: 50%; width: 40px; height: 40px; cursor: pointer; }
.btn-close-modal { border: none; background: none; font-size: 20px; cursor: pointer; }

/* Group Members List */
#group-members-list { max-height: 300px; overflow-y: auto; }
.member-item { display: flex; align-items: center; padding: 8px 0; border-bottom: 1px solid #f0f0f0; }
.member-item:last-child { border-bottom: none; }
.member-item .avatar { margin-right: 12px; }

/* Select2 Styles */
.select2-container--default .select2-selection--multiple { border: 1px solid #ccc; border-radius: 4px; padding: 4px; }
.select2-container { z-index: 1050; }
.select2-container--default .select2-selection--multiple{border-color: #ccc !important;padding: 7px !important;font-size: 14px;}
.select2-results__options .select2-results__option{font-family: Verdana, sans-serif;font-size: 14px;}
.select2-selection__rendered .select2-selection__choice{font-family: Verdana, sans-serif;font-size: 12px;}
/* ========================================= */
/* ðŸ”¥ VIDEO CALL FIX (The missing part)     */
/* ========================================= */
#jitsiContainer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000;
    z-index: 2000; /* Must be higher than dock/sidebar */
    display: none;
}
#jitsiContainer iframe {
    width: 100%;
    height: 100%;
    border: 0;
}
/* Style for the custom Hang Up button inside the video container */
.end-call-btn {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #ef4444;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 2001;
}
.end-call-btn:hover { background-color: #dc2626; }

.system-msg {
    text-align: center;
    font-size: 13px;
    color: #6b7280;
    margin: 12px 0;
}

.chat-start-msg{
    text-align: center;
    font-size: 12px;
    text: bold;
    color: #8696a0;        /* WhatsApp grey */
    margin: 10px 0;
    line-height: 1.4;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 
                 "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}


.item.pinned {
    background: #f9fafb;
    font-weight: 600;
    border-left: 4px solid #10b981;
}

.pin-label {
    font-size: 12px;
    margin-left: 6px;
    color: #10b981;
}
/* Add this to your styles.css */

.unread-badge {
    background-color: #ff3b30; /* Red */
    color: white;
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: bold;
    margin-left: auto;
    min-width: 20px;
    text-align: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* Update .item to ensure proper spacing */
.item { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    padding: 8px 10px; 
    cursor: pointer; 
    border-bottom: 1px solid #f3f4f6;
    position: relative; /* Added for positioning if needed */
}

/* ========================================= */
/* 🔥 UNREAD MESSAGE STYLES (NEW)            */
/* ========================================= */

/* 1. The Red Counter Badge */
.unread-badge {
    background-color: #ef4444; /* Bright Red */
    color: white;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 700;
    margin-left: auto; /* Pushes badge to the right */
    min-width: 20px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

/* 2. Style the Whole Row when Unread */
.item.unread {
    background-color: #eff6ff; /* Light Blue Background */
    border-left: 4px solid #3b82f6; /* Blue indicator on left */
}

/* Make name bold in unread chats */
.item.unread .name {
    font-weight: 700;
    color: #1f2937;
}

/* Adjust standard item to accommodate border */
.item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 10px; /* Slightly bigger padding */
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    border-left: 4px solid transparent; /* Invisible border to prevent jumping */
    transition: background 0.2s;
    font-family: Verdana, sans-serif;
    font-size: 14px;
}
.unread-badge {
    background-color: #ef4444;
    color: white;
    border-radius: 12px;
    padding: 2px 8px; /* Padding creates size */
    font-size: 11px;
    font-weight: 700;
    margin-left: auto;
    min-width: 20px;
    text-align: center;
    /* Display none is handled by JS not creating the element, 
       but you can add this to be safe if empty: */
    display: inline-block; 
}

/* Hide empty badges purely via CSS (Backup) */
.unread-badge:empty {
    display: none;
}
const select2Style = document.createElement("style");
select2Style.innerText = `
    /* 1. Hide items that are already selected */
    .select2-results__option[aria-selected=true] { 
        display: none; 
    }
    
    /* 2. Optional: Fix width issues in modals */
    .select2-container {
        width: 100% !important;
    }
`;
document.head.appendChild(select2Style);



.member-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-bottom: 1px solid #e5e7eb;
}

.member-item .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.member-item span {
    flex: 1;
    font-size: 14px;
    color: #111827;
}

.btn-remove {
    background: #fee2e2;
    color: #b91c1c;
    border: none;
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.btn-remove:hover {
    background: #fecaca;
}


.member-admin {
    background: #bae9a5;
    color: #2f3c2a;
    padding: 2px 10px;
    font-size: 12px;
    border-radius: 6px;
    font-weight: 500;
    white-space: nowrap;
}

.member-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.member-name {
    flex: 1;                
    font-size: 14px;
}

.member-action {
    display: flex;
    align-items: center;
}

.btn-exit {
    background: #fef3c7;
    color: #92400e;
    border: none;
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
}

.btn-exit:hover {
    background: #fde68a;


