/* =========================================================
   ERP CHAT WIDGET - ORACLE APEX 18.2
   Primary Theme Color: #404624
   Responsive Floating Chat Widget
   ========================================================= */

#erp-chat-root {
    --chat-primary: #404624;
    --chat-primary-hover: #34391D;
    --chat-primary-light: #F0F1E9;
    --chat-bg: #FFFFFF;
    --chat-bg-soft: #F7F8F4;
    --chat-bg-sidebar: #FAFAF8;
    --chat-text: #292D22;
    --chat-text-secondary: #6F7465;
    --chat-text-light: #FFFFFF;
    --chat-border: #E2E4DB;
    --chat-border-focus: #404624;
    --chat-success: #388E3C;
    --chat-danger: #C62828;
    --chat-unread: #404624;
    --chat-shadow: 0 8px 30px rgba(30, 35, 20, 0.18);
    --chat-radius: 10px;
    --chat-font: "Segoe UI", "Helvetica Neue", Tahoma, Arial, sans-serif;
    --chat-font-size: 13px;
    --chat-font-size-sm: 11px;
    --chat-font-size-xs: 10px;
    --chat-line: 1.35;

    position: fixed;
    right: 24px;
    bottom: 24px;
    width: auto;
    height: auto;
    font-family: var(--chat-font);
    font-size: var(--chat-font-size);
    line-height: var(--chat-line);
    color: var(--chat-text);
    -webkit-font-smoothing: antialiased;
    box-sizing: border-box;
    z-index: 99990;
}

#erp-chat-root *,
#erp-chat-root *::before,
#erp-chat-root *::after {
    box-sizing: border-box;
}

/* Floating toggle */
#erp-chat-toggle {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    padding: 0;
    background: #404624;
    color: #FFFFFF;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 5px 18px rgba(64, 70, 36, 0.30);
    animation: erp-chat-pulse 2.8s ease-in-out infinite;
    transition:
        background-color 0.25s ease,
        transform 0.25s ease,
        box-shadow 0.25s ease;
}

/* Pending / unread count on chat icon */
#erp-chat-unread {
    position: absolute;
    top: -4px;
    right: -4px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    background: #C62828;
    color: #FFFFFF;
    border: 2px solid #FFFFFF;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    z-index: 2;
}

#erp-chat-unread[hidden] {
    display: none !important;
}

#erp-chat-toggle:hover {
    background: #34391D;
    transform: scale(1.06);
    box-shadow: 0 8px 24px rgba(64, 70, 36, 0.40);
    animation-play-state: paused;
}

#erp-chat-toggle:active {
    transform: scale(0.96);
}

#erp-chat-toggle:focus-visible {
    outline: 3px solid rgba(64, 70, 36, 0.35);
    outline-offset: 4px;
}

#erp-chat-toggle svg {
    color: #FFFFFF;
    fill: currentColor;
}

.erp-chat-animated-icon {
    display: block;
    width: 35px;
    height: 35px;
    overflow: visible;
    animation: erp-chat-float 2.2s ease-in-out infinite;
}

.erp-chat-bubble {
    transform-origin: center;
    animation: erp-chat-bubble-pop 2.8s ease-in-out infinite;
}

.erp-chat-dot {
    transform-box: fill-box;
    transform-origin: center;
    animation: erp-chat-typing 1.2s ease-in-out infinite;
}

.dot-one { animation-delay: 0s; }
.dot-two { animation-delay: 0.18s; }
.dot-three { animation-delay: 0.36s; }

@keyframes erp-chat-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

@keyframes erp-chat-pulse {
    0%, 100% { box-shadow: 0 5px 18px rgba(64, 70, 36, 0.25); }
    50% {
        box-shadow:
            0 5px 22px rgba(64, 70, 36, 0.38),
            0 0 0 7px rgba(64, 70, 36, 0.08);
    }
}

@keyframes erp-chat-bubble-pop {
    0%, 85%, 100% { transform: scale(1); }
    90% { transform: scale(1.04); }
    95% { transform: scale(0.98); }
}

@keyframes erp-chat-typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.65;
    }
    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* Panel */
#erp-chat-panel {
    position: absolute;
    right: 0;
    bottom: 76px;
    display: flex;
    flex-direction: column;
    width: 780px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 120px);
    background: var(--chat-bg);
    border: 1px solid var(--chat-border);
    border-radius: var(--chat-radius);
    box-shadow: var(--chat-shadow);
    overflow: hidden;
    transition: width 0.2s ease;
}

#erp-chat-panel.users-open,
#erp-chat-panel.group-create-open,
#erp-chat-panel.group-manage-open {
    width: 980px;
    max-width: calc(100vw - 24px);
}

#erp-chat-panel[hidden],
#erp-chat-root [hidden] {
    display: none !important;
}

/* Header */
#erp-chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
    min-height: 58px;
    padding: 12px 16px;
    background: var(--chat-primary);
    color: #FFFFFF;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

#erp-chat-header strong {
    margin: 0;
    flex: 1 1 auto;
    min-width: 0;
    color: #FFFFFF;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
}

#erp-chat-status {
    flex: 0 0 auto;
    color: rgba(255, 255, 255, 0.85);
    font-size: 11px;
    white-space: nowrap;
}

#erp-chat-status.online { color: #D5F5D7; }
#erp-chat-status.offline { color: #FFE0B2; }

#erp-chat-minimize {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    min-height: 32px;
    padding: 5px;
    background: transparent;
    color: #FFFFFF;
    border: none;
    border-radius: 6px;
    font: inherit;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

#erp-chat-minimize:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Layout */
#erp-chat-layout {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background: var(--chat-bg);
}

.erp-chat-pane-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex: 0 0 auto;
    min-height: 34px;
    padding: 6px 10px;
    background: #FFFFFF;
    border-bottom: 1px solid var(--chat-border);
}

.erp-chat-pane-header strong {
    font-size: var(--chat-font-size-sm);
    font-weight: 700;
    color: var(--chat-text);
}

