/* ==========================================================================
   PulseChat — Client Portal Chat Styles
   Toggle-only chat widget for the Perfex CRM client area.
   Neutral, professional palette — no admin blue.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Client Theme Variables
   -------------------------------------------------------------------------- */
:root {
    --pcc-primary:         #4a5568;
    --pcc-primary-hover:   #3d4758;
    --pcc-primary-light:   rgba(74, 85, 104, .10);
    --pcc-accent:          #667eea;
    --pcc-accent-light:    rgba(102, 126, 234, .10);
    --pcc-bg:              #ffffff;
    --pcc-bg-alt:          #f7f8fa;
    --pcc-border:          #e2e8f0;
    --pcc-text:            #2d3748;
    --pcc-text-secondary:  #718096;
    --pcc-text-muted:      #65758a;
    --pcc-sent-bg:         #0066cc;
    --pcc-sent-color:      #ffffff;
    --pcc-recv-bg:         #e4e6eb;
    --pcc-recv-color:      #1a1a1a;
    --pcc-danger:          #e53e3e;
    --pcc-success:         #38a169;
    --pcc-radius:          12px;
    --pcc-radius-sm:       6px;
    --pcc-radius-full:     9999px;
    --pcc-shadow:          0 10px 30px rgba(0, 0, 0, .12), 0 4px 10px rgba(0, 0, 0, .06);
    --pcc-shadow-sm:       0 2px 8px rgba(0, 0, 0, .08);
    --pcc-transition:      .2s ease;
    --pcc-font:            -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* --------------------------------------------------------------------------
   Toggle Button (Client)
   -------------------------------------------------------------------------- */
.pulsechat-client-toggle,
.pcc-toggle-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10100;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    border: none;
    background: var(--pcc-primary);
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    display: -webkit-inline-box;
    display: -ms-inline-flexbox;
    display: inline-flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(74, 85, 104, .3),
                0 2px 6px rgba(0, 0, 0, .08);
    -webkit-transition: transform .25s ease, box-shadow .25s ease, background-color .25s ease;
    transition: transform .25s ease, box-shadow .25s ease, background-color .25s ease;
    outline: none;
    line-height: 1;
    padding: 0;
}
.pulsechat-client-toggle:hover,
.pcc-toggle-btn:hover {
    -webkit-transform: scale(1.08);
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(74, 85, 104, .4),
                0 3px 8px rgba(0, 0, 0, .1);
}
.pulsechat-client-toggle:active,
.pcc-toggle-btn:active {
    -webkit-transform: scale(.96);
    transform: scale(.96);
}
.pulsechat-client-toggle.open .icon-chat,
.pcc-toggle-btn.open .icon-chat { display: none; }
.pulsechat-client-toggle.open .icon-close,
.pcc-toggle-btn.open .icon-close { display: inline-flex; }
.pulsechat-client-toggle .icon-close,
.pcc-toggle-btn .icon-close { display: none; }

/* Center icon inside toggle */
.pcc-toggle-btn i {
    font-size: 22px;
    line-height: 1;
}

/* Pulse on new message */
.pulsechat-client-toggle.has-new,
.pcc-toggle-btn.has-new {
    -webkit-animation: pccPulse 1.5s infinite;
    animation: pccPulse 1.5s infinite;
}

@-webkit-keyframes pccPulse {
    0%   { box-shadow: 0 0 0 0 rgba(74, 85, 104, .4); }
    100% { box-shadow: 0 0 0 14px rgba(74, 85, 104, 0); }
}
@keyframes pccPulse {
    0%   { box-shadow: 0 0 0 0 rgba(74, 85, 104, .4); }
    100% { box-shadow: 0 0 0 14px rgba(74, 85, 104, 0); }
}

