/* ================================================================
   MIXKO — WhatsApp-Style Chat UI
   Brand: rich purple #7c3aed / #9f67ff  |  Dark theme #07070d
   ================================================================ */

.jsi-chat-app *,
.jsi-chat-app *::before,
.jsi-chat-app *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ── App Shell ──────────────────────────────────────────────────── */
/* Height fills from just-below the app header (70px) to just-above
   the bottom nav (82px). Both are fixed so we use calc. */
.jsi-chat-app {
    display: flex;
    width: 100%;
    height: calc(100vh - 70px - 82px);
    min-height: 480px;
    background: #07070d;
    border-radius: 16px;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    color: #e9edef;
    position: relative;
}

/* ── NAV UNREAD BADGE ───────────────────────────────────────────── */
.jsi-nav-icon-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.jsi-nav-unread-dot {
    position: absolute;
    top: -5px;
    right: -9px;
    min-width: 17px;
    height: 17px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    border: 2px solid #111118;
    line-height: 1;
    z-index: 2;
}

/* ================================================================
   SIDEBAR
   ================================================================ */
.jsi-chat-sidebar {
    width: 360px;
    min-width: 300px;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    background: #0a0a14;
    border-right: 1px solid rgba(124,58,237,.15);
    height: 100%;
    flex-shrink: 0;
    transition: transform .25s ease;
    overflow: hidden;
}