#erp-chat-users-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    color: var(--chat-text-secondary);
    border: none;
    border-radius: 6px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

#erp-chat-users-close:hover {
    background: #F0F1E9;
    color: var(--chat-text);
}

#erp-chat-clear-recent,
.erp-chat-clear-recent {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    padding: 2px 8px;
    background: transparent;
    color: #8A8F80;
    border: 1px solid #D5D8CC;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}

#erp-chat-clear-recent:hover {
    background: #FBE9E7;
    color: #C62828;
    border-color: #FFCDD2;
}

/* Left: filter + users (New Chat) */
#erp-chat-users-panel {
    display: flex;
    flex-direction: column;
    flex: 0 0 250px;
    width: 250px;
    min-width: 0;
    background: #f6f7f3;
    border-right: 1px solid var(--chat-border);
    overflow: hidden;
}

#erp-chat-users-panel[hidden] {
    display: none !important;
}

/* Middle: recent chats */
#erp-chat-sidebar {
    display: flex;
    flex-direction: column;
    flex: 0 0 250px;
    width: 250px;
    min-width: 0;
    background: var(--chat-bg-sidebar);
    border-right: 1px solid var(--chat-border);
    overflow: hidden;
}

.erp-chat-sidebar-actions {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 6px;
    padding: 8px 8px 0;
}

#erp-chat-new-chat,
#erp-chat-new-group {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    min-height: 30px;
    margin: 0;
    padding: 5px 6px;
    background: var(--chat-primary);
    color: #FFFFFF;
    border: none;
    border-radius: 7px;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
    white-space: nowrap;
}

#erp-chat-new-group {
    background: #5A6140;
}

#erp-chat-new-chat:hover {
    background: var(--chat-primary-hover);
}

#erp-chat-new-group:hover {
    background: #484E34;
}

#erp-chat-new-chat .fa,
#erp-chat-new-group .fa {
    color: #FFFFFF;
    font-size: 12px;
}

/* Group create / manage panels */
#erp-chat-group-create-panel,
#erp-chat-group-manage-panel {
    display: flex;
    flex-direction: column;
    flex: 0 0 280px;
    width: 280px;
    min-width: 0;
    background: #f6f7f3;
    border-right: 1px solid var(--chat-border);
    overflow: hidden;
}

#erp-chat-group-create-panel[hidden],
#erp-chat-group-manage-panel[hidden] {
    display: none !important;
}

#erp-chat-group-create-close,
#erp-chat-group-manage-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    color: var(--chat-text-secondary);
    border: none;
    border-radius: 6px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

#erp-chat-group-create-close:hover,
#erp-chat-group-manage-close:hover {
    background: #F0F1E9;
    color: var(--chat-text);
}

.erp-chat-group-form,
.erp-chat-group-manage {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1 1 auto;
    min-height: 0;
    padding: 10px;
    overflow-x: hidden;
    overflow-y: auto;
}

.erp-chat-group-form label,
.erp-chat-group-section label {
    display: block;
    margin: 0 0 4px;
    color: var(--chat-text-secondary);
    font-size: 11px;
    font-weight: 600;
}

.erp-chat-group-form input,
.erp-chat-group-form textarea,
.erp-chat-group-section input,
.erp-chat-group-section textarea,
.erp-chat-group-section select {
    display: block;
    width: 100%;
    margin: 0 0 8px;
    padding: 7px 8px;
    background: #FFFFFF;
    color: var(--chat-text);
    border: 1px solid var(--chat-border);
    border-radius: 7px;
    font-family: inherit;
    font-size: var(--chat-font-size-sm);
    outline: none;
}

.erp-chat-group-form textarea,
.erp-chat-group-section textarea {
    resize: vertical;
    min-height: 52px;
}

.erp-chat-group-form input:focus,
.erp-chat-group-form textarea:focus,
.erp-chat-group-section input:focus,
.erp-chat-group-section textarea:focus,
.erp-chat-group-section select:focus {
    border-color: var(--chat-border-focus);
    box-shadow: 0 0 0 2px rgba(64, 70, 36, 0.10);
}

#erp-chat-group-create-submit,
#erp-chat-group-save {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 34px;
    margin-top: 4px;
    padding: 6px 10px;
    background: var(--chat-primary);
    color: #FFFFFF;
    border: none;
    border-radius: 7px;
    font-family: inherit;
    font-size: var(--chat-font-size-sm);
    font-weight: 600;
    cursor: pointer;
}

#erp-chat-group-save {
    width: 36px;
    min-width: 36px;
    min-height: 36px;
    padding: 0;
    font-size: 14px;
}

#erp-chat-group-create-submit:hover,
#erp-chat-group-save:hover {
    background: var(--chat-primary-hover);
}

#erp-chat-group-save:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

#erp-chat-group-edit-section.is-locked input,
#erp-chat-group-edit-section.is-locked textarea {
    background: #EEF0E8;
    color: var(--chat-text-secondary);
    cursor: default;
}

.erp-chat-setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 0 0 10px;
}

.erp-chat-setting-label {
    flex: 1 1 auto;
    min-width: 0;
    color: var(--chat-text-secondary);
    font-size: 11px;
    font-weight: 600;
}

.erp-chat-setting-icons {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
}

.erp-chat-setting-icons button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    background: #FFFFFF;
    color: var(--chat-text-secondary);
    border: 1px solid var(--chat-border);
    border-radius: 7px;
    font-size: 13px;
    cursor: pointer;
}

.erp-chat-setting-icons button:hover:not(:disabled) {
    background: #F0F1E9;
    color: var(--chat-text);
}

.erp-chat-setting-icons button.is-active {
    background: var(--chat-primary);
    color: #FFFFFF;
    border-color: var(--chat-primary);
}

.erp-chat-setting-icons button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.erp-chat-group-section {
    padding-bottom: 10px;
    border-bottom: 1px solid #E4E6DA;
}