/* Client Toggle Badge */
.pulsechat-client-toggle .toggle-badge,
.pcc-toggle-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    display: -webkit-inline-box;
    display: -ms-inline-flexbox;
    display: inline-flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    background: var(--pcc-danger);
    border-radius: var(--pcc-radius-full);
    border: 2px solid #fff;
    pointer-events: none;
}
.pulsechat-client-toggle .toggle-badge:empty,
.pcc-toggle-badge.hidden {
    display: none;
}

/* --------------------------------------------------------------------------
   Client Chat Panel
   -------------------------------------------------------------------------- */
.pulsechat-client-panel,
.pcc-panel {
    position: fixed;
    bottom: 86px;
    right: 20px;
    z-index: 10200;
    width: 340px;
    height: 460px;
    background: var(--pcc-bg);
    border-radius: var(--pcc-radius);
    box-shadow: var(--pcc-shadow);
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -ms-flex-direction: column;
    flex-direction: column;
    overflow: hidden;
    font-family: var(--pcc-font);
    font-size: 14px;
}
.pcc-panel.hidden {
    display: none !important;
}
.pulsechat-client-panel.open,
.pcc-panel:not(.hidden) {
    opacity: 1;
    visibility: visible;
    -webkit-transform: translateY(0) scale(1);
    transform: translateY(0) scale(1);
}

/* Panel — "Conversations" list view */
.pulsechat-client-panel .client-view-list,
.pulsechat-client-panel .client-view-chat {
    display: flex;
    flex-direction: column;
    height: 100%;
}
.pulsechat-client-panel .client-view-chat {
    display: none;
}
.pulsechat-client-panel.in-chat .client-view-list {
    display: none;
}
.pulsechat-client-panel.in-chat .client-view-chat {
    display: flex;
}

/* --------------------------------------------------------------------------
   Client Panel Header
   -------------------------------------------------------------------------- */
.pulsechat-client-panel .client-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--pcc-primary);
    color: #fff;
}
.pulsechat-client-panel .client-header h4 {
    flex: 1;
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}
.pulsechat-client-panel .client-header .back-btn,
.pulsechat-client-panel .client-header .close-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, .15);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    -webkit-transition: background-color var(--pcc-transition);
    transition: background-color var(--pcc-transition);
}
.pulsechat-client-panel .client-header .back-btn:hover,
.pulsechat-client-panel .client-header .close-btn:hover {
    background: rgba(255, 255, 255, .25);
}
.pulsechat-client-panel .client-header .back-btn {
    display: none;
}
.pulsechat-client-panel.in-chat .client-header .back-btn {
    display: inline-flex;
}

/* --------------------------------------------------------------------------
   Client Staff List
   -------------------------------------------------------------------------- */
.pulsechat-client-panel .client-staff-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 0;
}
.pulsechat-client-panel .staff-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    -webkit-transition: background-color var(--pcc-transition);
    transition: background-color var(--pcc-transition);
}
.pulsechat-client-panel .staff-item:hover {
    background: var(--pcc-bg-alt);
}
.pulsechat-client-panel .staff-item .pulsechat-avatar {
    width: 36px;
    height: 36px;
    font-size: 13px;
    background: var(--pcc-accent-light);
    color: var(--pcc-accent);
}
.pulsechat-client-panel .staff-item .staff-info {
    flex: 1;
    min-width: 0;
}
.pulsechat-client-panel .staff-item .staff-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--pcc-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pulsechat-client-panel .staff-item .staff-role {
    font-size: 11px;
    color: var(--pcc-text-muted);
    margin-top: 1px;
}
.pulsechat-client-panel .staff-item .staff-preview {
    font-size: 11px;
    color: var(--pcc-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}
.pulsechat-client-panel .staff-item .staff-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}
.pulsechat-client-panel .staff-item .staff-time {
    font-size: 10px;
    color: var(--pcc-text-muted);
}
.pulsechat-client-panel .staff-item .pulsechat-unread-badge {
    font-size: 10px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--pcc-danger);
}