/* Sticky sidebar header */
.jsi-chat-sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #12082a, #0e0e1f);
    border-bottom: 1px solid rgba(124,58,237,.2);
    min-height: 60px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 10;
}
.jsi-chat-my-avatar { position: relative; cursor: pointer; flex-shrink: 0; }
.jsi-chat-my-avatar img {
    width: 40px; height: 40px; border-radius: 50%;
    object-fit: cover; display: block; background: #1f1b3a;
    border: 2px solid rgba(124,58,237,.4);
}
.jsi-online-ring {
    position: absolute; bottom: 0; right: 0;
    width: 11px; height: 11px;
    background: #22c55e; border-radius: 50%;
    border: 2px solid #12082a;
}
.jsi-chat-title {
    font-size: 18px; font-weight: 700;
    background: linear-gradient(135deg,#a78bfa,#7c3aed);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text; flex: 1;
}
.jsi-chat-sidebar-actions { display: flex; gap: 4px; align-items: center; margin-left: auto; }

/* Sidebar search */
.jsi-sidebar-search-bar {
    padding: 8px 12px;
    background: #0a0a14;
    border-bottom: 1px solid rgba(124,58,237,.1);
    flex-shrink: 0;
    position: relative;
}
.jsi-sidebar-search-bar input {
    width: 100%;
    background: #12082a;
    border: 1px solid rgba(124,58,237,.25);
    border-radius: 10px;
    padding: 9px 14px 9px 38px;
    color: #e9edef;
    font-size: 14px;
    outline: none;
    transition: border-color .2s;
}
.jsi-sidebar-search-bar input:focus { border-color: #7c3aed; }
.jsi-sidebar-search-bar input::placeholder { color: #6b7280; }

/* Conversations list — scrollable middle */
.jsi-conversations-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(124,58,237,.3) transparent;
}
.jsi-conversations-list::-webkit-scrollbar { width: 4px; }
.jsi-conversations-list::-webkit-scrollbar-thumb { background: rgba(124,58,237,.3); border-radius: 4px; }

/* Empty contacts */
.jsi-chat-empty-contacts {
    padding: 48px 24px; text-align: center;
    color: #6b7280; font-size: 13px; line-height: 1.7;
}

/* Conversation item */
.jsi-conv-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 16px; cursor: pointer;
    transition: background .12s;
    border-bottom: 1px solid rgba(124,58,237,.07);
    position: relative;
}
.jsi-conv-item:hover { background: rgba(124,58,237,.08); }
.jsi-conv-item.jsi-conv-active { background: rgba(124,58,237,.14); }

.jsi-conv-avatar-wrap { position: relative; flex-shrink: 0; }
.jsi-conv-avatar-wrap img, .jsi-conv-avatar-wrap .jsi-conv-avatar {
    width: 48px; height: 48px; border-radius: 50%;
    object-fit: cover; background: #1f1b3a; display: block;
    border: 2px solid rgba(124,58,237,.2);
}
.jsi-contact-online-dot {
    position: absolute; bottom: 1px; right: 1px;
    width: 11px; height: 11px;
    background: #22c55e; border-radius: 50%;
    border: 2px solid #0a0a14;
}

.jsi-conv-info { flex: 1; min-width: 0; }
.jsi-conv-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 3px; }
.jsi-conv-name {
    font-size: 15px; font-weight: 600; color: #e9edef;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 190px;
}
.jsi-conv-time { font-size: 11px; color: #6b7280; white-space: nowrap; flex-shrink: 0; }

.jsi-conv-bottom { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.jsi-conv-preview {
    font-size: 13px; color: #6b7280;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1;
}

/* Unread badge */
.jsi-unread-badge {
    background: linear-gradient(135deg,#7c3aed,#9f67ff);
    color: #fff; font-size: 11px; font-weight: 700;
    min-width: 20px; height: 20px; border-radius: 50px;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0 5px; flex-shrink: 0; line-height: 1;
}

/* Spinner */
.jsi-chat-loading { display: flex; justify-content: center; padding: 40px 0; }
.jsi-spinner {
    width: 32px; height: 32px;
    border: 3px solid rgba(124,58,237,.2);
    border-top-color: #7c3aed;
    border-radius: 50%; animation: jsiSpin .7s linear infinite;
}
@keyframes jsiSpin { to { transform: rotate(360deg); } }

/* ── Mobile floating search FAB ────────────────────────────────── */
.jsi-chat-search-fab {
    display: none; /* shown only on mobile */
    position: absolute;
    bottom: 20px; right: 20px;
    width: 52px; height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg,#7c3aed,#9f67ff);
    border: none; color: #fff; font-size: 22px;
    cursor: pointer; z-index: 20;
    box-shadow: 0 4px 20px rgba(124,58,237,.55);
    display: flex; align-items: center; justify-content: center;
    transition: transform .2s, box-shadow .2s;
}
.jsi-chat-search-fab:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(124,58,237,.7); }

/* ================================================================
   MAIN CHAT PANEL
   ================================================================ */
.jsi-chat-main {
    flex: 1; display: flex; flex-direction: column;
    background: #07070d; min-width: 0;
    position: relative; height: 100%; overflow: hidden;
}

/* Subtle purple-dot wallpaper */
.jsi-chat-main::before {
    content: '';
    position: absolute; inset: 0;
    background-image: radial-gradient(circle, rgba(124,58,237,.06) 1px, transparent 1px);
    background-size: 28px 28px;
    pointer-events: none; z-index: 0;
}
.jsi-chat-main > * { position: relative; z-index: 1; }

/* Empty state */
.jsi-chat-empty-state {
    flex: 1; display: flex; align-items: center;
    justify-content: center; flex-direction: column;
    gap: 16px; padding: 40px; text-align: center;
}
.jsi-chat-empty-inner { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.jsi-chat-empty-inner h3 { font-size: 20px; font-weight: 300; color: #e9edef; }
.jsi-chat-empty-inner p { font-size: 14px; color: #6b7280; }

/* Chat window */
.jsi-chat-window { display: flex; flex-direction: column; height: 100%; overflow: hidden; }

/* ── STICKY Chat window header ──────────────────────────────────── */
.jsi-chat-window-header {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px;
    background: linear-gradient(135deg, #12082a, #0e0e1f);
    border-bottom: 1px solid rgba(124,58,237,.2);
    min-height: 62px; flex-shrink: 0;
    position: sticky; top: 0; z-index: 15;
}
.jsi-chat-back-btn { display: none; }

.jsi-chat-partner-info {
    display: flex; align-items: center; gap: 10px;
    flex: 1; cursor: pointer; min-width: 0;
}
.jsi-chat-partner-avatar { position: relative; flex-shrink: 0; }
.jsi-chat-partner-avatar img {
    width: 42px; height: 42px; border-radius: 50%;
    object-fit: cover; display: block; background: #1f1b3a;
    border: 2px solid rgba(124,58,237,.4);
}
.jsi-status-dot {
    position: absolute; bottom: 1px; right: 1px;
    width: 10px; height: 10px; border-radius: 50%;
    background: #4b5563; border: 2px solid #12082a;
}
.jsi-status-dot.online { background: #22c55e; }

.jsi-chat-partner-meta { min-width: 0; }
.jsi-chat-partner-name {
    font-size: 16px; font-weight: 600; color: #e9edef;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.jsi-chat-partner-status { font-size: 12px; color: #6b7280; }
.jsi-chat-partner-status.online { color: #22c55e; }

.jsi-chat-header-actions {
    display: flex; gap: 2px; align-items: center;
    margin-left: auto; flex-shrink: 0;
}

/* ── Dropdown menu ──────────────────────────────────────────────── */
.jsi-chat-dropdown-menu {
    position: absolute; top: 62px; right: 8px;
    background: #12082a;
    border: 1px solid rgba(124,58,237,.25);
    border-radius: 14px; padding: 6px 0;
    min-width: 210px; z-index: 200;
    box-shadow: 0 8px 32px rgba(0,0,0,.6);
    display: none;
}
.jsi-chat-dropdown-menu.open { display: block; }
.jsi-chat-dropdown-menu button {
    display: flex; align-items: center; gap: 12px;
    width: 100%; background: none; border: none;
    color: #e9edef; font-size: 14px;
    padding: 11px 18px; cursor: pointer;
    text-align: left; transition: background .12s; line-height: 1;
    font-family: inherit;
}
.jsi-chat-dropdown-menu button svg { flex-shrink: 0; color: #9f67ff; }
.jsi-chat-dropdown-menu button:hover { background: rgba(124,58,237,.12); }
.jsi-chat-dropdown-menu button.jsi-danger { color: #ef4444; }
.jsi-chat-dropdown-menu button.jsi-danger svg { color: #ef4444; }

/* ── In-chat search bar ─────────────────────────────────────────── */
.jsi-in-chat-search {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 14px;
    background: #12082a;
    border-bottom: 1px solid rgba(124,58,237,.15);
    flex-shrink: 0;
}
.jsi-in-chat-search input {
    flex: 1; background: #1f1b3a;
    border: 1px solid rgba(124,58,237,.25);
    border-radius: 8px; padding: 8px 12px;
    color: #e9edef; font-size: 14px; outline: none;
}
.jsi-in-chat-search input::placeholder { color: #6b7280; }
.jsi-in-chat-search button {
    background: linear-gradient(135deg,#7c3aed,#9f67ff);
    border: none; border-radius: 8px; color: #fff;
    font-size: 13px; font-weight: 600; padding: 7px 14px; cursor: pointer;
    font-family: inherit;
}

/* ── SCROLLABLE Messages area ───────────────────────────────────── */
.jsi-messages-container {
    flex: 1; overflow-y: auto;
    padding: 16px 8%; display: flex;
    flex-direction: column; gap: 2px;
    scrollbar-width: thin;
    scrollbar-color: rgba(124,58,237,.25) transparent;
    /* flex: 1 means it fills the space between sticky header and sticky input */
}
.jsi-messages-container::-webkit-scrollbar { width: 5px; }
.jsi-messages-container::-webkit-scrollbar-thumb { background: rgba(124,58,237,.25); border-radius: 4px; }

.jsi-chat-no-messages {
    text-align: center; padding: 40px 20px;
    color: #6b7280; font-size: 14px;
}

/* Date separator */
.jsi-date-separator {
    display: flex; align-items: center;
    justify-content: center; margin: 10px 0;
}
.jsi-date-separator span {
    background: rgba(7,7,13,.9);
    color: #9ca3af; font-size: 11.5px; font-weight: 500;
    padding: 5px 14px; border-radius: 100px;
    border: 1px solid rgba(124,58,237,.15);
}

/* Message row */
.jsi-msg-row {
    display: flex; align-items: flex-end; gap: 6px;
    max-width: 75%; position: relative;
}
.jsi-msg-row + .jsi-msg-row { margin-top: 2px; }
.jsi-msg-out { align-self: flex-end; flex-direction: row-reverse; }
.jsi-msg-in  { align-self: flex-start; }

.jsi-msg-avatar-wrap { flex-shrink: 0; }
.jsi-msg-avatar {
    width: 28px; height: 28px; border-radius: 50%;
    object-fit: cover; background: #1f1b3a; display: block;
}
.jsi-msg-out .jsi-msg-avatar-wrap { display: none; }

.jsi-msg-bubble-wrap { display: flex; flex-direction: column; max-width: 100%; }
.jsi-msg-sender-name {
    font-size: 11.5px; font-weight: 600;
    color: #a78bfa; margin-bottom: 2px; padding-left: 2px;
}

/* Bubble */
.jsi-msg-bubble {
    padding: 7px 10px 8px; border-radius: 12px;
    position: relative; word-wrap: break-word;
    min-width: 80px; max-width: 100%;
    box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
.jsi-msg-in .jsi-msg-bubble {
    background: #12082a;
    border: 1px solid rgba(124,58,237,.15);
    border-top-left-radius: 2px;
}
.jsi-msg-out .jsi-msg-bubble {
    background: linear-gradient(135deg,#5b21b6,#7c3aed);
    border-top-right-radius: 2px;
}

/* Bubble tails */
.jsi-msg-in .jsi-msg-bubble::before {
    content: ''; position: absolute; top: 0; left: -7px;
    border: 7px solid transparent;
    border-top-color: #12082a; border-right: none; border-left: none;
    width: 0; height: 0;
}
.jsi-msg-out .jsi-msg-bubble::before {
    content: ''; position: absolute; top: 0; right: -7px;
    border: 7px solid transparent;
    border-top-color: #7c3aed; border-left: none; border-right: none;
    width: 0; height: 0;
}

.jsi-msg-text { font-size: 14.5px; line-height: 1.5; color: #e9edef; white-space: pre-wrap; }
.jsi-msg-caption { font-size: 13.5px; color: #e9edef; margin-top: 5px; line-height: 1.4; }

.jsi-msg-meta {
    display: flex; align-items: center;
    justify-content: flex-end; gap: 4px; margin-top: 2px;
}
.jsi-msg-time { font-size: 10.5px; color: rgba(156,163,175,.7); white-space: nowrap; }
.jsi-msg-read { font-size: 12px; color: #9ca3af; line-height: 1; }
.jsi-msg-read.read { color: #a78bfa; }

/* Reply quote */
.jsi-msg-reply-quote {
    background: rgba(0,0,0,.25);
    border-left: 3px solid #7c3aed;
    border-radius: 4px; padding: 4px 8px; margin-bottom: 6px; font-size: 13px;
}
.jsi-msg-reply-quote strong { display: block; color: #a78bfa; font-size: 11.5px; margin-bottom: 2px; }
.jsi-msg-reply-quote span {
    color: #9ca3af; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; display: block; max-width: 250px;
}

/* Attachments */
.jsi-msg-img {
    max-width: 280px; max-height: 280px; border-radius: 8px;
    display: block; object-fit: cover; cursor: pointer; transition: opacity .15s;
}
.jsi-msg-img:hover { opacity: .9; }
.jsi-msg-video { max-width: 280px; max-height: 200px; border-radius: 8px; display: block; background: #000; }
.jsi-msg-audio { width: 240px; height: 36px; filter: invert(1) hue-rotate(240deg); border-radius: 100px; }

.jsi-file-bubble {
    display: flex; align-items: center; gap: 10px;
    background: rgba(0,0,0,.3); border-radius: 10px;
    padding: 10px 12px; min-width: 200px;
    text-decoration: none; color: inherit;
    border: 1px solid rgba(124,58,237,.15);
    transition: background .12s;
}
.jsi-file-bubble:hover { background: rgba(124,58,237,.15); }
.jsi-file-icon { font-size: 26px; flex-shrink: 0; }
.jsi-file-bubble div strong {
    display: block; font-size: 13px; color: #e9edef;
    font-weight: 500; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; max-width: 170px;
}
.jsi-file-bubble div small { font-size: 11px; color: #9ca3af; }

.jsi-location-bubble {
    display: flex; flex-direction: column; gap: 2px;
    color: #a78bfa; font-size: 14px; text-decoration: none; padding: 4px 0;
}
.jsi-location-bubble strong { color: #e9edef; font-size: 14px; }
.jsi-location-bubble small { color: #9ca3af; font-size: 11px; }

.jsi-voice-note {
    display: flex; align-items: center; gap: 8px;
    min-width: 200px; padding: 4px 0;
}
.jsi-voice-icon { font-size: 20px; flex-shrink: 0; }
.jsi-voice-note audio { flex: 1; height: 32px; filter: invert(1) hue-rotate(240deg); }

/* Hover actions */
.jsi-msg-actions {
    display: none; position: absolute; top: 50%; transform: translateY(-50%);
    gap: 2px; background: #12082a;
    border: 1px solid rgba(124,58,237,.2);
    border-radius: 8px; padding: 3px 5px;
    box-shadow: 0 4px 16px rgba(0,0,0,.5); z-index: 10;
}
.jsi-msg-out .jsi-msg-actions { right: calc(100% + 10px); }
.jsi-msg-in  .jsi-msg-actions { left: calc(100% + 10px); }
.jsi-msg-row:hover .jsi-msg-actions { display: flex; }
.jsi-msg-reply-btn, .jsi-msg-delete-btn {
    background: none; border: none; color: #9ca3af;
    font-size: 15px; cursor: pointer;
    padding: 4px 6px; border-radius: 5px; line-height: 1;
    transition: color .12s, background .12s;
}
.jsi-msg-reply-btn:hover { color: #a78bfa; background: rgba(124,58,237,.15); }
.jsi-msg-delete-btn:hover { color: #ef4444; background: rgba(239,68,68,.1); }

/* ================================================================
   STICKY INPUT BAR
   ================================================================ */

/* Reply preview */
.jsi-reply-preview {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 16px;
    background: #0e0e1f;
    border-top: 1px solid rgba(124,58,237,.15);
    flex-shrink: 0; gap: 10px;
}
.jsi-reply-preview-inner { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.jsi-reply-label { font-size: 12px; color: #9f67ff; font-weight: 600; }
.jsi-reply-text {
    font-size: 13px; color: #9ca3af;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 280px; display: block;
}
.jsi-reply-preview > button {
    background: none; border: none; color: #9ca3af;
    font-size: 18px; cursor: pointer; flex-shrink: 0; line-height: 1;
}
.jsi-reply-preview > button:hover { color: #e9edef; }

/* Attachment staging */
.jsi-attachment-staging {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 16px;
    background: #0e0e1f;
    border-top: 1px solid rgba(124,58,237,.15);
    flex-shrink: 0;
}
.jsi-attachment-staging-inner {
    flex: 1; display: flex; align-items: center; gap: 10px;
    font-size: 13px; color: #9ca3af;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.jsi-attachment-staging-inner img {
    height: 52px; width: 52px; object-fit: cover;
    border-radius: 8px; flex-shrink: 0;
    border: 1px solid rgba(124,58,237,.3);
}
.jsi-attach-name {
    white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; max-width: 220px;
}

/* ── Main input bar — STICKY to bottom ─────────────────────────── */
.jsi-chat-input-bar {
    display: flex; align-items: flex-end; gap: 6px;
    padding: 10px 12px;
    background: linear-gradient(135deg, #12082a, #0e0e1f);
    border-top: 1px solid rgba(124,58,237,.2);
    flex-shrink: 0;
    position: sticky; bottom: 0; z-index: 15;
}

/* Attach popup */
.jsi-attach-menu-wrap { position: relative; }
.jsi-attach-menu {
    position: absolute; bottom: 56px; left: 0;
    background: #12082a;
    border: 1px solid rgba(124,58,237,.25);
    border-radius: 16px; padding: 12px;
    display: none; grid-template-columns: repeat(3, 1fr);
    gap: 8px; box-shadow: 0 12px 40px rgba(0,0,0,.65);
    z-index: 100; min-width: 220px;
}
.jsi-attach-menu.open { display: grid; }
.jsi-attach-option {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    background: rgba(124,58,237,.1);
    border: 1px solid rgba(124,58,237,.2);
    border-radius: 12px; padding: 12px 8px;
    color: #e9edef; font-size: 11.5px; cursor: pointer;
    transition: background .12s; text-align: center; font-family: inherit;
}
.jsi-attach-option:hover { background: rgba(124,58,237,.2); }
.jsi-attach-option svg { color: #9f67ff; }

/* Text input */
.jsi-msg-input-wrap {
    flex: 1; background: #1f1b3a;
    border: 1px solid rgba(124,58,237,.25);
    border-radius: 22px; display: flex;
    align-items: center; padding: 10px 14px;
    min-height: 44px; max-height: 120px; gap: 8px;
    transition: border-color .2s;
}
.jsi-msg-input-wrap:focus-within { border-color: #7c3aed; }
#jsi-msg-input {
    flex: 1; background: transparent; border: none; outline: none;
    color: #e9edef; font-size: 15px; line-height: 1.45;
    resize: none; max-height: 100px; overflow-y: auto;
    scrollbar-width: none; font-family: inherit;
}
#jsi-msg-input::placeholder { color: #6b7280; }
#jsi-msg-input::-webkit-scrollbar { display: none; }

.jsi-emoji-btn {
    color: #6b7280; font-size: 20px; background: none;
    border: none; cursor: pointer; padding: 0; flex-shrink: 0; line-height: 1;
    transition: color .15s;
}
.jsi-emoji-btn:hover { color: #9f67ff; }

/* Send / Voice */
.jsi-send-area { flex-shrink: 0; }
.jsi-voice-btn, .jsi-send-btn {
    width: 46px; height: 46px; border-radius: 50%;
    background: linear-gradient(135deg,#7c3aed,#9f67ff);
    border: none; color: #fff; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: transform .15s, box-shadow .15s;
    box-shadow: 0 4px 16px rgba(124,58,237,.5);
}
.jsi-voice-btn:hover, .jsi-send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(124,58,237,.7);
}
.jsi-voice-btn.recording { background: #ef4444; animation: jsiPulse 1s infinite; }

@keyframes jsiPulse {
    0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,.4); }
    50% { box-shadow: 0 0 0 10px rgba(239,68,68,0); }
}

/* Voice recording bar */
.jsi-voice-recording-bar {
    position: absolute; bottom: 70px; left: 0; right: 0;
    display: flex; align-items: center; gap: 12px;
    padding: 12px 20px;
    background: #12082a;
    border-top: 1px solid rgba(124,58,237,.2); z-index: 50;
}
.jsi-voice-pulse {
    width: 10px; height: 10px; background: #ef4444;
    border-radius: 50%; animation: jsiPulse 1s infinite; flex-shrink: 0;
}
.jsi-voice-recording-bar span { flex: 1; font-size: 14px; color: #e9edef; }
.jsi-voice-recording-bar button {
    background: none;
    border: 1px solid rgba(124,58,237,.3);
    color: #9ca3af; border-radius: 6px;
    padding: 5px 12px; font-size: 13px; cursor: pointer; font-family: inherit;
}
.jsi-voice-recording-bar button:hover { color: #e9edef; border-color: #7c3aed; }

/* ================================================================
   SHARED ICON BUTTON
   ================================================================ */
.jsi-icon-btn {
    background: none; border: none; color: #9ca3af; cursor: pointer;
    width: 40px; height: 40px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: background .12s, color .12s; flex-shrink: 0;
}
.jsi-icon-btn:hover { background: rgba(124,58,237,.15); color: #a78bfa; }

/* ================================================================
   MODALS
   ================================================================ */
.jsi-modal-overlay {
    position: absolute; inset: 0;
    background: rgba(0,0,0,.7); z-index: 300;
    display: flex; align-items: center; justify-content: center;
    padding: 20px; backdrop-filter: blur(6px);
}
.jsi-modal {
    background: #12082a;
    border: 1px solid rgba(124,58,237,.25);
    border-radius: 20px; width: 100%;
    max-width: 460px; max-height: 82vh; overflow: hidden;
    display: flex; flex-direction: column;
    box-shadow: 0 24px 64px rgba(0,0,0,.7);
}
.jsi-modal-sm { max-width: 340px; }
.jsi-modal-header {
    display: flex; align-items: center;
    justify-content: space-between;
    padding: 18px 22px 14px;
    border-bottom: 1px solid rgba(124,58,237,.15);
}
.jsi-modal-header h3 { font-size: 17px; font-weight: 700; color: #e9edef; }
.jsi-modal-header > button {
    background: none; border: none; color: #6b7280;
    font-size: 20px; cursor: pointer; line-height: 1;
    transition: color .12s; width: 32px; height: 32px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
}
.jsi-modal-header > button:hover { color: #e9edef; background: rgba(124,58,237,.15); }
.jsi-modal-body {
    padding: 18px 22px; overflow-y: auto; flex: 1;
    display: flex; flex-direction: column; gap: 14px;
}
.jsi-modal-footer {
    display: flex; justify-content: flex-end; gap: 10px;
    padding: 14px 22px;
    border-top: 1px solid rgba(124,58,237,.15);
}

/* Form groups */
.jsi-form-group { display: flex; flex-direction: column; gap: 6px; }
.jsi-form-group label { font-size: 13px; color: #9ca3af; font-weight: 500; }
.jsi-form-group input, .jsi-form-group select, .jsi-form-group textarea {
    background: #1f1b3a;
    border: 1px solid rgba(124,58,237,.2);
    border-radius: 10px; padding: 10px 12px;
    color: #e9edef; font-size: 14px; outline: none;
    transition: border-color .15s; font-family: inherit; resize: none;
}
.jsi-form-group input:focus,
.jsi-form-group textarea:focus { border-color: #7c3aed; }
.jsi-form-group input::placeholder,
.jsi-form-group textarea::placeholder { color: #6b7280; }
.jsi-form-group select { cursor: pointer; }
.jsi-form-group select option { background: #1f1b3a; }

/* User search results */
.jsi-user-search-results, #jsi-new-chat-results {
    display: flex; flex-direction: column; gap: 2px;
    margin-top: 6px; max-height: 240px; overflow-y: auto;
    scrollbar-width: thin; scrollbar-color: rgba(124,58,237,.2) transparent;
}
.jsi-user-result-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px; border-radius: 10px;
    cursor: pointer; transition: background .12s;
}
.jsi-user-result-item:hover { background: rgba(124,58,237,.12); }
.jsi-user-result-item img {
    width: 38px; height: 38px; border-radius: 50%;
    object-fit: cover; background: #1f1b3a; flex-shrink: 0;
    border: 1px solid rgba(124,58,237,.2);
}
.jsi-user-result-item div strong { display: block; font-size: 14px; color: #e9edef; font-weight: 500; }
.jsi-user-result-item div small { font-size: 12px; color: #9ca3af; }
.jsi-no-results { font-size: 13px; color: #6b7280; padding: 10px; text-align: center; }

/* Selected members chips */
.jsi-selected-members { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.jsi-selected-member {
    display: flex; align-items: center; gap: 5px;
    background: linear-gradient(135deg,#7c3aed,#9f67ff);
    color: #fff; border-radius: 100px;
    padding: 3px 10px 3px 4px; font-size: 12px; font-weight: 500;
}
.jsi-selected-member img { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; }
.jsi-selected-member button {
    background: none; border: none; color: #fff;
    font-size: 14px; cursor: pointer; padding: 0; opacity: .75; line-height: 1;
}
.jsi-selected-member button:hover { opacity: 1; }

/* Buttons */
.jsi-btn-primary {
    background: linear-gradient(135deg,#7c3aed,#9f67ff);
    border: none; border-radius: 10px; color: #fff;
    font-size: 14px; font-weight: 600; padding: 9px 20px;
    cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
    font-family: inherit; transition: transform .15s, box-shadow .15s;
    box-shadow: 0 4px 16px rgba(124,58,237,.4);
}
.jsi-btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 24px rgba(124,58,237,.55); }
.jsi-btn-secondary {
    background: rgba(124,58,237,.12);
    border: 1px solid rgba(124,58,237,.25);
    border-radius: 10px; color: #e9edef;
    font-size: 14px; font-weight: 500; padding: 9px 20px;
    cursor: pointer; font-family: inherit; transition: background .15s;
}
.jsi-btn-secondary:hover { background: rgba(124,58,237,.2); }
.jsi-btn-danger {
    background: #ef4444; border: none; border-radius: 10px;
    color: #fff; font-size: 14px; font-weight: 600; padding: 9px 20px;
    cursor: pointer; font-family: inherit; transition: background .15s;
}
.jsi-btn-danger:hover { background: #dc2626; }

/* Toast */
.jsi-chat-toast {
    position: absolute; bottom: 80px; left: 50%;
    transform: translateX(-50%) translateY(16px);
    background: #12082a;
    border: 1px solid rgba(124,58,237,.3);
    color: #e9edef; font-size: 13px;
    padding: 8px 18px; border-radius: 100px;
    opacity: 0; pointer-events: none;
    transition: opacity .25s, transform .25s;
    z-index: 400; white-space: nowrap;
}
.jsi-chat-toast.visible {
    opacity: 1; transform: translateX(-50%) translateY(0);
}

/* ================================================================
   MOBILE RESPONSIVE
   ================================================================ */
@media (max-width: 720px) {
    .jsi-chat-app {
        height: calc(100vh - 70px - 82px);
        border-radius: 0;
    }

    .jsi-chat-sidebar {
        position: absolute; inset: 0;
        width: 100%; max-width: 100%;
        z-index: 10; border-right: none;
        transition: transform .25s ease;
    }
    .jsi-chat-sidebar.jsi-sidebar-hidden { transform: translateX(-100%); }

    .jsi-chat-main { position: absolute; inset: 0; width: 100%; z-index: 5; }
    .jsi-chat-main.jsi-main-visible { z-index: 15; }

    .jsi-chat-back-btn { display: flex !important; }
    .jsi-messages-container { padding: 12px 3%; }
    .jsi-msg-row { max-width: 90%; }
    .jsi-chat-dropdown-menu { right: 0; }
    .jsi-msg-img, .jsi-msg-video { max-width: 240px; }
    .jsi-attach-menu { min-width: 190px; }
    .jsi-conv-name { max-width: 150px; }

    /* Show the floating search FAB on mobile sidebar */
    .jsi-chat-search-fab { display: flex !important; }
}

@media (max-width: 420px) {
    .jsi-msg-input-wrap { border-radius: 18px; }
    .jsi-attach-menu { grid-template-columns: repeat(2, 1fr); }
}