.erp-chat-group-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.erp-chat-group-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.erp-chat-group-section-head strong {
    font-size: var(--chat-font-size-sm);
    font-weight: 700;
    color: var(--chat-text);
}

#erp-chat-group-add-member-btn,
#erp-chat-group-events-refresh,
.erp-chat-group-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    min-height: 28px;
    padding: 0;
    background: #FFFFFF;
    color: var(--chat-text);
    border: 1px solid var(--chat-border);
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
}

#erp-chat-group-add-member-btn:hover,
#erp-chat-group-events-refresh:hover,
.erp-chat-group-icon-btn:hover {
    background: #F0F1E9;
}

#erp-chat-group-member-picker,
#erp-chat-group-add-member-list,
#erp-chat-group-members-list,
#erp-chat-group-events-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 160px;
    overflow-y: auto;
}

#erp-chat-group-selected-members {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 4px 0 8px;
}

.erp-chat-group-pick-item {
    display: block;
    width: 100%;
    padding: 7px 8px;
    text-align: left;
    background: #FFFFFF;
    color: var(--chat-text);
    border: 1px solid var(--chat-border);
    border-radius: 7px;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
}

.erp-chat-group-pick-item:hover {
    background: #EEF0E8;
}

.erp-chat-group-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: #E8EBD9;
    color: var(--chat-text);
    border: none;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}

.erp-chat-group-chip:hover {
    background: #DCE0C8;
}

.erp-chat-group-member-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 6px;
    padding: 7px 8px;
    background: #FFFFFF;
    border: 1px solid var(--chat-border);
    border-radius: 7px;
}

.erp-chat-group-member-info {
    min-width: 0;
    font-size: 12px;
    line-height: 1.35;
    color: var(--chat-text);
    word-break: break-word;
}

.erp-chat-group-member-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 4px;
}

.erp-chat-group-member-actions .erp-chat-group-icon-btn {
    width: 26px;
    height: 26px;
    min-height: 26px;
    color: var(--chat-text-secondary);
    border-color: #D5D8CC;
    font-size: 11px;
}

.erp-chat-group-member-actions .erp-chat-group-icon-btn:hover {
    color: var(--chat-text);
}

.erp-chat-group-event-row {
    padding: 6px 8px;
    background: #FFFFFF;
    border: 1px solid #E4E6DA;
    border-radius: 6px;
    color: var(--chat-text-secondary);
    font-size: 11px;
    line-height: 1.35;
}

.erp-chat-group-danger {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

#erp-chat-group-leave,
#erp-chat-group-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
    border-radius: 7px;
    font-size: 14px;
    cursor: pointer;
}

#erp-chat-group-leave {
    background: #FFFFFF;
    color: #C62828;
    border: 1px solid #FFCDD2;
}

#erp-chat-group-leave:hover {
    background: #FBE9E7;
}

#erp-chat-group-delete {
    background: #C62828;
    color: #FFFFFF;
    border: none;
}

#erp-chat-group-delete:hover {
    background: #B71C1C;
}

#erp-chat-group-info-btn,
#erp-chat-dm-options-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    min-height: 28px;
    padding: 0;
    background: #FFFFFF;
    color: var(--chat-text);
    border: 1px solid var(--chat-border);
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
}

#erp-chat-group-info-btn:hover,
#erp-chat-dm-options-btn:hover {
    background: #F0F1E9;
}

.erp-chat-dm-options-wrap {
    position: relative;
    flex: 0 0 auto;
}

#erp-chat-dm-options-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 30;
    min-width: 150px;
    padding: 4px;
    background: #FFFFFF;
    border: 1px solid var(--chat-border);
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

#erp-chat-dm-options-menu button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    background: transparent;
    color: #C62828;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

#erp-chat-dm-options-menu button:hover {
    background: #FBE9E7;
}

/* WhatsApp-style date chips */
.erp-chat-date-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin: 6px 0 10px;
    clear: both;
}

.erp-chat-date-separator span {
    display: inline-block;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.92);
    color: #54656F;
    border-radius: 7px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.3;
}

#erp-chat-search {
    display: block;
    width: calc(100% - 16px);
    height: 30px;
    min-height: 30px;
    margin: 8px;
    padding: 5px 8px;
    background: #FFFFFF;
    color: var(--chat-text);
    border: 1px solid var(--chat-border);
    border-radius: 7px;
    font-family: inherit;
    font-size: var(--chat-font-size-sm);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#erp-chat-search::placeholder { color: #929687; }

#erp-chat-search:focus {
    border-color: var(--chat-border-focus);
    box-shadow: 0 0 0 2px rgba(64, 70, 36, 0.10);
}

#erp-chat-list,
#erp-chat-recent-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1 1 auto;
    min-height: 0;
    padding: 8px;
    overflow-x: hidden;
    overflow-y: auto;
    background: #f6f7f3;
    scrollbar-width: thin;
    scrollbar-color: #C9CCBF transparent;
}

#erp-chat-recent-list {
    background: var(--chat-bg-sidebar);
}

#erp-chat-recent-list .erp-chat-recent-row {
    display: flex;
    align-items: stretch;
    gap: 4px;
    width: 100%;
}

#erp-chat-recent-list .erp-chat-conversation-item {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    padding: 6px 8px;
    border: 1px solid #e6e8df;
    border-radius: 8px;
    background: #ffffff;
    color: #25291f;
    text-align: left;
    cursor: pointer;
    font: inherit;
    transition:
        background 0.18s ease,
        border-color 0.18s ease,
        box-shadow 0.18s ease;
}

#erp-chat-recent-list .erp-chat-recent-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 28px;
    width: 28px;
    min-height: 28px;
    padding: 0;
    background: transparent;
    color: #8A8F80;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}

#erp-chat-recent-list .erp-chat-recent-remove:hover {
    background: #FBE9E7;
    color: #C62828;
    border-color: #FFCDD2;
}