/* Online indicator on staff avatar */
.pulsechat-client-panel .staff-item .pulsechat-status-dot {
    border-color: var(--pcc-bg);
}

/* --------------------------------------------------------------------------
   Client Chat View
   -------------------------------------------------------------------------- */

/* Chat Header (inside chat) */
.pulsechat-client-panel .client-chat-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--pcc-border);
    background: var(--pcc-bg);
}
.pulsechat-client-panel .client-chat-header .chat-name {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    color: var(--pcc-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pulsechat-client-panel .client-chat-header .chat-status {
    font-size: 11px;
    color: var(--pcc-text-muted);
}

/* Client Messages Area */
.pulsechat-client-panel .client-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px;
    background: var(--pcc-bg-alt);
}
.pulsechat-client-panel .client-messages .client-msg {
    display: flex;
    margin-bottom: 6px;
    -webkit-animation: pcFadeIn .15s ease;
    animation: pcFadeIn .15s ease;
}
.pulsechat-client-panel .client-messages .client-msg.sent {
    justify-content: flex-end;
}
.pulsechat-client-panel .client-messages .client-msg .msg-bubble {
    max-width: 80%;
    padding: 8px 12px;
    font-size: 13px;
    line-height: 1.4;
    border-radius: 14px;
    word-wrap: break-word;
}
.pulsechat-client-panel .client-messages .client-msg.sent .msg-bubble {
    background: var(--pcc-sent-bg);
    color: var(--pcc-sent-color);
    border-bottom-right-radius: 4px;
}
.pulsechat-client-panel .client-messages .client-msg.received .msg-bubble {
    background: var(--pcc-recv-bg);
    color: var(--pcc-recv-color);
    border-bottom-left-radius: 4px;
}
.pulsechat-client-panel .client-messages .client-msg .msg-time {
    font-size: 10px;
    color: var(--pcc-text-muted);
    margin-top: 2px;
}
.pulsechat-client-panel .client-messages .client-msg.sent .msg-time {
    text-align: right;
}

/* Typing indicator inside client chat */
.pulsechat-client-panel .client-messages .pulsechat-typing {
    background: var(--pcc-recv-bg);
    padding: 6px 10px;
    border-radius: 14px;
}

/* --------------------------------------------------------------------------
   Client Chat Input
   -------------------------------------------------------------------------- */
.pulsechat-client-panel .client-input {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    border-top: 1px solid var(--pcc-border);
    background: var(--pcc-bg);
}
.pulsechat-client-panel .client-input input {
    flex: 1;
    border: 1px solid var(--pcc-border);
    border-radius: var(--pcc-radius-full);
    padding: 8px 14px;
    font-size: 13px;
    color: var(--pcc-text);
    background: var(--pcc-bg);
    outline: none;
    -webkit-transition: border-color var(--pcc-transition), box-shadow var(--pcc-transition);
    transition: border-color var(--pcc-transition), box-shadow var(--pcc-transition);
}
.pulsechat-client-panel .client-input input:focus {
    border-color: var(--pcc-accent);
    box-shadow: 0 0 0 3px var(--pcc-accent-light);
}
.pulsechat-client-panel .client-input input::-webkit-input-placeholder { color: var(--pcc-text-muted); }
.pulsechat-client-panel .client-input input::-moz-placeholder          { color: var(--pcc-text-muted); }
.pulsechat-client-panel .client-input input:-ms-input-placeholder      { color: var(--pcc-text-muted); }
.pulsechat-client-panel .client-input input::placeholder                { color: var(--pcc-text-muted); }

.pulsechat-client-panel .client-input .attach-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--pcc-text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
    -webkit-transition: color var(--pcc-transition), background-color var(--pcc-transition);
    transition: color var(--pcc-transition), background-color var(--pcc-transition);
}
.pulsechat-client-panel .client-input .attach-btn:hover {
    color: var(--pcc-accent);
    background: var(--pcc-accent-light);
}
.pulsechat-client-panel .client-input .send-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: var(--pcc-primary);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    -webkit-transition: background-color var(--pcc-transition), transform var(--pcc-transition);
    transition: background-color var(--pcc-transition), transform var(--pcc-transition);
}
.pulsechat-client-panel .client-input .send-btn:hover {
    background: var(--pcc-primary-hover);
    -webkit-transform: scale(1.05);
    transform: scale(1.05);
}
.pulsechat-client-panel .client-input .send-btn:disabled {
    opacity: .4;
    cursor: not-allowed;
    -webkit-transform: none;
    transform: none;
}

