/* =========================================
   NEXUS MESSAGES — Messaging page UI
   ========================================= */

/* Override outer 3-col grid for messages page */
.nx-logged-in .nx-messages-wrapper {
    display: block;
    padding: 0;
    max-width: 100%;
}

.nx-messages-page {
    display: grid;
    grid-template-columns: 340px 1fr;
    height: calc(100vh - var(--nx-topbar-height));
    max-width: 1600px;
    margin: 0 auto;
    overflow: hidden;
}

/* Conversation list panel */
.nx-conv-panel {
    border-right: 1px solid var(--nx-border);
    display: flex; flex-direction: column;
    background: var(--nx-card);
    overflow: hidden;
}
.nx-conv-panel-header {
    padding: var(--nx-spacing-md);
    border-bottom: 1px solid var(--nx-border);
    flex-shrink: 0;
}
.nx-conv-panel-title { font-size: 1.25rem; font-weight: 700; margin-bottom: var(--nx-spacing-sm); }
.nx-conv-search {
    padding: 8px 14px;
    background: var(--nx-bg);
    border: 1px solid var(--nx-border);
    border-radius: var(--nx-radius-full);
    font-size: 0.875rem;
    width: 100%;
    outline: none;
}
.nx-conv-search:focus { border-color: var(--nx-primary); }

.nx-conv-list { flex: 1; overflow-y: auto; }

.nx-conv-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px var(--nx-spacing-md);
    cursor: pointer;
    transition: background var(--nx-transition);
    border-left: 3px solid transparent;
    text-decoration: none;
}
.nx-conv-item:hover    { background: var(--nx-bg); text-decoration: none; }
.nx-conv-item.is-active { background: var(--nx-primary-light); border-left-color: var(--nx-primary); }
.nx-conv-item.has-unread .nx-conv-name   { font-weight: 700; }
.nx-conv-item.has-unread .nx-conv-last  { color: var(--nx-text-primary); font-weight: 600; }