#erp-chat-recent-list .erp-chat-conversation-item:hover {
    background: #f0f2e9;
    border-color: #c9ceb9;
}

#erp-chat-recent-list .erp-chat-conversation-item.is-selected {
    background: #edf0e4;
    border-color: #404624;
    box-shadow: inset 3px 0 0 #404624;
}

#erp-chat-recent-list .erp-chat-recent-preview {
    display: block;
    color: #777c6e;
    font-size: var(--chat-font-size-xs);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#erp-chat-recent-list .erp-chat-recent-unread {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    margin-left: auto;
    background: #C62828;
    color: #FFFFFF;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
}

#erp-chat-recent-list > .erp-chat-contact-preview,
#erp-chat-list > .erp-chat-contact-preview {
    padding: 20px 12px;
    color: #737769;
    text-align: center;
    font-size: 12px;
    line-height: 1.6;
}

#erp-chat-list .erp-chat-conversation-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-width: 0;
    padding: 6px 8px;
    border: 1px solid #e6e8df;
    border-radius: 8px;
    background: #ffffff;
    color: #25291f;
    text-align: left;
    cursor: pointer;
    font: inherit;
    transition:
        background 0.18s ease,
        border-color 0.18s ease,
        box-shadow 0.18s ease;
}

#erp-chat-list .erp-chat-conversation-item:hover {
    background: #f0f2e9;
    border-color: #c9ceb9;
    box-shadow: 0 2px 8px rgba(64, 70, 36, 0.08);
}

#erp-chat-list .erp-chat-conversation-item:focus-visible {
    outline: 2px solid #404624;
    outline-offset: 2px;
}

#erp-chat-list .erp-chat-conversation-item.is-selected {
    background: #edf0e4;
    border-color: #404624;
    box-shadow: inset 3px 0 0 #404624;
}

.erp-chat-user-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #404624;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.erp-chat-user-info {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

#erp-chat-list .erp-chat-contact-name,
#erp-chat-recent-list .erp-chat-contact-name {
    display: block;
    color: #292d22;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

#erp-chat-list .erp-chat-contact-preview {
    display: block;
    color: #777c6e;
    font-size: var(--chat-font-size-xs);
    font-weight: 400;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.erp-chat-user-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin-top: 1px;
}

.erp-chat-user-code,
.erp-chat-user-department {
    display: inline-block;
    max-width: 100%;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 9px;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.erp-chat-user-code {
    background: #eceee5;
    color: #404624;
    font-weight: 700;
}

.erp-chat-user-department {
    background: #f1f2ef;
    color: #606456;
}

#erp-chat-list > .erp-chat-contact-preview {
    padding: 20px 12px;
    color: #737769;
    text-align: center;
    font-size: 12px;
    line-height: 1.6;
}

/* Conversation / messages */
#erp-chat-conversation {
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    background: #FFFFFF;
    overflow: hidden;
}

#erp-chat-title-bar {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 0 0 auto;
    min-height: 40px;
    padding: 6px 12px;
    background: #FFFFFF;
    border-bottom: 1px solid var(--chat-border);
}

.erp-chat-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
}

#erp-chat-title {
    display: flex;
    align-items: center;
    min-width: 0;
    color: var(--chat-text);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#erp-chat-presence {
    flex: 0 0 auto;
    font-size: 10px;
    font-weight: 700;
    text-transform: lowercase;
}

#erp-chat-presence.is-online {
    color: #1FA855;
}

#erp-chat-presence.is-offline {
    color: #8A8F80;
}

#erp-chat-presence[hidden] {
    display: none !important;
}

#erp-chat-friendship {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

#erp-chat-friendship[hidden] {
    display: none !important;
}

#erp-chat-friendship-status {
    font-size: var(--chat-font-size-xs);
    color: var(--chat-text-secondary);
    font-weight: 600;
}

#erp-chat-friendship-status.is-friends {
    color: var(--chat-success);
}

#erp-chat-friendship-status.is-pending {
    color: #B26A00;
}

#erp-chat-friendship-status.is-declined {
    color: var(--chat-danger);
}

#erp-chat-friend-add,
#erp-chat-friend-accept,
#erp-chat-friend-decline,
#erp-chat-friend-unfriend {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    padding: 2px 8px;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: var(--chat-font-size-xs);
    font-weight: 700;
    cursor: pointer;
}

#erp-chat-friend-add,
#erp-chat-friend-accept {
    background: var(--chat-primary);
    color: #FFFFFF;
}

#erp-chat-friend-decline {
    background: #F0F1E9;
    color: #5A5F52;
}

#erp-chat-friend-unfriend {
    background: #FBE9E7;
    color: #C62828;
}

#erp-chat-friend-add[hidden],
#erp-chat-friend-accept[hidden],
#erp-chat-friend-decline[hidden],
#erp-chat-friend-unfriend[hidden] {
    display: none !important;
}

.erp-chat-avatar-wrap {
    position: relative;
    flex: 0 0 auto;
}

.erp-chat-presence-dot {
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 10px;
    height: 10px;
    border: 2px solid #FFFFFF;
    border-radius: 50%;
    background: #B0B5A4;
}

.erp-chat-presence-dot.is-online {
    background: #1FA855;
}

.erp-chat-presence-dot.is-offline {
    background: #B0B5A4;
}

.erp-chat-user-status {
    display: inline-block;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 9px;
    font-weight: 700;
    line-height: 1.25;
    text-transform: lowercase;
}

.erp-chat-user-status.is-online {
    background: #E8F8EF;
    color: #1FA855;
}

.erp-chat-user-status.is-offline {
    background: #F1F2EF;
    color: #8A8F80;
}