/* --------------------------------------------------------------------------
   Client No-Messages / Loader
   -------------------------------------------------------------------------- */
.pulsechat-client-panel .client-no-messages {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 24px;
    color: var(--pcc-text-muted);
    text-align: center;
}
.pulsechat-client-panel .client-no-messages i {
    font-size: 36px;
    margin-bottom: 12px;
    opacity: .35;
}
.pulsechat-client-panel .client-no-messages p {
    margin: 0;
    font-size: 13px;
}

.pulsechat-client-panel .client-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.pulsechat-client-panel .client-loader::after {
    content: "";
    width: 24px;
    height: 24px;
    border: 2px solid var(--pcc-accent-light);
    border-top-color: var(--pcc-accent);
    border-radius: 50%;
    -webkit-animation: pcSpin .7s linear infinite;
    animation: pcSpin .7s linear infinite;
}

/* --------------------------------------------------------------------------
   Client System Message
   -------------------------------------------------------------------------- */
.pulsechat-client-panel .client-system-msg {
    text-align: center;
    padding: 8px 12px;
}
.pulsechat-client-panel .client-system-msg span {
    display: inline-block;
    padding: 3px 12px;
    font-size: 11px;
    color: var(--pcc-text-muted);
    background: rgba(0, 0, 0, .03);
    border-radius: var(--pcc-radius-full);
}

/* --------------------------------------------------------------------------
   Client Scrollbar
   -------------------------------------------------------------------------- */
.pulsechat-client-panel .client-messages::-webkit-scrollbar,
.pulsechat-client-panel .client-staff-list::-webkit-scrollbar {
    width: 5px;
}
.pulsechat-client-panel .client-messages::-webkit-scrollbar-track,
.pulsechat-client-panel .client-staff-list::-webkit-scrollbar-track {
    background: transparent;
}
.pulsechat-client-panel .client-messages::-webkit-scrollbar-thumb,
.pulsechat-client-panel .client-staff-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, .12);
    border-radius: 3px;
}
.pulsechat-client-panel .client-messages::-webkit-scrollbar-thumb:hover,
.pulsechat-client-panel .client-staff-list::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, .2);
}
.pulsechat-client-panel .client-messages,
.pulsechat-client-panel .client-staff-list {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, .12) transparent;
}

/* --------------------------------------------------------------------------
   Client Mini Chat Windows (alternative to panel)
   -------------------------------------------------------------------------- */
.pulsechat-client-mini-chats {
    position: fixed;
    bottom: 0;
    right: 86px;
    z-index: 10300;
    display: flex;
    flex-direction: row-reverse;
    gap: 8px;
    align-items: flex-end;
    pointer-events: none;
}
.pulsechat-client-mini-chats > * {
    pointer-events: auto;
}
.pulsechat-client-mini-chat {
    width: 280px;
    height: 380px;
    background: var(--pcc-bg);
    border-radius: var(--pcc-radius) var(--pcc-radius) 0 0;
    box-shadow: var(--pcc-shadow-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    -webkit-animation: pcSlideInUp .3s ease;
    animation: pcSlideInUp .3s ease;
}
.pulsechat-client-mini-chat.minimized {
    height: 42px;
}
.pulsechat-client-mini-chat.minimized .client-messages,
.pulsechat-client-mini-chat.minimized .client-input {
    display: none;
}

/* Client mini-chat header */
.pulsechat-client-mini-chat .mini-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    min-height: 42px;
    background: var(--pcc-primary);
    color: #fff;
    cursor: pointer;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}