.nx-conv-avatar-wrap { position: relative; flex-shrink: 0; }
.nx-conv-online-dot {
    position: absolute; bottom: 1px; right: 1px;
    width: 12px; height: 12px;
    background: #31a24c;
    border-radius: 50%;
    border: 2px solid var(--nx-card);
}
.nx-conv-info { flex: 1; min-width: 0; }
.nx-conv-name-row { display: flex; align-items: center; justify-content: space-between; }
.nx-conv-name { font-size: 0.9375rem; font-weight: 600; color: var(--nx-text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nx-conv-time { font-size: 0.75rem; color: var(--nx-text-muted); flex-shrink: 0; }
.nx-conv-last { font-size: 0.875rem; color: var(--nx-text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.nx-conv-unread-count { background: var(--nx-primary); color: #fff; font-size: 0.6875rem; font-weight: 700; padding: 2px 6px; border-radius: var(--nx-radius-full); flex-shrink: 0; }

/* Message thread panel */
.nx-thread-panel {
    display: flex; flex-direction: column;
    background: var(--nx-bg-secondary);
    overflow: hidden;
    position: relative;
}
.nx-thread-header {
    display: flex; align-items: center; gap: 12px;
    padding: 12px var(--nx-spacing-md);
    background: var(--nx-card);
    border-bottom: 1px solid var(--nx-border);
    flex-shrink: 0;
    box-shadow: var(--nx-shadow-sm);
}
.nx-thread-user-info { flex: 1; }
.nx-thread-name { font-weight: 700; font-size: 1rem; color: var(--nx-text-primary); text-decoration: none; }
.nx-thread-name:hover { text-decoration: underline; }
.nx-thread-status { font-size: 0.8125rem; color: var(--nx-text-muted); }
.nx-thread-status.is-online { color: #31a24c; }
.nx-thread-actions { display: flex; gap: 4px; }

.nx-thread-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--nx-spacing-md);
    display: flex; flex-direction: column; gap: 4px;
}

/* Date divider */
.nx-msg-date-divider {
    text-align: center;
    font-size: 0.75rem;
    color: var(--nx-text-muted);
    margin: var(--nx-spacing-sm) 0;
}

/* Bubble */
.nx-msg-group { display: flex; flex-direction: column; margin-bottom: 8px; }
.nx-msg-group.is-mine { align-items: flex-end; }
.nx-msg-group.is-theirs { align-items: flex-start; }
.nx-msg-group.is-theirs .nx-msg-sender-avatar { display: flex; }

.nx-msg-sender-avatar { display: none; }

.nx-msg-bubble-wrap {
    display: flex; align-items: flex-end; gap: 6px;
    max-width: 72%;
}
.nx-msg-group.is-mine .nx-msg-bubble-wrap { flex-direction: row-reverse; }

.nx-msg-bubble {
    padding: 9px 14px;
    border-radius: 18px;
    font-size: 0.9375rem;
    line-height: 1.4;
    max-width: 100%;
    word-break: break-word;
    position: relative;
}
.nx-msg-group.is-mine .nx-msg-bubble {
    background: var(--nx-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.nx-msg-group.is-theirs .nx-msg-bubble {
    background: var(--nx-card);
    color: var(--nx-text-primary);
    border-bottom-left-radius: 4px;
    box-shadow: var(--nx-shadow-sm);
}
.nx-msg-bubble img { border-radius: var(--nx-radius-sm); max-width: 240px; }

.nx-msg-time {
    font-size: 0.6875rem;
    color: var(--nx-text-muted);
    margin-top: 2px;
    padding: 0 4px;
}

/* Thread input */
.nx-thread-input-bar {
    background: var(--nx-card);
    border-top: 1px solid var(--nx-border);
    padding: 12px var(--nx-spacing-md);
    display: flex; align-items: flex-end; gap: 8px;
    flex-shrink: 0;
}
.nx-thread-input {
    flex: 1;
    background: var(--nx-bg);
    border: 1px solid var(--nx-border);
    border-radius: 20px;
    padding: 9px 16px;
    font-size: 0.9375rem;
    color: var(--nx-text-primary);
    outline: none;
    resize: none;
    max-height: 100px;
    overflow-y: auto;
    transition: border-color var(--nx-transition);
    line-height: 1.4;
}
.nx-thread-input:focus { border-color: var(--nx-primary); }
.nx-thread-send-btn {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--nx-primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: background var(--nx-transition);
}
.nx-thread-send-btn:hover { background: var(--nx-primary-dark); }
.nx-thread-send-btn:disabled { background: var(--nx-border); }

/* Empty state */
.nx-thread-empty {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    color: var(--nx-text-muted);
    gap: var(--nx-spacing-md);
}
.nx-thread-empty svg { opacity: 0.3; }

/* =========================================
   NEXUS CHAT WIDGET — Floating chat bubble
   ========================================= */

.nx-chat-widget {
    position: fixed;
    bottom: 72px;
    right: 20px;
    z-index: 900;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

/* Bubble button */
.nx-chat-bubble-btn {
    width: 52px; height: 52px;
    border-radius: 50%;
    background: var(--nx-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 16px rgba(24,119,242,0.45);
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
}
.nx-chat-bubble-btn:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(24,119,242,0.55); }
.nx-chat-bubble-btn .nx-badge {
    position: absolute;
    top: -4px; right: -4px;
    min-width: 18px; height: 18px;
    font-size: 0.7rem;
}

/* Panel */
.nx-chat-panel, .nx-chat-thread {
    width: 300px;
    background: var(--nx-card);
    border: 1px solid var(--nx-border);
    border-radius: 14px;
    box-shadow: 0 8px 28px rgba(0,0,0,0.14);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 440px;
}

.nx-chat-panel-header, .nx-chat-thread-header {
    display: flex; align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid var(--nx-border);
    background: var(--nx-card);
    flex-shrink: 0;
    gap: 8px;
}
.nx-chat-panel-title { font-weight: 700; font-size: 1rem; flex: 1; }
.nx-chat-panel-actions { display: flex; gap: 4px; }

.nx-chat-icon-btn {
    width: 30px; height: 30px;
    border: none; background: none; cursor: pointer;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--nx-text-secondary);
    transition: background var(--nx-transition);
}
.nx-chat-icon-btn:hover { background: var(--nx-bg-secondary); color: var(--nx-text-primary); }

/* Search */
.nx-chat-panel-search {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--nx-border);
    flex-shrink: 0;
}
.nx-chat-search-icon { color: var(--nx-text-muted); flex-shrink: 0; }
.nx-chat-panel-search input {
    flex: 1; border: none; background: none; outline: none;
    font-size: 0.875rem; color: var(--nx-text-primary);
}

/* Conversation list */
.nx-chat-conv-list {
    overflow-y: auto;
    flex: 1;
}
.nx-chat-conv-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--nx-transition);
    border-bottom: 1px solid var(--nx-border-light, #f0f0f0);
}
.nx-chat-conv-item:hover { background: var(--nx-bg-secondary); text-decoration: none; }
.nx-chat-conv-avatar-wrap { position: relative; flex-shrink: 0; }
.nx-chat-conv-info { flex: 1; min-width: 0; }
.nx-chat-conv-name {
    font-size: 0.9rem; font-weight: 600;
    color: var(--nx-text-primary);
    display: flex; align-items: center; gap: 6px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nx-chat-conv-last {
    font-size: 0.78rem; color: var(--nx-text-muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin-top: 2px;
}
.nx-chat-conv-time { font-size: 0.72rem; color: var(--nx-text-muted); flex-shrink: 0; }
.nx-chat-unread-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--nx-primary);
    display: inline-block;
}

/* Thread */
.nx-chat-thread-name { font-weight: 600; font-size: 0.9rem; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nx-chat-thread-messages {
    flex: 1; overflow-y: auto;
    padding: 12px;
    display: flex; flex-direction: column; gap: 6px;
}
.nx-chat-msg { display: flex; flex-direction: column; max-width: 80%; }
.nx-chat-msg-mine { align-self: flex-end; align-items: flex-end; }
.nx-chat-msg-other { align-self: flex-start; align-items: flex-start; }
.nx-chat-bubble {
    padding: 8px 12px;
    border-radius: 18px;
    font-size: 0.875rem;
    line-height: 1.4;
    word-break: break-word;
}
.nx-chat-msg-mine .nx-chat-bubble { background: var(--nx-primary); color: #fff; border-bottom-right-radius: 4px; }
.nx-chat-msg-other .nx-chat-bubble { background: var(--nx-bg-secondary); color: var(--nx-text-primary); border-bottom-left-radius: 4px; }
.nx-chat-msg-time { font-size: 0.68rem; color: var(--nx-text-muted); margin: 2px 4px 0; }

/* Thread footer */
.nx-chat-thread-footer {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px;
    border-top: 1px solid var(--nx-border);
    flex-shrink: 0;
}
.nx-chat-thread-input {
    flex: 1;
    border: 1px solid var(--nx-border);
    border-radius: 20px;
    padding: 7px 14px;
    font-size: 0.875rem;
    background: var(--nx-bg-secondary);
    color: var(--nx-text-primary);
    outline: none;
    transition: border-color var(--nx-transition);
}
.nx-chat-thread-input:focus { border-color: var(--nx-primary); background: var(--nx-card); }
.nx-chat-send-btn {
    width: 34px; height: 34px;
    border-radius: 50%;
    border: none;
    background: var(--nx-primary);
    color: #fff;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background var(--nx-transition), transform 0.15s;
    flex-shrink: 0;
}
.nx-chat-send-btn:hover:not(:disabled) { background: var(--nx-primary-dark, #1565c0); transform: scale(1.08); }
.nx-chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Typing indicator */
.nx-chat-thread-typing {
    padding: 6px 14px;
    display: flex; gap: 4px; align-items: center;
}
.nx-typing-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--nx-text-muted);
    animation: nx-typing-bounce 1.2s infinite;
}
.nx-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.nx-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes nx-typing-bounce {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1.2); opacity: 1; }
}

/* Loading / empty states */
.nx-chat-loading { display: flex; justify-content: center; padding: 20px; }
.nx-chat-empty { padding: 20px; text-align: center; color: var(--nx-text-muted); font-size: 0.875rem; }

/* Mobile: hide on small screens (mobile nav already handles messages) */
@media (max-width: 640px) { .nx-chat-widget { display: none; } }


/* ================================================================
   Chat Widget — Enhanced UI
   ================================================================ */

/* Wider panel */
.nx-chat-panel, .nx-chat-thread {
    width: 360px !important;
    max-height: 520px !important;
    box-shadow: 0 8px 40px rgba(0,0,0,.18) !important;
}

/* Thread messages area */
.nx-chat-thread-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 340px;
    min-height: 180px;
    scroll-behavior: smooth;
}

/* Message bubbles */
.nx-chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 78%;
    gap: 2px;
    animation: nx-msg-in .15s ease;
}
@keyframes nx-msg-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.nx-chat-msg-mine { align-self: flex-end; align-items: flex-end; }
.nx-chat-msg-other { align-self: flex-start; align-items: flex-start; }

.nx-chat-bubble {
    padding: 9px 13px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.45;
    word-break: break-word;
    max-width: 100%;
}
.nx-chat-msg-mine .nx-chat-bubble {
    background: linear-gradient(135deg, #1877F2, #0d5dc5);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.nx-chat-msg-other .nx-chat-bubble {
    background: var(--nx-bg-secondary, #f0f2f5);
    color: var(--nx-text, #1c1e21);
    border-bottom-left-radius: 4px;
}
.nx-chat-msg-mine .nx-chat-bubble:hover,
.nx-chat-msg-other .nx-chat-bubble:hover { filter: brightness(.97); }

.nx-chat-msg-time {
    font-size: 11px;
    color: var(--nx-text-muted, #65676b);
    padding: 0 4px;
    opacity: 0;
    transition: opacity .2s;
}
.nx-chat-msg:hover .nx-chat-msg-time { opacity: 1; }

/* Image in chat */
.nx-chat-img-msg {
    max-width: 200px;
    border-radius: 12px;
    display: block;
    cursor: pointer;
    transition: transform .2s;
}
.nx-chat-img-msg:hover { transform: scale(1.02); }

/* Read receipt */
.nx-chat-seen {
    font-size: 10px;
    color: var(--nx-text-muted, #65676b);
    display: flex;
    align-items: center;
    gap: 3px;
    align-self: flex-end;
    padding-right: 4px;
}
.nx-chat-seen svg { width: 12px; height: 12px; color: #1877F2; }

/* Thread footer — emoji + attach + send */
.nx-chat-thread-footer {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    border-top: 1px solid var(--nx-border, #e4e6eb);
    background: #fff;
    border-radius: 0 0 14px 14px;
    position: relative;
}
.nx-chat-footer-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    color: var(--nx-text-muted, #65676b);
    flex-shrink: 0;
    transition: background .15s, color .15s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.nx-chat-footer-icon-btn:hover {
    background: var(--nx-bg-secondary, #f0f2f5);
    color: var(--nx-primary, #1877F2);
}
.nx-chat-thread-input {
    flex: 1 !important;
    border: none !important;
    background: var(--nx-bg-secondary, #f0f2f5) !important;
    border-radius: 20px !important;
    padding: 8px 14px !important;
    font-size: 14px !important;
    outline: none !important;
    min-width: 0;
}
.nx-chat-send-btn {
    width: 34px !important;
    height: 34px !important;
    border-radius: 50% !important;
    background: var(--nx-primary, #1877F2) !important;
    border: none !important;
    color: #fff !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    transition: transform .15s, opacity .15s !important;
}
.nx-chat-send-btn:disabled { opacity: .45 !important; cursor: default !important; }
.nx-chat-send-btn:not(:disabled):hover { transform: scale(1.08) !important; }

/* Emoji picker */
.nx-emoji-picker {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 12px;
    background: #fff;
    border: 1px solid var(--nx-border, #e4e6eb);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,.15);
    padding: 8px;
    width: 272px;
    z-index: 9999;
    display: none;
}
.nx-emoji-picker.is-open { display: block; animation: nx-msg-in .15s ease; }
.nx-emoji-picker-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    max-height: 200px;
    overflow-y: auto;
}
.nx-emoji-picker-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    line-height: 1;
    transition: background .1s;
}
.nx-emoji-picker-btn:hover { background: var(--nx-bg-secondary, #f0f2f5); }

/* Image upload preview */
.nx-chat-attach-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--nx-bg-secondary, #f0f2f5);
    border-top: 1px solid var(--nx-border, #e4e6eb);
}
.nx-chat-attach-preview img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
}
.nx-chat-attach-remove {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: var(--nx-text-muted, #65676b);
    padding: 0 4px;
}

/* Online status on thread header avatar */
.nx-chat-thread-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}
.nx-chat-thread-avatar-wrap .nx-online-ring {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #31a24c;
    border: 2px solid #fff;
}

/* Typing indicator */
.nx-chat-thread-typing {
    display: flex !important;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
}
.nx-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--nx-text-muted, #65676b);
    animation: nx-typing 1.2s infinite;
}
.nx-typing-dot:nth-child(2) { animation-delay: .2s; }
.nx-typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes nx-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: .4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* Mobile */
@media (max-width: 480px) {
    .nx-chat-panel, .nx-chat-thread {
        width: calc(100vw - 24px) !important;
        right: 0 !important;
        max-height: 75vh !important;
    }
}

/* ═══════════════════════════════════════════════════
   Facebook-style Floating Chat Windows
═══════════════════════════════════════════════════ */
#nx-chat-wins-container {
    position: fixed;
    bottom: 0;
    right: 90px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    z-index: 9990;
    pointer-events: none;
}
.nx-fw {
    width: 300px;
    background: var(--nx-card, #fff);
    border-radius: 12px 12px 0 0;
    box-shadow: 0 4px 24px rgba(0,0,0,.22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    pointer-events: all;
    transition: height .2s ease;
    max-height: 420px;
}
.nx-fw.is-minimized {
    max-height: 48px;
    border-radius: 12px 12px 0 0;
}
.nx-fw.is-minimized .nx-fw__msgs,
.nx-fw.is-minimized .nx-fw__footer { display: none; }

/* Header */
.nx-fw__head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--nx-primary, #1877F2);
    cursor: pointer;
    flex-shrink: 0;
    min-height: 48px;
    box-sizing: border-box;
}
.nx-fw__avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,.4);
}
.nx-fw__name {
    flex: 1;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.nx-fw__btn {
    width: 28px; height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,.18);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: background .15s;
    flex-shrink: 0;
}
.nx-fw__btn:hover { background: rgba(255,255,255,.32); }

/* Messages area */
.nx-fw__msgs {
    flex: 1;
    overflow-y: auto;
    padding: 10px 10px 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 0;
    background: var(--nx-card, #fff);
}
.nx-fw-msg {
    display: flex;
    max-width: 85%;
}
.nx-fw-msg--mine  { align-self: flex-end; }
.nx-fw-msg--other { align-self: flex-start; }
.nx-fw-bubble {
    padding: 8px 12px;
    border-radius: 18px;
    font-size: 13.5px;
    line-height: 1.4;
    word-break: break-word;
}
.nx-fw-msg--mine .nx-fw-bubble {
    background: var(--nx-primary, #1877F2);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.nx-fw-msg--other .nx-fw-bubble {
    background: var(--nx-bg-secondary, #f0f2f5);
    color: var(--nx-text, #050505);
    border-bottom-left-radius: 4px;
}

/* Footer */
.nx-fw__footer {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-top: 1px solid var(--nx-border-light, #e4e6eb);
    background: var(--nx-card, #fff);
    flex-shrink: 0;
}
.nx-fw__input {
    flex: 1;
    border: none;
    outline: none;
    background: var(--nx-bg-secondary, #f0f2f5);
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13px;
    color: var(--nx-text, #050505);
}
.nx-fw__input::placeholder { color: var(--nx-text-muted, #65676b); }
.nx-fw__send {
    width: 32px; height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--nx-primary, #1877F2);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: opacity .15s;
    flex-shrink: 0;
}
.nx-fw__send:disabled { opacity: 0.35; cursor: default; }
.nx-fw__send:not(:disabled):hover { opacity: 0.85; }

/* Dark mode */
[data-theme="dark"] .nx-fw                      { background: #242526; box-shadow: 0 4px 24px rgba(0,0,0,.5); }
[data-theme="dark"] .nx-fw__msgs               { background: #242526; }
[data-theme="dark"] .nx-fw-msg--other .nx-fw-bubble { background: #3a3b3c; color: #e4e6eb; }
[data-theme="dark"] .nx-fw__footer             { background: #242526; border-top-color: #3a3b3c; }
[data-theme="dark"] .nx-fw__input              { background: #3a3b3c; color: #e4e6eb; }
[data-theme="dark"] .nx-fw__input::placeholder { color: #b0b3b8; }

@media (max-width: 640px) {
    #nx-chat-wins-container { right: 0; left: 0; justify-content: flex-end; }
    .nx-fw { width: calc(100vw - 16px); max-width: 340px; }
}

/* ── Contacts sidebar widget ────────────────────────────────────── */
.nx-contacts-widget { padding: 16px 20px; }
.nx-contacts-widget__head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px;
}
.nx-contacts-widget__head h3 {
    font-size: 15px; font-weight: 700; color: var(--nx-text, #050505); margin: 0;
}
.nx-contacts-widget__head svg { color: var(--nx-text-muted, #65676b); cursor: pointer; }

.nx-contacts-list {
    list-style: none; margin: 0; padding: 0;
    display: flex; flex-direction: column; gap: 2px;
}
.nx-contact-item {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 8px; border-radius: 8px;
    cursor: pointer; transition: background .15s;
}
.nx-contact-item:hover { background: var(--nx-hover-bg, #f0f2f5); }
.nx-contact-item__av {
    position: relative; flex-shrink: 0;
    width: 36px; height: 36px;
}
.nx-contact-item__av img {
    width: 36px; height: 36px; border-radius: 50%; object-fit: cover;
}
.nx-contact-item__online {
    position: absolute; bottom: 1px; right: 1px;
    width: 10px; height: 10px; border-radius: 50%;
    background: #31a24c;
    border: 2px solid var(--nx-card, #fff);
}
.nx-contact-item__name {
    font-size: 14px; font-weight: 500;
    color: var(--nx-text, #050505);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    flex: 1;
}

/* Dark mode */
[data-theme="dark"] .nx-contacts-widget__head h3 { color: #e4e6eb; }
[data-theme="dark"] .nx-contact-item:hover        { background: #3a3b3c; }
[data-theme="dark"] .nx-contact-item__name        { color: #e4e6eb; }
[data-theme="dark"] .nx-contact-item__online      { border-color: #242526; }

/* Chat window size override */
.nx-fw {
    width: 360px !important;
    max-height: 520px !important;
}
.nx-fw__msgs {
    min-height: 300px;
}
@media (max-width: 640px) {
    .nx-fw { width: calc(100vw - 16px) !important; max-width: 360px !important; }
}