#erp-chat-messages {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    padding: 10px 12px 14px;
    gap: 4px;
    background:
        linear-gradient(180deg, rgba(247, 248, 244, 0.92), rgba(247, 248, 244, 0.92)),
        repeating-linear-gradient(
            -12deg,
            transparent,
            transparent 18px,
            rgba(64, 70, 36, 0.015) 18px,
            rgba(64, 70, 36, 0.015) 19px
        );
    overflow-x: hidden;
    overflow-y: auto;
    overflow-wrap: anywhere;
    word-break: break-word;
    scrollbar-width: thin;
    scrollbar-color: #C9CCBF transparent;
}

#erp-chat-messages .message-actions {
    position: absolute;
    top: 4px;
    z-index: 6;
    opacity: 0;
    transition: opacity 0.15s ease;
}

#erp-chat-messages .message.mine .message-actions {
    left: 4px;
}

#erp-chat-messages .message.received .message-actions {
    right: 4px;
}

#erp-chat-messages .message:hover .message-actions,
#erp-chat-messages .message.is-menu-open .message-actions,
#erp-chat-messages .message-actions.is-open {
    opacity: 1;
}

#erp-chat-messages .message-action-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    background: rgba(255, 255, 255, 0.95);
    color: #54656F;
    border: 1px solid #D5D8CC;
    border-radius: 50%;
    font-size: 11px;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

#erp-chat-messages .message.is-menu-open {
    overflow: visible;
    z-index: 12;
}

#erp-chat-messages .message-action-menu {
    position: absolute;
    top: 26px;
    z-index: 20;
    min-width: 132px;
    max-width: 160px;
    padding: 3px;
    background: #FFFFFF;
    border: 1px solid var(--chat-border);
    border-radius: 7px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.14);
}

#erp-chat-messages .message.mine .message-action-menu {
    left: 0;
    right: auto;
}

#erp-chat-messages .message.received .message-action-menu {
    right: 0;
    left: auto;
}

#erp-chat-messages .message-action-icons {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    margin-bottom: 2px;
    padding-bottom: 4px;
    border-bottom: 1px solid #E8EAD9;
}

#erp-chat-messages .message-action-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: #F6F7F3;
    color: var(--chat-text);
    border: 1px solid var(--chat-border);
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
}

#erp-chat-messages .message-action-icon-btn:hover {
    background: #E8EBD9;
}

#erp-chat-messages .message-action-menu > button {
    display: block;
    width: 100%;
    padding: 5px 8px;
    background: transparent;
    color: var(--chat-text);
    border: none;
    border-radius: 5px;
    font-family: inherit;
    font-size: 10px;
    font-weight: 600;
    line-height: 1.3;
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
}

#erp-chat-messages .message-action-menu > button:hover {
    background: #F0F1E9;
}

#erp-chat-messages .message-forwarded-label {
    display: flex;
    align-items: center;
    gap: 5px;
    margin: 0 0 4px;
    color: #667781;
    font-size: 10px;
    font-weight: 700;
    font-style: italic;
}

#erp-chat-messages .message-forwarded-label .fa {
    font-size: 10px;
}

#erp-chat-messages .message-reply-quote {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0 0 6px;
    padding: 5px 8px;
    background: rgba(0, 0, 0, 0.05);
    border-left: 3px solid var(--chat-primary);
    border-radius: 0 6px 6px 0;
}

#erp-chat-messages .message-reply-quote strong {
    color: var(--chat-primary);
    font-size: 10px;
    font-weight: 700;
}

#erp-chat-messages .message-reply-quote span {
    color: #54656F;
    font-size: 11px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#erp-chat-messages .message-body-stack {
    min-width: 0;
}

.erp-chat-reply-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    padding: 6px 10px;
    background: #F6F7F3;
    border-top: 1px solid var(--chat-border);
}

.erp-chat-reply-bar[hidden] {
    display: none !important;
}

.erp-chat-reply-bar-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1 1 auto;
    min-width: 0;
    padding-left: 8px;
    border-left: 3px solid var(--chat-primary);
}

.erp-chat-reply-bar-body strong {
    color: var(--chat-primary);
    font-size: 11px;
    font-weight: 700;
}

.erp-chat-reply-bar-body span {
    color: #667781;
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#erp-chat-reply-cancel {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    background: transparent;
    color: var(--chat-text-secondary);
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
}

#erp-chat-reply-cancel:hover {
    background: #E8EAD9;
}

.erp-chat-forward-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 240px;
    overflow-y: auto;
}

#erp-chat-forward-search {
    display: block;
    width: 100%;
    min-height: 34px;
    padding: 7px 8px;
    border: 1px solid var(--chat-border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 12px;
}

.erp-chat-forward-item {
    display: block;
    width: 100%;
    padding: 9px 10px;
    text-align: left;
    background: #F6F7F3;
    color: var(--chat-text);
    border: 1px solid var(--chat-border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.erp-chat-forward-item:hover {
    background: #E8EBD9;
}

#erp-chat-messages .message.system-deleted {
    max-width: 85%;
    background: rgba(255, 255, 255, 0.75);
    color: #667781;
    font-style: italic;
}

/* Attachment dialog */
.erp-chat-attach-dialog {
    position: absolute;
    inset: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(25, 28, 20, 0.35);
}

.erp-chat-attach-dialog[hidden] {
    display: none !important;
}

.erp-chat-attach-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(360px, 100%);
    max-height: min(420px, 90%);
    padding: 12px;
    background: #FFFFFF;
    border: 1px solid var(--chat-border);
    border-radius: 12px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
}

.erp-chat-attach-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.erp-chat-attach-head strong {
    font-size: 14px;
    font-weight: 700;
    color: var(--chat-text);
}

#erp-chat-attach-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    color: var(--chat-text-secondary);
    border: none;
    border-radius: 6px;
    font-size: 18px;
    cursor: pointer;
}

#erp-chat-attach-close:hover {
    background: #F0F1E9;
}

#erp-chat-attach-input {
    display: block;
    width: 100%;
    font-size: 12px;
}

.erp-chat-attach-preview {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 160px;
    overflow-y: auto;
    padding: 8px;
    background: #F6F7F3;
    border: 1px solid var(--chat-border);
    border-radius: 8px;
}