.pulsechat-client-mini-chat .mini-header .mini-name {
    flex: 1;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pulsechat-client-mini-chat .mini-header .mini-actions button {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, .15);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    -webkit-transition: background-color .2s;
    transition: background-color .2s;
}
.pulsechat-client-mini-chat .mini-header .mini-actions button:hover {
    background: rgba(255, 255, 255, .3);
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
    .pulsechat-client-toggle {
        bottom: 14px;
        right: 14px;
        width: 48px;
        height: 48px;
        font-size: 20px;
    }
    .pulsechat-client-panel {
        bottom: 74px;
        right: 6px;
        left: 6px;
        width: auto;
        height: 65vh;
        max-height: 460px;
    }
    .pulsechat-client-mini-chats {
        right: 6px;
        left: 6px;
        flex-direction: column;
        align-items: stretch;
    }
    .pulsechat-client-mini-chat {
        width: 100%;
    }
}

/* ==========================================================================
   JS-injected widget elements (pcc-* namespace)
   ========================================================================== */

/* Panel header */
.pcc-panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--pcc-primary);
    color: #fff;
}
.pcc-panel-title {
    flex: 1;
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}
.pcc-panel-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}
.pcc-header-btn,
.pcc-panel-close {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, .15);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background-color var(--pcc-transition);
}
.pcc-header-btn:hover,
.pcc-panel-close:hover {
    background: rgba(255, 255, 255, .25);
}

/* Search */
.pcc-search {
    padding: 8px 12px;
    border-bottom: 1px solid var(--pcc-border);
    background: var(--pcc-bg);
}
.pcc-search-input {
    width: 100%;
    border: 1px solid var(--pcc-border) !important;
    border-radius: var(--pcc-radius-full);
    padding: 7px 12px;
    font-size: 13px;
    color: var(--pcc-text) !important;
    background-color: var(--pcc-bg-alt) !important;
    outline: none;
    transition: border-color var(--pcc-transition), box-shadow var(--pcc-transition);
    box-sizing: border-box;
}
.pcc-search-input:focus {
    border-color: var(--pcc-accent) !important;
    box-shadow: 0 0 0 3px var(--pcc-accent-light) !important;
}

/* Staff list */
.pcc-staff-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 0;
}
.pcc-staff-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background-color var(--pcc-transition);
}
.pcc-staff-item:hover {
    background: var(--pcc-bg-alt);
}
.pcc-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}
.pcc-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}
.pcc-presence {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--pcc-bg);
}
.pcc-presence.online { background: var(--pcc-success); }
.pcc-presence.away   { background: #f39c12; }
.pcc-presence.busy   { background: var(--pcc-danger); }
.pcc-presence.offline { background: var(--pcc-text-muted); }
.pcc-staff-info { flex: 1; min-width: 0; }
.pcc-staff-name {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--pcc-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pcc-staff-role {
    display: block;
    font-size: 11px;
    color: var(--pcc-text-muted);
}
.pcc-unread-badge {
    background: var(--pcc-danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: var(--pcc-radius-full);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.pcc-empty {
    padding: 24px;
    text-align: center;
    color: var(--pcc-text-muted);
    font-size: 13px;
}

/* Mini windows container */
.pcc-mini-windows {
    position: fixed;
    bottom: 0;
    right: 86px;
    z-index: 10300;
    display: flex;
    flex-direction: row-reverse;
    gap: 8px;
    align-items: flex-end;
    pointer-events: none;
}
.pcc-mini-windows > * { pointer-events: auto; }

/* Single mini window */
.pcc-mini-window {
    width: 300px;
    height: 380px;
    background: var(--pcc-bg);
    border-radius: var(--pcc-radius) var(--pcc-radius) 0 0;
    box-shadow: var(--pcc-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: pcSlideInUp .3s ease;
}
.pcc-mini-window.minimized { height: 42px; overflow: hidden; }
.pcc-mini-window.minimized .pcc-mini-body { display: none; }

/* Mini window header */
.pcc-mini-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    min-height: 42px;
    background: var(--pcc-primary);
    color: #fff;
    cursor: pointer;
    user-select: none;
    flex-shrink: 0;
}
.pcc-mini-header-info {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.pcc-mini-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}
.pcc-mini-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}
.pcc-mini-header-text {
    flex: 1;
    min-width: 0;
}
.pcc-mini-name {
    display: block;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}
.pcc-mini-status {
    display: block;
    font-size: 10px;
    opacity: .8;
    line-height: 1.3;
}
.pcc-mini-header-actions { display: flex; gap: 4px; flex-shrink: 0; }
.pcc-mini-close,
.pcc-mini-minimize {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, .15);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    transition: background-color .2s;
}
.pcc-mini-close:hover,
.pcc-mini-minimize:hover {
    background: rgba(255, 255, 255, .3);
}

/* Mini chat body — flex column to stack messages area + footer */
.pcc-mini-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--pcc-bg-alt);
    min-height: 0;
}

