/* ═══════════════════════════════════════════════════
   CualityX Mensajes – WhatsApp Web Dark Mode Theme
   ═══════════════════════════════════════════════════ */

/* ── Variables ── */
.cx-msg-shell {
    --wa-bg-deep: #0b141a;
    --wa-bg-panel: #111b21;
    --wa-bg-header: #202c33;
    --wa-bg-input: #2a3942;
    --wa-bg-bubble-me: #005c4b;
    --wa-bg-bubble-other: #202c33;
    --wa-bg-hover: #202c33;
    --wa-bg-active: #2a3942;
    --wa-border: #222d34;
    --wa-border-light: #313d45;
    --wa-text-primary: #e9edef;
    --wa-text-secondary: #8696a0;
    --wa-text-bubble: #e9edef;
    --wa-accent: #00a884;
    --wa-accent-hover: #06cf9c;
    --wa-blue: #53bdeb;
    --wa-unread: #00a884;
    --wa-danger: #ea0038;
    --wa-icon: #aebac1;
    --wa-icon-hover: #e9edef;
    --wa-nav-width: 48px;
    --wa-sidebar-width: 25%;

    display: grid;
    grid-template-columns: var(--wa-nav-width) var(--wa-sidebar-width) auto 1fr;
    height: 100%;
    background: var(--wa-bg-deep);
    color: var(--wa-text-primary);
    overflow: hidden;
    font-family: 'Segoe UI', Helvetica, Arial, sans-serif;
    font-size: 14.2px;
    line-height: 1.35;
}

/* When contact panel is open, add 5th column */
.cx-msg-shell.panel-open {
    grid-template-columns: var(--wa-nav-width) var(--wa-sidebar-width) auto 1fr 340px;
}

/* ── Draggable Resize Handle ── */
.cx-msg-resize-handle {
    width: 4px;
    cursor: col-resize;
    background: transparent;
    transition: background .15s;
    z-index: 5;
    position: relative;
}

.cx-msg-resize-handle:hover,
.cx-msg-resize-handle.dragging {
    background: var(--wa-accent);
}

.cx-msg-resize-handle::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -3px;
    right: -3px;
}

/* ── Left Icon Nav Bar ── */
.cx-msg-nav {
    background: var(--wa-bg-panel);
    border-right: 1px solid var(--wa-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 0;
    gap: 2px;
    z-index: 3;
}

.cx-msg-nav-item {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    cursor: pointer;
    color: var(--wa-icon);
    background: transparent;
    border: none;
    transition: background .15s, color .15s;
    font-size: 17px;
}

.cx-msg-nav-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--wa-icon-hover);
}

.cx-msg-nav-item.active {
    background: rgba(0, 168, 132, 0.15);
    color: var(--wa-accent);
}

.cx-msg-nav-spacer {
    flex: 1;
}

.cx-msg-nav-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    overflow: hidden;
    cursor: pointer;
    margin-top: 4px;
    background: var(--wa-bg-input);
}

.cx-msg-nav-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ── Sidebar ── */
.cx-msg-sidebar {
    background: var(--wa-bg-panel);
    border-right: 1px solid var(--wa-border);
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.cx-msg-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    min-height: 44px;
    background: var(--wa-bg-header);
}

.cx-msg-brand-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--wa-bg-input);
    color: var(--wa-text-primary);
    font-weight: 700;
    display: grid;
    place-items: center;
    font-size: 14px;
    overflow: hidden;
}

.cx-msg-brand-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cx-msg-subtitle {
    font-size: 11px;
    color: var(--wa-text-secondary);
}

.cx-msg-actions {
    display: flex;
    align-items: center;
    gap: 0;
}

/* Buttons */
.cx-msg-btn {
    appearance: none;
    border: none;
    background: transparent;
    color: var(--wa-icon);
    border-radius: 50%;
    padding: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: background .15s, color .15s, transform .15s, box-shadow .15s;
    white-space: nowrap;
}

.cx-msg-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--wa-icon-hover);
    transform: translateY(-1px);
}

.cx-msg-btn:active {
    transform: scale(0.96);
}

.cx-msg-btn.primary {
    background: var(--wa-accent);
    color: #111b21;
    border-radius: 24px;
    padding: 10px 24px;
    font-weight: 700;
    font-size: 14px;
}

