#cxc-chat-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    border: 1px solid #dcdcde;
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
    max-width: 980px;
    margin: 20px auto;
    box-sizing: border-box;
}

#cxc-chat-wrapper * {
    box-sizing: border-box;
}

/* Login card */
#cxc-login-card {
    padding: 30px;
    max-width: 360px;
    margin: 40px auto;
    text-align: center;
}
.cxc-form-group {
    margin-bottom: 12px;
}
#cxc-login-card input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
}
#cxc-btn-login {
    width: 100%;
    padding: 10px;
    background: #0073aa;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

/* Two-column container: Chat Left (65%), Users Right (35%) */
#cxc-messenger {
    display: flex;
    flex-direction: row;
    height: 600px;
}

#cxc-left-panel {
    width: 65%;
    display: flex;
    flex-direction: column;
    position: relative;
    border-right: 1px solid #e2e4e7;
}

#cxc-right-panel {
    width: 35%;
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
}

/* Right Panel: Header, Meta, and 7-User Viewport */
.cxc-panel-header {
    padding: 12px 14px;
    border-bottom: 1px solid #e2e4e7;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.cxc-panel-header h4 { margin: 0; font-size: 14px; }
#cxc-active-badge { font-size: 11px; background: #28a745; color: #fff; padding: 2px 7px; border-radius: 12px; }

.cxc-user-meta {
    font-size: 12px;
    padding: 8px 14px;
    border-bottom: 1px solid #e2e4e7;
    background: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
#cxc-btn-logout {
    padding: 3px 8px;
    font-size: 11px;
    background: #d63638;
    color: #fff;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}

/* Exactly 7 users visible (55px * 7 = 385px) before scrolling */
#cxc-online-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 385px;
    overflow-y: auto;
    flex: 1;
}

.cxc-contact-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    position: relative;
    height: 55px;
}
.cxc-contact-item:hover { background: #eef2f5; }
.cxc-contact-item.active-contact { background: #e0ecf8; }

.cxc-avatar-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #28a745;
    flex-shrink: 0;
}
.cxc-contact-info {
    flex: 1;
    overflow: hidden;
}
.cxc-contact-info strong {
    display: block;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cxc-contact-info small {
    display: block;
    color: #666;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Unread Message Notification Blob */
.cxc-unread-blob {
    background: #e53e3e;
    color: #ffffff;
    font-size: 11px;
    font-weight: bold;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    border-radius: 9px;
    padding: 0 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.cxc-no-users {
    padding: 20px 10px;
    color: #888;
    font-size: 12px;
    text-align: center;
}

/* Left Panel: Chat container */
#cxc-empty-state { margin: auto; color: #888; font-size: 14px; text-align: center; padding: 20px; }
#cxc-chat-container { display: flex; flex-direction: column; height: 100%; width: 100%; }
.cxc-chat-header {
    padding: 12px 16px;
    border-bottom: 1px solid #e2e4e7;
    background: #fff;
}
.cxc-chat-header small { color: #666; margin-left: 5px; }

#cxc-message-stream {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #fbfbfb;
}

.cxc-msg-bubble {
    max-width: 75%;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.4;
    word-break: break-word;
}
.cxc-msg-bubble p { margin: 0; }
.cxc-outgoing { align-self: flex-end; background: #dcf8c6; }
.cxc-incoming { align-self: flex-start; background: #fff; border: 1px solid #e5e5e5; }
.cxc-msg-author { font-size: 11px; font-weight: bold; color: #555; display: block; margin-bottom: 3px; }
.cxc-msg-time { display: block; font-size: 10px; color: #999; margin-top: 4px; text-align: right; }

.cxc-chat-media {
    max-width: 100%;
    max-height: 220px;
    border-radius: 4px;
    display: block;
    margin-top: 5px;
}
.cxc-chat-media.cxc-lightbox-trigger {
    cursor: zoom-in;
    transition: opacity 0.2s;
}
.cxc-chat-media.cxc-lightbox-trigger:hover {
    opacity: 0.9;
}

/* Inputs */
.cxc-input-bar {
    display: flex;
    align-items: center;
    padding: 10px;
    border-top: 1px solid #e2e4e7;
    background: #fff;
    gap: 8px;
}
.cxc-input-bar input[type="text"] {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
}
.cxc-file-label {
    cursor: pointer;
    font-size: 20px;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 6px;
    border-radius: 4px;
    transition: background 0.2s;
}
.cxc-file-label:hover {
    background: #f0f0f0;
}
.cxc-file-label input[type="file"] { display: none; }
#cxc-btn-send {
    padding: 8px 16px;
    background: #0073aa;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}
#cxc-btn-send:hover {
    background: #005a87;
}

/* Upload Status / Progress Bar */
#cxc-upload-status {
    padding: 6px 14px 8px;
    font-size: 12px;
    color: #0073aa;
    font-weight: 500;
}
.cxc-progress-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
}
.cxc-progress-bar-bg {
    flex: 1;
    height: 6px;
    background: #e2e4e7;
    border-radius: 3px;
    overflow: hidden;
}
.cxc-progress-bar-fill {
    height: 100%;
    width: 0%;
    background: #0073aa;
    border-radius: 3px;
    transition: width 0.15s ease;
}

/* Fullscreen Lightbox Modal */
#cxc-lightbox-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.88);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

#cxc-lightbox-img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    user-select: none;
}

#cxc-lightbox-close {
    position: absolute;
    top: 20px;
    right: 25px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    font-size: 32px;
    line-height: 1;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.1s;
}
#cxc-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.08);
}

/* Mobile View Responsive */
@media screen and (max-width: 768px) {
    #cxc-messenger {
        flex-direction: column-reverse;
        height: auto;
    }
    #cxc-left-panel {
        width: 100%;
        height: 480px;
        border-right: none;
        border-top: 1px solid #e2e4e7;
    }
    #cxc-right-panel {
        width: 100%;
        height: auto;
    }
    #cxc-online-list {
        max-height: 165px;
    }
    #cxc-lightbox-close {
        top: 12px;
        right: 12px;
        width: 38px;
        height: 38px;
        font-size: 26px;
    }
}