.erp-chat-attach-file-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 8px;
    background: #FFFFFF;
    border: 1px solid #E4E6DA;
    border-radius: 7px;
    font-size: 12px;
    color: var(--chat-text);
}

.erp-chat-attach-file-row button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    background: #FFFFFF;
    color: #C62828;
    border: 1px solid #FFCDD2;
    border-radius: 6px;
    cursor: pointer;
}

#erp-chat-attach-caption {
    width: 100%;
    min-height: 54px;
    padding: 8px;
    border: 1px solid var(--chat-border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 12px;
    resize: vertical;
}

.erp-chat-attach-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

#erp-chat-attach-cancel,
#erp-chat-attach-send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 34px;
    padding: 6px 12px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

#erp-chat-attach-cancel {
    background: #FFFFFF;
    color: var(--chat-text);
    border: 1px solid var(--chat-border);
}

#erp-chat-attach-send {
    background: var(--chat-primary);
    color: #FFFFFF;
    border: none;
}

#erp-chat-attach-send:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

#erp-chat-attach-send:not(:disabled):hover {
    background: var(--chat-primary-hover);
}

/* WhatsApp-style bubbles */
#erp-chat-messages .message {
    position: relative;
    display: block;
    width: fit-content;
    max-width: 72%;
    padding: 6px 8px 4px 9px;
    margin: 0;
    font-size: 13px;
    line-height: 1.35;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
}

/* Meri messages → RIGHT (WhatsApp) */
#erp-chat-messages .message.mine {
    align-self: flex-end;
    background: #DCF8C6;
    color: #111B21;
    border: none;
    border-radius: 8px 8px 0 8px;
}

#erp-chat-messages .message.mine::after {
    content: "";
    position: absolute;
    right: -6px;
    bottom: 0;
    width: 0;
    height: 0;
    border-left: 6px solid #DCF8C6;
    border-top: 6px solid transparent;
}

/* Received → LEFT (WhatsApp) */
#erp-chat-messages .message.received {
    align-self: flex-start;
    background: #FFFFFF;
    color: #111B21;
    border: none;
    border-radius: 8px 8px 8px 0;
}

#erp-chat-messages .message.received::before {
    content: "";
    position: absolute;
    left: -6px;
    bottom: 0;
    width: 0;
    height: 0;
    border-right: 6px solid #FFFFFF;
    border-top: 6px solid transparent;
}

/* System / missed / cancelled call bubbles */
#erp-chat-messages .message.system {
    align-self: center;
    max-width: 80%;
    background: #EEF0E8;
    color: #5A5F52;
    border: 1px dashed #C5C9B8;
    border-radius: 16px;
    text-align: center;
    font-size: 12px;
    font-style: italic;
    box-shadow: none;
}

#erp-chat-messages .message.system-missed {
    background: #FDECEA;
    color: #8A1C1C;
    border-color: #F5C6C2;
}

#erp-chat-messages .message.system-cancelled {
    background: #FFF4E5;
    color: #8A5A00;
    border-color: #FFE0B2;
}

#erp-chat-messages .message.system .message-time {
    display: block;
    margin-top: 4px;
    text-align: center;
    color: inherit;
    opacity: 0.75;
}

#erp-chat-messages .message-sender {
    display: block;
    margin-bottom: 2px;
    color: #075E54;
    font-size: 11px;
    font-weight: 700;
}

/* Long text: 1 line + Read more */
#erp-chat-messages .message-body {
    min-width: 0;
}

#erp-chat-messages .message-text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

#erp-chat-messages .message-text.is-clamped {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    overflow: hidden;
    white-space: normal;
}

#erp-chat-messages .message-text.is-expanded {
    display: block;
    -webkit-line-clamp: unset;
    white-space: pre-wrap;
}

#erp-chat-messages .message-read-more {
    display: inline-block;
    margin-top: 2px;
    padding: 0;
    background: transparent;
    border: none;
    color: #027EB5;
    font: inherit;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
}

#erp-chat-messages .message-read-more:hover {
    text-decoration: underline;
}

/* Image album / media cards */
#erp-chat-messages .message-body-media {
    min-width: 180px;
    max-width: 260px;
}

#erp-chat-messages .message-media-album {
    display: grid;
    gap: 3px;
    overflow: hidden;
    border-radius: 8px;
}

#erp-chat-messages .message-media-album.count-1 {
    grid-template-columns: 1fr;
}

#erp-chat-messages .message-media-album.count-2 {
    grid-template-columns: 1fr 1fr;
}

#erp-chat-messages .message-media-album.count-3,
#erp-chat-messages .message-media-album.count-4 {
    grid-template-columns: 1fr 1fr;
}

#erp-chat-messages .message-media-item {
    position: relative;
    display: block;
    width: 100%;
    min-height: 88px;
    padding: 0;
    border: none;
    background: #111B21;
    cursor: pointer;
    overflow: hidden;
}

#erp-chat-messages .message-media-item img {
    display: block;
    width: 100%;
    height: 110px;
    object-fit: cover;
}

#erp-chat-messages .message-media-album.count-1 .message-media-item img {
    height: 180px;
}

#erp-chat-messages .message-media-more {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(11, 20, 26, 0.55);
    color: #FFFFFF;
    font-size: 22px;
    font-weight: 700;
}

#erp-chat-messages .message-media-caption {
    margin-top: 4px;
    color: #667781;
    font-size: 10px;
}

#erp-chat-messages .message-file-card {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 8px;
    text-align: left;
    cursor: pointer;
    font: inherit;
    color: inherit;
}

#erp-chat-messages .message-file-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    background: #FFFFFF;
    border-radius: 8px;
    font-size: 18px;
}

#erp-chat-messages .message-file-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

#erp-chat-messages .message-file-name {
    display: block;
    font-size: 12px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#erp-chat-messages .message-file-info small {
    color: #667781;
    font-size: 10px;
}