.cx-msg-btn.primary:hover {
    background: var(--wa-accent-hover);
}

.cx-msg-btn.secondary {
    background: transparent;
    color: var(--wa-text-secondary);
    border: 1px solid var(--wa-border);
    border-radius: 24px;
    padding: 10px 24px;
    font-size: 14px;
}

.cx-msg-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--wa-text-primary);
}

/* Request bell */
.cx-msg-request-wrap {
    padding: 0 10px 2px;
}

.cx-msg-requests-bell {
    width: 100%;
    border: 1px solid var(--wa-border);
    background: rgba(0, 168, 132, 0.06);
    color: var(--wa-text-primary);
    border-radius: 8px;
    padding: 5px 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 12px;
    transition: background .15s;
}

.cx-msg-requests-bell:hover {
    background: rgba(0, 168, 132, 0.12);
}

.cx-msg-requests-icon {
    width: 18px;
    text-align: center;
    font-size: 14px;
}

.cx-msg-requests-badge {
    margin-left: auto;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 10px;
    font-weight: 800;
    background: var(--wa-bg-input);
    color: var(--wa-text-secondary);
}

.cx-msg-requests-bell.has-pending {
    border-color: var(--wa-accent);
    background: rgba(0, 168, 132, 0.14);
}

.cx-msg-requests-bell.has-pending .cx-msg-requests-badge {
    background: var(--wa-accent);
    color: #111b21;
}

/* Search */
.cx-msg-search-wrap {
    padding: 3px 10px 3px;
}

.cx-msg-search-wrap input {
    width: 100%;
    border: none;
    background: var(--wa-bg-input);
    color: var(--wa-text-primary);
    border-radius: 8px;
    padding: 5px 10px 5px 28px;
    outline: none;
    font-size: 13px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='13' height='13' fill='%238696a0' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242.656a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 8px center;
    background-size: 13px;
}

.cx-msg-search-wrap input::placeholder {
    color: var(--wa-text-secondary);
    font-size: 12.5px;
}

/* Tabs */
.cx-msg-tabs {
    display: flex;
    gap: 4px;
    padding: 2px 10px 4px;
}

.cx-msg-tab {
    border: none;
    background: rgba(255, 255, 255, 0.05);
    color: var(--wa-text-secondary);
    border-radius: 16px;
    padding: 3px 11px;
    font-size: 12px;
    cursor: pointer;
    transition: all .15s;
    font-weight: 500;
}

.cx-msg-tab:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--wa-text-primary);
}

.cx-msg-tab.active {
    color: #111b21;
    background: var(--wa-accent);
    font-weight: 700;
}

/* Chat list */
.cx-msg-list {
    overflow-y: auto;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}

.cx-msg-list::-webkit-scrollbar {
    width: 6px;
}

.cx-msg-list::-webkit-scrollbar-track {
    background: transparent;
}

.cx-msg-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 3px;
}

/* ── Chat items (compact like WhatsApp) ── */
.cx-msg-item {
    border: none;
    border-radius: 0;
    padding: 6px 12px;
    display: grid;
    grid-template-columns: 42px 1fr auto;
    gap: 8px;
    align-items: center;
    cursor: pointer;
    background: transparent;
    transition: background .14s, transform .18s, box-shadow .18s;
    position: relative;
    min-height: 0;
}

.cx-msg-item:not(:last-child)::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 62px;
    right: 12px;
    height: 1px;
    background: rgba(134, 150, 160, 0.08);
}

.cx-msg-item:hover {
    background: var(--wa-bg-hover);
    transform: translateX(2px);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.cx-msg-item.active {
    background: var(--wa-bg-active);
    transform: translateX(1px);
}

.cx-msg-item-arrow {
    display: none;
    position: absolute;
    right: 8px;
    top: 8px;
    color: var(--wa-icon);
    font-size: 12px;
    cursor: pointer;
    background: var(--wa-bg-hover);
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.cx-msg-item:hover .cx-msg-item-arrow {
    display: flex;
}

/* Avatar */
.cx-msg-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--wa-bg-input);
    display: grid;
    place-items: center;
    font-weight: 700;
    overflow: hidden;
    font-size: 15px;
    color: var(--wa-text-secondary);
    flex-shrink: 0;
}