/* Messages area — scrolls, flex column for align-self to work */
.pcc-mini-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px;
    display: flex;
    flex-direction: column;
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,.12) transparent;
}
.pcc-mini-messages::-webkit-scrollbar { width: 5px; }
.pcc-mini-messages::-webkit-scrollbar-track { background: transparent; }
.pcc-mini-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,.12); border-radius: 3px; }
.pcc-mini-messages::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.2); }

/* Empty state */
.pcc-mini-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: var(--pcc-text-muted);
    font-size: 13px;
    text-align: center;
    padding: 20px;
}

/* Loading spinner */
.pcc-mini-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: var(--pcc-text-muted);
}

/* Typing indicator */
.pcc-mini-typing {
    padding: 4px 10px;
    font-size: 11px;
    color: var(--pcc-text-muted);
    flex-shrink: 0;
}
.pcc-mini-typing.hidden { display: none; }

/* Mini chat footer — attach, audio, input, send */
.pcc-mini-footer {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    padding: 8px 10px;
    border-top: 1px solid var(--pcc-border);
    background: var(--pcc-bg);
    flex-shrink: 0;
}

/* Textarea input */
textarea.pcc-mini-input {
    flex: 1;
    border: 1px solid var(--pcc-border);
    border-radius: var(--pcc-radius-sm);
    padding: 6px 10px;
    font-size: 12px;
    font-family: var(--pcc-font);
    color: var(--pcc-text);
    background: var(--pcc-bg);
    resize: none;
    outline: none;
    min-height: 30px;
    max-height: 60px;
    line-height: 1.4;
    transition: border-color var(--pcc-transition);
    box-sizing: border-box;
}
textarea.pcc-mini-input:focus {
    border-color: var(--pcc-accent);
    box-shadow: 0 0 0 2px var(--pcc-accent-light);
}
textarea.pcc-mini-input::placeholder { color: var(--pcc-text-muted); }

/* Footer action buttons */
.pcc-mini-attach-btn,
.pcc-mini-audio-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--pcc-text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
    transition: color var(--pcc-transition), background-color var(--pcc-transition);
    padding: 0;
}
.pcc-mini-attach-btn:hover,
.pcc-mini-audio-btn:hover {
    color: var(--pcc-accent);
    background: var(--pcc-accent-light);
}
.pcc-mini-file-input.hidden { display: none; }

.pcc-mini-send-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: var(--pcc-primary);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
    transition: background-color .2s;
    padding: 0;
}
.pcc-mini-send-btn:hover { background: var(--pcc-primary-hover); }