#erp-chat-messages .message-audio-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

#erp-chat-messages .message-audio-play {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    padding: 0;
    background: #25D366;
    color: #FFFFFF;
    border: none;
    border-radius: 50%;
    font-size: 12px;
    cursor: pointer;
}

#erp-chat-messages .message-audio-info {
    min-width: 0;
    flex: 1 1 auto;
}

#erp-chat-messages .message-audio-controls {
    display: block;
    width: 100%;
    height: 32px;
}

#erp-chat-messages .message-video-player {
    display: block;
    width: 100%;
    max-width: 260px;
    max-height: 220px;
    border-radius: 8px;
    background: #111B21;
}

#erp-chat-messages .message-mention {
    color: #027EB5;
    font-weight: 700;
}

#erp-chat-messages .message-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 3px;
    margin-top: 2px;
    float: right;
    margin-left: 8px;
}

#erp-chat-messages .message-time {
    color: #667781;
    font-size: 10px;
    line-height: 1.2;
}

#erp-chat-messages .message.mine .message-time,
#erp-chat-messages .message.received .message-time {
    color: #667781;
}

/* Delivered double tick */
#erp-chat-messages .message-ticks {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    font-size: 12px;
    line-height: 1;
    letter-spacing: -2px;
    user-select: none;
}

#erp-chat-messages .message-ticks.sent {
    color: #667781;
}

#erp-chat-messages .message-ticks.delivered,
#erp-chat-messages .message-ticks.read {
    color: #53BDEB;
}

#erp-chat-messages .message.received .message-ticks {
    display: none;
}

#erp-chat-messages .message-sender {
    color: #075E54;
}

/* Reactions: last emoji + remaining count */
#erp-chat-messages .message-reactions {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    clear: both;
    margin-top: 2px;
}

#erp-chat-messages .message-reaction-summary,
#erp-chat-messages .message-reaction-add {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 22px;
    padding: 1px 7px;
    background: #FFFFFF;
    color: #111B21;
    border: 1px solid #E9EDEF;
    border-radius: 999px;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

#erp-chat-messages .message-reaction-extra {
    color: #667781;
    font-size: 10px;
    font-weight: 700;
}

#erp-chat-messages .message-reaction-picker,
#erp-chat-messages .message-reaction-details {
    position: absolute;
    left: 0;
    bottom: calc(100% + 6px);
    z-index: 8;
    background: #FFFFFF;
    border: 1px solid #E9EDEF;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(11, 20, 26, 0.18);
}

#erp-chat-messages .message.mine .message-reaction-picker,
#erp-chat-messages .message.mine .message-reaction-details {
    left: auto;
    right: 0;
}

#erp-chat-messages .message-reaction-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    width: 180px;
    padding: 6px;
}

#erp-chat-messages .message-reaction-details {
    width: 200px;
    max-height: 220px;
    padding: 8px;
    overflow-y: auto;
}

#erp-chat-messages .message-reaction-picker[hidden],
#erp-chat-messages .message-reaction-details[hidden] {
    display: none !important;
}

#erp-chat-messages .message-reaction-picker button {
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
}

#erp-chat-messages .message-reaction-picker button:hover {
    background: #F0F2F5;
}

#erp-chat-messages .message-reaction-group + .message-reaction-group {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #F0F2F5;
}

#erp-chat-messages .message-reaction-group-head {
    margin-bottom: 4px;
    color: #111B21;
    font-size: 12px;
    font-weight: 700;
}

#erp-chat-messages .message-reaction-user {
    color: #667781;
    font-size: 11px;
    line-height: 1.45;
}

#erp-chat-messages .message.system .message-reactions {
    display: none !important;
}

#erp-chat-messages .empty-state {
    margin: auto;
    padding: 20px;
    color: var(--chat-text-secondary);
    font-size: 12px;
    text-align: center;
}

/* Composer */
#erp-chat-composer {
    position: relative;
    display: flex;
    align-items: flex-end;
    flex: 0 0 auto;
    gap: 6px;
    min-height: 62px;
    padding: 10px 12px;
    background: #FFFFFF;
    border-top: 1px solid var(--chat-border);
}

.erp-chat-emoji-wrap,
.erp-chat-input-wrap {
    position: relative;
    flex: 0 0 auto;
}

.erp-chat-input-wrap {
    flex: 1 1 auto;
    min-width: 0;
}

#erp-chat-attach,
#erp-chat-voice,
#erp-chat-emoji-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: #F0F1E9;
    color: var(--chat-text);
    border: 1px solid var(--chat-border);
    border-radius: 8px;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

#erp-chat-attach .fa,
#erp-chat-voice .fa {
    color: #404624;
    font-size: 14px;
}

#erp-chat-emoji-btn {
    font-size: 18px;
}

#erp-chat-attach:hover,
#erp-chat-voice:hover,
#erp-chat-emoji-btn:hover,
#erp-chat-emoji-btn[aria-expanded="true"] {
    background: #E4E7DA;
    border-color: #C9CEB9;
}

#erp-chat-attach:focus-visible,
#erp-chat-voice:focus-visible,
#erp-chat-emoji-btn:focus-visible {
    outline: 2px solid var(--chat-primary);
    outline-offset: 2px;
}

.erp-chat-mention-panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% + 6px);
    z-index: 25;
    display: flex;
    flex-direction: column;
    max-height: 180px;
    overflow-y: auto;
    background: #FFFFFF;
    border: 1px solid var(--chat-border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(30, 35, 20, 0.16);
}

.erp-chat-mention-panel[hidden] {
    display: none !important;
}

.erp-chat-mention-item {
    display: block;
    width: 100%;
    padding: 8px 10px;
    background: transparent;
    border: none;
    border-bottom: 1px solid #F0F1E9;
    text-align: left;
    font: inherit;
    font-size: 12px;
    color: var(--chat-text);
    cursor: pointer;
}

.erp-chat-mention-item:last-child {
    border-bottom: none;
}