.cx-msg-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 50%;
}

.cx-msg-item-title {
    font-weight: 500;
    font-size: 14.5px;
    color: var(--wa-text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cx-msg-item-sub {
    font-size: 12.5px;
    color: var(--wa-text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 3px;
    margin-top: -1px;
}

.cx-msg-item-sub svg {
    flex-shrink: 0;
}

.cx-msg-item-time {
    font-size: 11px;
    color: var(--wa-text-secondary);
    white-space: nowrap;
}

.cx-msg-item.has-unread .cx-msg-item-time {
    color: var(--wa-accent);
}

.cx-msg-badge {
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 10.5px;
    font-weight: 700;
    background: var(--wa-unread);
    color: #111b21;
    margin-left: auto;
}

/* ── Main chat area ── */
.cx-msg-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background: var(--wa-bg-deep);
}

.cx-msg-chat-header {
    border-bottom: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 10px;
    background: var(--wa-bg-header);
    min-height: 44px;
    flex-shrink: 0;
}

.cx-msg-chat-user {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    flex: 1;
    min-width: 0;
}

.cx-msg-chat-user .cx-msg-avatar {
    width: 36px;
    height: 36px;
    font-size: 13px;
}

.cx-msg-chat-name {
    font-weight: 500;
    font-size: 15px;
    color: var(--wa-text-primary);
}

.cx-msg-chat-status {
    font-size: 12px;
    color: var(--wa-text-secondary);
}

.cx-msg-chat-tools {
    display: flex;
    align-items: center;
    gap: 0;
}

.cx-msg-tools-row {
    display: flex;
    align-items: center;
    gap: 0;
}

.cx-msg-icon-btn {
    border: none;
    background: transparent;
    color: var(--wa-icon);
    border-radius: 50%;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: background .14s, color .14s, transform .14s, box-shadow .14s;
    font-size: 16px;
    padding: 0;
}

.cx-msg-icon-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--wa-icon-hover);
    transform: translateY(-1px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.22);
}

.cx-msg-icon-btn:active {
    transform: scale(0.93);
}

/* Empty */
.cx-msg-empty {
    display: grid;
    place-content: center;
    text-align: center;
    gap: 10px;
    color: var(--wa-text-secondary);
    flex: 1;
}

.cx-msg-empty-icon {
    font-size: 64px;
    opacity: 0.5;
}

.cx-msg-empty h3 {
    font-size: 24px;
    font-weight: 300;
    color: var(--wa-text-primary);
}

.cx-msg-empty p {
    font-size: 13px;
    color: var(--wa-text-secondary);
    max-width: 420px;
}

/* ── Timeline ── */
.cx-msg-timeline {
    overflow-y: auto;
    padding: 8px 50px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
    min-height: 0;
    position: relative;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
    background-color: #0b141a;
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='250' height='250' opacity='0.025'%3E%3Cdefs%3E%3Cstyle%3E.a%7Bfill:%23fff%7D%3C/style%3E%3C/defs%3E%3Ccircle class='a' cx='20' cy='20' r='2'/%3E%3Ccircle class='a' cx='100' cy='40' r='1.5'/%3E%3Ccircle class='a' cx='60' cy='80' r='1.8'/%3E%3Ccircle class='a' cx='150' cy='60' r='1.2'/%3E%3Ccircle class='a' cx='40' cy='140' r='2'/%3E%3Ccircle class='a' cx='120' cy='120' r='1.4'/%3E%3Ccircle class='a' cx='200' cy='150' r='1.6'/%3E%3Ccircle class='a' cx='80' cy='180' r='1.3'/%3E%3Ccircle class='a' cx='180' cy='210' r='1.7'/%3E%3Ccircle class='a' cx='220' cy='30' r='1.1'/%3E%3Ccircle class='a' cx='170' cy='100' r='1.5'/%3E%3Ccircle class='a' cx='30' cy='220' r='1.4'/%3E%3C/svg%3E");
}

.cx-msg-timeline::-webkit-scrollbar {
    width: 6px;
}

.cx-msg-timeline::-webkit-scrollbar-track {
    background: transparent;
}