/* Presence dot (in mini window header) */
.pcc-mini-presence {
    position: absolute;
    bottom: 0; right: 0;
    width: 8px; height: 8px;
    border-radius: 50%;
    border: 2px solid var(--pcc-primary);
}
.pcc-mini-presence.online { background: var(--pcc-success); }
.pcc-mini-presence.offline { background: var(--pcc-text-muted); }

/* Legacy compat: .pcc-mini-msg (if used) */
.pcc-mini-msg { display: flex; margin-bottom: 4px; }
.pcc-mini-msg.sent { justify-content: flex-end; }
.pcc-mini-msg .pcc-msg-bubble {
    max-width: 80%;
    padding: 7px 10px;
    font-size: 12px;
    line-height: 1.4;
    border-radius: 12px;
    word-wrap: break-word;
}
.pcc-mini-msg.sent .pcc-msg-bubble {
    background: var(--pcc-sent-bg);
    color: var(--pcc-sent-color);
    border-bottom-right-radius: 4px;
}
.pcc-mini-msg.received .pcc-msg-bubble {
    background: var(--pcc-recv-bg);
    color: var(--pcc-recv-color);
    border-bottom-left-radius: 4px;
}

/* --------------------------------------------------------------------------
   Message Display Styles (pcc-msg class)
   -------------------------------------------------------------------------- */
.pcc-msg {
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
    max-width: 75%;
}

.pcc-msg-sent {
    align-self: flex-end;
    align-items: flex-end;
}

.pcc-msg-received {
    align-self: flex-start;
    align-items: flex-start;
}

.pcc-msg-sender {
    font-size: 11px;
    color: var(--pcc-text-muted);
    margin-bottom: 4px;
    font-weight: 500;
}

.pcc-msg-body {
    padding: 10px 14px;
    border-radius: 12px;
    word-wrap: break-word;
    overflow: hidden;
    max-width: 100%;
    box-sizing: border-box;
    max-width: 100%;
    font-size: 13px;
    line-height: 1.5;
}