.erp-chat-mention-item:hover {
    background: #F0F1E9;
}

.erp-chat-emoji-panel {
    position: absolute;
    left: 0;
    bottom: calc(100% + 8px);
    z-index: 20;

    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;

    width: 280px;
    max-width: min(280px, calc(100vw - 48px));
    max-height: 220px;
    padding: 8px;

    background: #FFFFFF;
    border: 1px solid var(--chat-border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(30, 35, 20, 0.16);

    overflow-x: hidden;
    overflow-y: auto;
}

.erp-chat-emoji-panel[hidden] {
    display: none !important;
}

.erp-chat-emoji-panel button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 32px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 6px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.erp-chat-emoji-panel button:hover {
    background: #F0F1E9;
}

#erp-chat-input {
    display: block;
    width: 100%;
    min-width: 0;
    min-height: 36px;
    max-height: 110px;
    margin: 0;
    padding: 8px 10px;
    background: #FFFFFF;
    color: var(--chat-text);
    border: 1px solid var(--chat-border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.45;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#erp-chat-input::placeholder { color: #929687; }

#erp-chat-input:focus {
    border-color: var(--chat-primary);
    box-shadow: 0 0 0 2px rgba(64, 70, 36, 0.10);
}

#erp-chat-send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 42px;
    min-width: 42px;
    height: 40px;
    padding: 0;
    background: var(--chat-primary);
    color: #FFFFFF;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.15s ease;
}

#erp-chat-send .fa,
#erp-chat-send .fa-send {
    color: #FFFFFF;
    font-size: 16px;
    line-height: 1;
}

#erp-chat-send:hover { background: var(--chat-primary-hover); }
#erp-chat-send:active { transform: scale(0.96); }

#erp-chat-send:disabled {
    background: #B9BCAE;
    color: #F7F8F4;
    cursor: not-allowed;
    transform: none;
}

#erp-chat-root button {
    font-family: inherit;
}

#erp-chat-root button:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

/* Scrollbars */
#erp-chat-list::-webkit-scrollbar,
#erp-chat-messages::-webkit-scrollbar {
    width: 6px;
}

#erp-chat-list::-webkit-scrollbar-thumb,
#erp-chat-messages::-webkit-scrollbar-thumb {
    background: #C9CCBF;
    border-radius: 10px;
}

#erp-chat-list::-webkit-scrollbar-track,
#erp-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

/* Responsive */
@media screen and (max-width: 700px) {
    #erp-chat-root {
        right: 16px;
        bottom: 16px;
    }

    #erp-chat-toggle {
        width: 54px;
        height: 54px;
    }

    #erp-chat-panel,
    #erp-chat-panel.users-open,
    #erp-chat-panel.group-create-open,
    #erp-chat-panel.group-manage-open {
        width: calc(100vw - 32px);
        max-width: 560px;
        height: min(500px, calc(100vh - 100px));
        bottom: 66px;
    }

    #erp-chat-sidebar,
    #erp-chat-users-panel,
    #erp-chat-group-create-panel,
    #erp-chat-group-manage-panel {
        flex-basis: 160px;
        width: 160px;
    }

    #erp-chat-messages .message {
        max-width: 70%;
    }

    #erp-chat-sidebar,
    #erp-chat-users-panel,
    #erp-chat-group-create-panel,
    #erp-chat-group-manage-panel {
        flex-basis: 200px;
        width: 200px;
    }
}

@media screen and (max-width: 480px) {
    #erp-chat-root {
        right: 12px;
        bottom: 12px;
    }

    #erp-chat-toggle {
        width: 54px;
        height: 54px;
    }

    .erp-chat-animated-icon {
        width: 32px;
        height: 32px;
    }

    #erp-chat-panel {
        position: fixed;
        right: 8px;
        bottom: 72px;
        left: 8px;
        width: auto;
        max-width: none;
        height: min(620px, calc(100dvh - 90px));
        max-height: calc(100vh - 90px);
    }

    #erp-chat-sidebar {
        flex-basis: 115px;
        width: 115px;
    }

    #erp-chat-search {
        width: calc(100% - 12px);
        margin: 6px;
        padding: 7px 6px;
        font-size: 11px;
    }

    #erp-chat-list {
        padding: 8px;
        gap: 7px;
    }

    #erp-chat-list .erp-chat-conversation-item {
        gap: 9px;
        padding: 10px;
        border-radius: 10px;
    }

    .erp-chat-user-avatar {
        flex-basis: 38px;
        width: 38px;
        height: 38px;
        font-size: 12px;
    }

    #erp-chat-list .erp-chat-contact-name {
        font-size: 12px;
    }

    #erp-chat-title {
        min-height: 42px;
        padding: 8px 10px;
        font-size: 12px;
    }

    #erp-chat-messages {
        padding: 10px 8px;
        gap: 8px;
    }

    #erp-chat-messages .message {
        max-width: 78%;
        padding: 5px 8px;
    }

    #erp-chat-composer {
        gap: 6px;
        min-height: 58px;
        padding: 8px;
    }

    #erp-chat-emoji-btn {
        width: 38px;
        height: 38px;
        font-size: 16px;
    }

    .erp-chat-emoji-panel {
        width: 250px;
        grid-template-columns: repeat(7, 1fr);
    }

    #erp-chat-input {
        min-height: 38px;
        padding: 9px;
    }

    #erp-chat-send {
        width: 38px;
        min-width: 38px;
        height: 38px;
    }
}

@media screen and (max-width: 350px) {
    #erp-chat-panel {
        right: 4px;
        left: 4px;
        bottom: 68px;
    }

    #erp-chat-sidebar {
        flex-basis: 95px;
        width: 95px;
    }
}

@media (prefers-reduced-motion: reduce) {
    #erp-chat-toggle,
    .erp-chat-animated-icon,
    .erp-chat-bubble,
    .erp-chat-dot {
        animation: none !important;
    }
}