.cx-msg-timeline::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

/* Date separator */
.cx-msg-date-sep {
    text-align: center;
    padding: 6px 0;
}

.cx-msg-date-sep span {
    background: #182229;
    color: var(--wa-text-secondary);
    font-size: 11.5px;
    padding: 4px 12px;
    border-radius: 8px;
    display: inline-block;
    box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
}

/* Message rows */
.cx-msg-row {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    animation: none;
    position: relative;
    padding: 1px 0;
}

.cx-msg-row.me {
    justify-content: flex-end;
}

/* Hover emoji reaction button */
.cx-msg-row-emoji {
    background: none;
    border: none;
    color: var(--wa-text-secondary);
    cursor: pointer;
    padding: 2px;
    border-radius: 50%;
    opacity: 0;
    transition: opacity .15s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    margin-bottom: 4px;
    order: 1;
    /* Default: right side of bubble (for received msgs) */
}

.cx-msg-row:hover .cx-msg-row-emoji {
    opacity: .6;
}

.cx-msg-row-emoji:hover {
    opacity: 1 !important;
    background: rgba(255, 255, 255, .08);
}

/* For 'me' messages, emoji goes to the left of the bubble */
.cx-msg-row.me .cx-msg-row-emoji {
    order: -1;
}

/* Bubbles */
.cx-msg-bubble {
    max-width: min(60ch, 65%);
    border-radius: 8px;
    padding: 4px 7px 3px 9px;
    border: none;
    background: var(--wa-bg-bubble-other);
    position: relative;
    box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
    color: var(--wa-text-bubble);
    font-size: 14.2px;
    line-height: 1.35;
    word-wrap: break-word;
}

.cx-msg-bubble-menu {
    position: absolute;
    top: 3px;
    right: 3px;
    border: none;
    background: linear-gradient(180deg, var(--wa-bg-bubble-other) 60%, transparent);
    color: var(--wa-icon);
    width: 22px;
    height: 18px;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition: opacity .12s;
    display: grid;
    place-items: center;
    font-size: 11px;
    z-index: 2;
    padding: 0;
}

.cx-msg-row:hover .cx-msg-bubble-menu,
.cx-msg-bubble-menu:focus {
    opacity: 1;
}

.cx-msg-row.me .cx-msg-bubble-menu {
    background: linear-gradient(180deg, var(--wa-bg-bubble-me) 60%, transparent);
}

.cx-msg-row.me .cx-msg-bubble {
    background: var(--wa-bg-bubble-me);
}

/* Bubble tails */
.cx-msg-row:not(.me) .cx-msg-bubble::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 8px 10px 0;
    border-color: transparent var(--wa-bg-bubble-other) transparent transparent;
}

.cx-msg-row.me .cx-msg-bubble::before {
    content: '';
    position: absolute;
    right: -8px;
    top: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 0 10px 8px;
    border-color: transparent transparent transparent var(--wa-bg-bubble-me);
}

/* Message meta */
.cx-msg-meta {
    margin-top: 0;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.45);
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 3px;
    float: right;
    margin-left: 8px;
    position: relative;
    top: 4px;
}

.cx-msg-row.me .cx-msg-meta {
    color: rgba(255, 255, 255, 0.5);
}

.cx-msg-status-wrap {
    display: inline-flex;
    align-items: center;
    margin-left: 1px;
}

.cx-msg-status {
    letter-spacing: -1px;
    font-weight: 800;
    font-size: 14px;
}

.cx-msg-status-sending {
    opacity: 0.5;
    animation: cx-msg-spin-soft 1s linear infinite;
}

.cx-msg-status-sent,
.cx-msg-status-delivered {
    color: rgba(255, 255, 255, 0.5);
}

.cx-msg-status-read {
    color: var(--wa-blue);
}

.cx-msg-status-failed {
    color: var(--wa-danger);
}

@keyframes cx-msg-spin-soft {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Attachment */
.cx-msg-attachment {
    margin: 4px -3px;
    border-radius: 8px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.15);
}

.cx-msg-attachment img {
    max-width: 330px;
    max-height: 280px;
    border-radius: 6px;
    display: block;
}