.pcc-msg-sent .pcc-msg-body {
    background: var(--pcc-sent-bg, #0084ff);
    color: var(--pcc-sent-color, #fff);
    border-bottom-right-radius: 4px;
}

.pcc-msg-received .pcc-msg-body {
    background: var(--pcc-recv-bg, #e4e6eb);
    color: var(--pcc-recv-color, #050505);
    border-bottom-left-radius: 4px;
}

.pcc-msg-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    font-size: 10px;
    color: var(--pcc-text-muted);
}

.pcc-msg-time {
    font-size: 10px;
    color: var(--pcc-text-muted) !important;
    margin-left: auto;
}

/* Message status icons */
.pcc-msg-sent-icon,
.pcc-msg-delivered,
.pcc-msg-seen {
    font-size: 10px;
    margin-left: 2px;
}

.pcc-msg-sent-icon { color: var(--pcc-text-muted); }
.pcc-msg-delivered { color: var(--pcc-text-muted); }
.pcc-msg-seen { color: var(--pcc-success, #00a400); }

/* Message images */
.pcc-msg-image-link {
    display: block;
    max-width: 100%;
    overflow: hidden;
}

.pcc-msg-image {
    max-width: 100%;
    max-height: 250px;
    width: auto;
    height: auto;
    border-radius: 8px;
    display: block;
    object-fit: contain;
}

.pcc-msg-body .pcc-msg-image-link,
.pcc-msg-body .pcc-msg-image {
    max-width: 100% !important;
}

/* Message files */
.pcc-msg-file {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: rgba(0,0,0,.05);
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: background .2s;
}

.pcc-msg-file:hover {
    background: rgba(0,0,0,.1);
}

.pcc-msg-file i {
    font-size: 16px;
}

/* Message audio */
.pcc-msg-audio {
    max-width: 100%;
    width: 200px;
    height: 36px;
    border-radius: 18px;
    display: block;
    box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   Reactions
   -------------------------------------------------------------------------- */
.pcc-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}
.pcc-reaction-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    font-size: 13px;
    background: rgba(255, 255, 255, .2);
    border: 1px solid rgba(255, 255, 255, .3);
    border-radius: var(--pcc-radius-full);
    cursor: pointer;
    transition: background .2s, border-color .2s;
    line-height: 1.4;
}
.pcc-msg-received .pcc-reaction-badge {
    background: rgba(0, 0, 0, .05);
    border-color: rgba(0, 0, 0, .1);
}
.pcc-reaction-badge:hover {
    background: rgba(255, 255, 255, .35);
}
.pcc-msg-received .pcc-reaction-badge:hover {
    background: rgba(0, 0, 0, .1);
}
.pcc-reaction-badge.mine {
    border-color: rgba(255, 255, 255, .6);
    background: rgba(255, 255, 255, .3);
}
.pcc-msg-received .pcc-reaction-badge.mine {
    border-color: var(--pcc-accent);
    background: var(--pcc-accent-light);
}
.pcc-reaction-count {
    font-size: 11px;
    color: rgba(255, 255, 255, .95);
    font-weight: 500;
}
.pcc-msg-received .pcc-reaction-count {
    color: var(--pcc-text-secondary);
}

/* Reaction add button */
.pcc-reaction-add {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    padding: 0 4px;
    opacity: 0;
    transition: opacity .2s;
    line-height: 1;
}
.pcc-msg:hover .pcc-reaction-add {
    opacity: .6;
}
.pcc-reaction-add:hover {
    opacity: 1 !important;
}

/* Emoji picker popup — appended to .pcc-mini-body to avoid overflow clipping */
.pcc-emoji-picker {
    position: fixed;
    background: var(--pcc-bg);
    border: 1px solid var(--pcc-border);
    border-radius: var(--pcc-radius-sm);
    box-shadow: var(--pcc-shadow);
    padding: 6px;
    display: flex;
    gap: 2px;
    z-index: 10500;
    animation: pcFadeIn .15s ease;
}
.pcc-emoji-option {
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background .15s;
    line-height: 1;
}
.pcc-emoji-option:hover {
    background: var(--pcc-bg-alt);
}

/* Make .pcc-msg position relative for emoji picker */
.pcc-msg {
    position: relative;
}

/* Recording state */
.pcc-mini-audio-btn.recording {
    color: var(--pcc-danger) !important;
    background: rgba(229, 62, 62, .1) !important;
    animation: pccPulse 1.5s infinite;
}

/* --------------------------------------------------------------------------
   Settings Modal
   -------------------------------------------------------------------------- */
.pcc-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
}
.pcc-modal-overlay.active {
    display: flex;
}
.pcc-modal {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}
.pcc-modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.pcc-modal-header h4 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}
.pcc-modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #999;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
    transition: all 0.2s;
}
.pcc-modal-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #333;
}
.pcc-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}
.pcc-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}
.pcc-modal-section {
    margin-bottom: 24px;
}
.pcc-modal-section:last-child {
    margin-bottom: 0;
}
.pcc-modal-section h5 {
    margin: 0 0 12px;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #999;
}
.pcc-setting-item {
    padding: 10px 0;
}
.pcc-setting-item label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-weight: normal;
    margin: 0;
}
.pcc-color-input-group {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}
.pcc-color-input {
    width: 48px;
    height: 32px;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
}
.pcc-btn {
    padding: 8px 16px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}
.pcc-btn-primary {
    background: var(--pcc-accent, #667eea);
    color: #fff;
}
.pcc-btn-primary:hover {
    opacity: 0.9;
}
.pcc-btn-default {
    background: #f0f0f0;
    color: #333;
}
.pcc-btn-default:hover {
    background: #e0e0e0;
}