/* Reply bar */
.cx-msg-reply {
    border-top: none;
    background: var(--wa-bg-header);
    padding: 6px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-left: 4px solid var(--wa-accent);
    margin: 0 10px;
    border-radius: 6px;
    flex-shrink: 0;
}

.cx-msg-reply-preview {
    color: var(--wa-text-secondary);
    font-size: 12.5px;
}

/* ── Composer ── */
.cx-msg-composer-wrap {
    border-top: none;
    padding: 4px 8px 5px;
    position: relative;
    background: var(--wa-bg-header);
    z-index: 2;
    display: flex;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.cx-msg-composer {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    flex: 1;
}

.cx-msg-composer textarea {
    flex: 1;
    min-height: 36px;
    max-height: 100px;
    resize: none;
    padding: 7px 12px;
    border: none;
    background: var(--wa-bg-input);
    color: var(--wa-text-primary);
    border-radius: 8px;
    outline: none;
    font-size: 14.5px;
    font-family: inherit;
    line-height: 1.35;
    scrollbar-width: thin;
}

.cx-msg-composer textarea::placeholder {
    color: var(--wa-text-secondary);
}

.cx-msg-send {
    border: none;
    border-radius: 50%;
    font-weight: 700;
    background: var(--wa-accent);
    color: #111b21;
    width: 36px;
    height: 36px;
    min-width: 36px;
    cursor: pointer;
    transition: background .12s, transform .12s;
    display: grid;
    place-items: center;
    font-size: 0;
    padding: 0;
}

.cx-msg-send::after {
    content: '➤';
    font-size: 17px;
}

.cx-msg-send:hover {
    background: var(--wa-accent-hover);
    transform: scale(1.05);
}

.cx-msg-send:active {
    transform: scale(0.94);
}

/* Typing */
.cx-msg-typing {
    min-height: 0;
    font-size: 12px;
    color: var(--wa-text-secondary);
    padding: 0 4px;
    flex-shrink: 0;
}

.cx-msg-typing:not(:empty) {
    min-height: 16px;
    padding: 2px 12px;
}

@keyframes cx-msg-in {
    from {
        opacity: 0;
        transform: translateY(3px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cx-msg-enter-stagger {
    animation: cx-msg-enter-stagger .24s cubic-bezier(0.22, 1, 0.36, 1) both;
    animation-delay: var(--cx-enter-delay, 0ms);
}

@keyframes cx-msg-enter-stagger {
    from {
        opacity: 0;
        transform: translateY(5px) scale(0.992);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.cx-msg-timeline.cx-msg-conv-switch {
    animation: cx-msg-conv-switch .22s ease both;
}

@keyframes cx-msg-conv-switch {
    from {
        opacity: 0.72;
        transform: translateY(4px);
        filter: saturate(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(0);
        filter: saturate(1);
    }
}

/* ── Emoji Picker ── */
.cx-msg-emoji-picker {
    position: absolute;
    left: 8px;
    bottom: 48px;
    padding: 8px;
    border-radius: 12px;
    border: 1px solid var(--wa-border);
    background: var(--wa-bg-header);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    z-index: 10;
}

.cx-msg-emoji-picker button {
    border: none;
    background: transparent;
    color: #fff;
    border-radius: 8px;
    min-width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 18px;
    transition: background .1s;
}

.cx-msg-emoji-picker button:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* ── Reaction Bar (click-only) ── */
.cx-msg-reaction-bar {
    position: absolute;
    top: -44px;
    display: flex;
    gap: 2px;
    background: var(--wa-bg-header);
    border: 1px solid var(--wa-border);
    border-radius: 22px;
    padding: 4px 6px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    z-index: 6;
    animation: cx-msg-reaction-in .15s ease both;
}

.cx-msg-reaction-bar.left-side {
    left: 0;
}

.cx-msg-reaction-bar.right-side {
    right: 0;
}

.cx-msg-reaction-bar button {
    border: none;
    background: transparent;
    font-size: 22px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    transition: background .1s, transform .1s;
}

.cx-msg-reaction-bar button:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.25);
}

.cx-msg-reaction-bar .reaction-plus {
    font-size: 16px;
    color: var(--wa-icon);
}

@keyframes cx-msg-reaction-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cx-msg-reaction-display {
    display: inline-flex;
    align-items: center;
    background: #1f2c34;
    border: 1px solid var(--wa-border);
    border-radius: 12px;
    padding: 2px 6px;
    font-size: 18px;
    margin-top: 2px;
    cursor: pointer;
}

/* ── Context Menu ── */
.cx-msg-ctx-menu {
    position: absolute;
    z-index: 100;
    min-width: 220px;
    background: #233138;
    border: none;
    border-radius: 10px;
    padding: 6px 0;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
    display: none;
}

.cx-msg-ctx-menu.show {
    display: block;
    animation: cx-msg-ctx-in .12s ease both;
}

@keyframes cx-msg-ctx-in {
    from {
        opacity: 0;
        transform: scale(0.96);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.cx-msg-ctx-item {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 8px 20px;
    border: none;
    background: transparent;
    color: var(--wa-text-primary);
    cursor: pointer;
    font-size: 13.5px;
    text-align: left;
    transition: background .1s;
}

.cx-msg-ctx-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.cx-msg-ctx-item .ctx-icon {
    width: 20px;
    height: 20px;
    display: grid;
    place-items: center;
    color: var(--wa-icon);
    flex-shrink: 0;
}

.cx-msg-ctx-item .ctx-icon svg {
    width: 18px;
    height: 18px;
}

.cx-msg-ctx-item.danger {
    color: var(--wa-danger);
}

.cx-msg-ctx-item.danger .ctx-icon {
    color: var(--wa-danger);
}

.cx-msg-ctx-sep {
    height: 1px;
    background: rgba(134, 150, 160, 0.15);
    margin: 4px 0;
}

/* ── Contact Info Panel ── */
.cx-msg-contact-panel {
    background: var(--wa-bg-panel);
    border-left: 1px solid var(--wa-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: cx-msg-panel-in .2s ease both;
}

@keyframes cx-msg-panel-in {
    from {
        opacity: 0;
        transform: translateX(10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.cx-msg-contact-panel-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 14px;
    background: var(--wa-bg-header);
    min-height: 44px;
    flex-shrink: 0;
}

.cx-msg-contact-panel-header h3 {
    font-size: 15px;
    font-weight: 500;
    margin: 0;
}

.cx-msg-contact-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.cx-msg-contact-panel-avatar {
    display: flex;
    justify-content: center;
    padding: 20px 0 10px;
}

.cx-msg-contact-panel-avatar-actions {
    display: flex;
    justify-content: center;
    padding: 0 16px 10px;
}

.cx-msg-contact-panel-mini-btn {
    border: 1px solid var(--wa-border);
    background: transparent;
    color: var(--wa-accent);
    border-radius: 18px;
    padding: 6px 12px;
    font-size: 12.5px;
    cursor: pointer;
    transition: background .14s, border-color .14s, transform .14s, box-shadow .14s;
}

.cx-msg-contact-panel-mini-btn:hover {
    background: rgba(0, 168, 132, 0.1);
    border-color: rgba(0, 168, 132, 0.45);
    transform: translateY(-1px);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.22);
}

.cx-msg-contact-panel-mini-btn:active {
    transform: scale(0.95);
}

.cx-msg-contact-panel-avatar .cx-msg-avatar {
    width: 180px;
    height: 180px;
    font-size: 56px;
}

.cx-msg-contact-panel-name {
    text-align: center;
    padding: 0 20px 2px;
    font-size: 20px;
    font-weight: 500;
}

.cx-msg-contact-panel-email {
    text-align: center;
    color: var(--wa-text-secondary);
    font-size: 13px;
    padding: 0 20px 4px;
}

.cx-msg-contact-panel-code {
    text-align: center;
    color: #f1c66a;
    font-size: 12px;
    letter-spacing: 1px;
    font-weight: 700;
    padding: 0 20px 14px;
}

.cx-msg-contact-panel-section {
    border-top: 8px solid var(--wa-bg-deep);
    padding: 12px 20px;
}

.cx-msg-contact-panel-section-title {
    font-size: 13px;
    color: var(--wa-text-secondary);
    margin-bottom: 4px;
}

.cx-msg-contact-panel-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 20px;
    cursor: pointer;
    transition: background .14s, transform .14s;
    font-size: 14px;
}

.cx-msg-contact-panel-row:hover {
    background: rgba(255, 255, 255, 0.04);
    transform: translateX(2px);
}

.cx-msg-contact-panel-row .panel-icon {
    font-size: 16px;
    color: var(--wa-icon);
    width: 22px;
    text-align: center;
}

.cx-msg-group-panel-members {
    margin-top: 8px;
    display: grid;
    gap: 6px;
}

.cx-msg-group-member {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(134, 150, 160, 0.2);
    border-radius: 10px;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.02);
    animation: cx-msg-list-soft-in .2s ease both;
}

@keyframes cx-msg-list-soft-in {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cx-msg-group-member .cx-msg-avatar {
    width: 34px;
    height: 34px;
    font-size: 12px;
}

.cx-msg-group-member-meta {
    min-width: 0;
    flex: 1;
}

.cx-msg-group-member-name {
    font-size: 13px;
    color: var(--wa-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cx-msg-group-member-sub {
    font-size: 11.5px;
    color: var(--wa-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cx-msg-group-member-role {
    font-size: 11px;
    color: #111b21;
    background: var(--wa-accent);
    border-radius: 10px;
    padding: 2px 6px;
    font-weight: 700;
}

.cx-msg-group-member-remove {
    border: 1px solid rgba(234, 0, 56, 0.35);
    background: transparent;
    color: var(--wa-danger);
    border-radius: 8px;
    padding: 5px 7px;
    font-size: 11.5px;
    cursor: pointer;
    transition: background .14s, transform .14s;
}

.cx-msg-group-member-remove:hover {
    background: rgba(234, 0, 56, 0.12);
    transform: translateY(-1px);
}

.cx-msg-group-member-remove:active {
    transform: scale(0.95);
}

.cx-msg-contact-panel-row.danger {
    color: var(--wa-danger);
}

.cx-msg-contact-panel-row.danger .panel-icon {
    color: var(--wa-danger);
}

.cx-msg-contact-panel-search {
    display: flex;
    justify-content: center;
    padding: 0 20px 14px;
}

.cx-msg-contact-panel-search button {
    border: 1px solid var(--wa-border);
    background: transparent;
    color: var(--wa-accent);
    padding: 7px 22px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background .12s;
}

.cx-msg-contact-panel-search button:hover {
    background: rgba(0, 168, 132, 0.08);
}

/* ── Modals (improved) ── */
.cx-msg-modal {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    background: rgba(11, 20, 26, 0.75);
    backdrop-filter: blur(3px);
}

.cx-msg-modal.hidden {
    display: none;
}

.cx-msg-modal-card {
    width: min(440px, 90%);
    border: none;
    border-radius: 12px;
    background: linear-gradient(180deg, #233138 0%, #1f2c33 100%);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, .04);
    animation: cx-msg-modal-in .25s ease both;
    overflow: hidden;
}

@keyframes cx-msg-modal-in {
    from {
        opacity: 0;
        transform: scale(0.93) translateY(12px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.cx-msg-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    background: rgba(0, 168, 132, 0.06);
    border-bottom: 1px solid rgba(0, 168, 132, 0.15);
    font-size: 17px;
    font-weight: 600;
}

.cx-msg-modal-head .cx-msg-icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, .06);
    border: none;
    color: var(--wa-text-secondary);
    cursor: pointer;
    font-size: 16px;
    transition: background .15s, color .15s;
}

.cx-msg-modal-head .cx-msg-icon-btn:hover {
    background: rgba(255, 255, 255, .12);
    color: var(--wa-text-primary);
}

.cx-msg-modal-body {
    display: grid;
    gap: 16px;
    padding: 24px;
}

.cx-msg-modal-body input,
.cx-msg-modal-body textarea {
    width: 100%;
    border: none;
    border-bottom: 2px solid var(--wa-border);
    background: transparent;
    color: var(--wa-text-primary);
    border-radius: 0;
    padding: 10px 2px;
    outline: none;
    font-size: 15px;
    font-family: inherit;
    transition: border-color .2s;
}

.cx-msg-modal-body input:focus,
.cx-msg-modal-body textarea:focus {
    border-bottom-color: var(--wa-accent);
    box-shadow: none;
}

.cx-msg-modal-body input::placeholder,
.cx-msg-modal-body textarea::placeholder {
    color: var(--wa-text-secondary);
    opacity: 0.7;
}

.cx-msg-modal-body label {
    color: var(--wa-accent);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.cx-msg-modal-hint {
    font-size: 12.5px;
    color: var(--wa-text-secondary);
    min-height: 16px;
}

.cx-msg-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 8px;
}

.cx-msg-modal-actions .cx-msg-btn.primary {
    background: var(--wa-accent);
    color: #fff;
    font-weight: 600;
    padding: 10px 24px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    transition: background .15s, transform .1s;
}

.cx-msg-modal-actions .cx-msg-btn.primary:hover {
    background: var(--wa-accent-hover);
    transform: translateY(-1px);
}

.cx-msg-modal-actions .cx-msg-btn.secondary {
    background: transparent;
    color: var(--wa-text-secondary);
    font-weight: 500;
    padding: 10px 20px;
    border-radius: 8px;
    border: 1px solid var(--wa-border);
    cursor: pointer;
    font-size: 14px;
    transition: background .15s, color .15s;
}

.cx-msg-modal-actions .cx-msg-btn.secondary:hover {
    background: rgba(255, 255, 255, .06);
    color: var(--wa-text-primary);
}

.cx-msg-menu-card {
    width: min(300px, 88%);
}

.cx-msg-menu-items {
    display: grid;
    gap: 2px;
}

.cx-msg-menu-item {
    text-align: left;
    padding: 9px 18px;
    border-radius: 0;
    font-size: 14px;
    color: var(--wa-text-primary);
}

.cx-msg-menu-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.cx-msg-edit-input {
    width: 100%;
    min-height: 70px;
    resize: vertical;
    border: none;
    background: var(--wa-bg-input);
    color: var(--wa-text-primary);
    border-radius: 8px;
    outline: none;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
}

.cx-msg-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Group members */
.cx-msg-group-members {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--wa-border);
    border-radius: 10px;
    padding: 6px;
    display: grid;
    gap: 2px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .08) transparent;
}

.cx-msg-member-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border: none;
    border-radius: 8px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.02);
    cursor: pointer;
    transition: background .15s, transform .15s;
    font-size: 14px;
}

.cx-msg-member-item:hover {
    background: rgba(0, 168, 132, 0.08);
}

.cx-msg-member-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--wa-accent);
    cursor: pointer;
    flex-shrink: 0;
    border-radius: 4px;
}

/* ── Search bar inside chat ── */
.cx-msg-chat-search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--wa-bg-header);
    border-bottom: 1px solid var(--wa-border);
    flex-shrink: 0;
    animation: cx-msg-in .15s ease both;
}

.cx-msg-chat-search-bar input {
    flex: 1;
    border: none;
    background: var(--wa-bg-input);
    color: var(--wa-text-primary);
    border-radius: 8px;
    padding: 6px 12px;
    outline: none;
    font-size: 13px;
}

.cx-msg-chat-search-bar input::placeholder {
    color: var(--wa-text-secondary);
}

.cx-msg-chat-search-bar .search-count {
    font-size: 12px;
    color: var(--wa-text-secondary);
    white-space: nowrap;
}

/* ── Settings Panel Rows ── */
.cx-msg-contact-panel-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    cursor: pointer;
    transition: background .15s;
    font-size: 14px;
    color: var(--wa-text-primary);
    border-radius: 6px;
}

.cx-msg-contact-panel-row:hover {
    background: rgba(255, 255, 255, 0.06);
    transform: translateX(2px);
}

.cx-msg-contact-panel-row .panel-icon {
    font-size: 16px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
    color: var(--wa-text-secondary);
}

/* ── Responsive ── */
@media (max-width: 900px) {
    .cx-msg-shell {
        grid-template-columns: 1fr;
    }

    .cx-msg-shell.panel-open {
        grid-template-columns: 1fr;
    }

    .cx-msg-nav {
        display: none;
    }

    .cx-msg-resize-handle {
        display: none;
    }

    .cx-msg-sidebar {
        max-height: 40%;
        border-right: 0;
        border-bottom: 1px solid var(--wa-border);
    }

    .cx-msg-contact-panel {
        display: none;
    }
}
