/* ============================================================
   PEPTIDE AGGREGATOR — LIVE CHAT (collapsible embedded block)
   ============================================================ */

#pa-chat-embed {
    display: flex;
    flex-direction: column;
    width: 100%;
    background: #ffffff;
    border: 1px solid #e4e9f0;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.4;
    color: #1a2332;
}

/* ---- Header (always visible, acts as toggle) ---- */
.pa-chat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    gap: 8px;
    background: #ffffff;
    cursor: pointer;
    user-select: none;
    flex-shrink: 0;
    border-bottom: 1px solid transparent;
    transition: background 0.15s, border-color 0.15s;
}

.pa-chat-head:hover {
    background: #f7f9fc;
}

#pa-chat-embed.is-open .pa-chat-head {
    border-bottom-color: #e4e9f0;
}

.pa-chat-head-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.pa-chat-title {
    font-size: 15px;
    font-weight: 700;
    color: #1a2332;
    white-space: nowrap;
}

.pa-chat-name-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.pa-chat-name {
    font-size: 12px;
    color: #6b7a90;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pa-chat-edit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border: none;
    background: none;
    cursor: pointer;
    color: #a0aab8;
    padding: 0;
    border-radius: 4px;
    flex-shrink: 0;
    transition: color 0.12s;
}

.pa-chat-edit-btn:hover {
    color: #2563eb;
}

.pa-chat-name-input {
    font-size: 12px;
    font-family: inherit;
    color: #1a2332;
    background: #f0f4f8;
    border: 1px solid #2563eb;
    border-radius: 6px;
    padding: 2px 6px;
    outline: none;
    width: 110px;
}

.pa-chat-head-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* ---- Status indicator ---- */
.pa-chat-status {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 10px;
    white-space: nowrap;
}

.pa-chat-status--online {
    background: rgba(14, 165, 114, 0.1);
    color: #0ea572;
}

.pa-chat-status--connecting,
.pa-chat-status--reconnecting {
    background: rgba(107, 122, 144, 0.1);
    color: #6b7a90;
}

.pa-chat-status--offline {
    background: rgba(229, 62, 62, 0.08);
    color: #e53e3e;
}

/* ---- Chevron icon ---- */
.pa-chat-chevron {
    display: inline-flex;
    align-items: center;
    color: #6b7a90;
    transition: transform 0.25s ease;
    flex-shrink: 0;
}

#pa-chat-embed.is-open .pa-chat-chevron {
    transform: rotate(180deg);
}

/* ---- Collapsible body ---- */
.pa-chat-body {
    display: flex;
    flex-direction: column;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

#pa-chat-embed.is-open .pa-chat-body {
    max-height: 500px;
}

/* ---- Messages area ---- */
.pa-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: 380px;
    scrollbar-width: thin;
    scrollbar-color: #e4e9f0 transparent;
    background: #f8fafc;
}

.pa-chat-messages::-webkit-scrollbar { width: 4px; }
.pa-chat-messages::-webkit-scrollbar-track { background: transparent; }
.pa-chat-messages::-webkit-scrollbar-thumb { background: #e4e9f0; border-radius: 4px; }

/* ---- Individual message rows ---- */
.pa-chat-msg {
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-width: 75%;
    align-self: flex-start;
}

.pa-chat-msg--me {
    align-self: flex-end;
    align-items: flex-end;
}

.pa-chat-msg--system {
    align-self: center;
    max-width: 100%;
}

.pa-chat-sender {
    font-size: 11px;
    font-weight: 600;
    color: #6b7a90;
    padding: 0 4px;
}

.pa-chat-sender--me {
    color: #2563eb;
}

.pa-chat-bubble {
    background: #ffffff;
    color: #1a2332;
    padding: 8px 12px;
    border-radius: 12px 12px 12px 3px;
    font-size: 13px;
    word-break: break-word;
    line-height: 1.5;
    border: 1px solid #e4e9f0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.pa-chat-bubble--me {
    background: #2563eb;
    color: #ffffff;
    border-color: #2563eb;
    border-radius: 12px 12px 3px 12px;
    box-shadow: none;
}

.pa-chat-system {
    font-size: 11px;
    color: #6b7a90;
    background: #f0f4f8;
    border-radius: 10px;
    padding: 3px 10px;
}

/* ---- Input footer ---- */
.pa-chat-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid #e4e9f0;
    flex-shrink: 0;
    background: #ffffff;
}

.pa-chat-input {
    flex: 1;
    border: 1px solid #e4e9f0;
    border-radius: 10px;
    padding: 9px 14px;
    font-size: 13px;
    font-family: inherit;
    color: #1a2332;
    background: #f7f9fc;
    outline: none;
    transition: border-color 0.15s, background 0.15s;
    min-width: 0;
}

.pa-chat-input:focus {
    border-color: #2563eb;
    background: #ffffff;
}

.pa-chat-input::placeholder {
    color: #a0aab8;
}

.pa-chat-send-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 10px;
    background: #2563eb;
    color: #ffffff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.1s;
}

.pa-chat-send-btn:hover {
    background: #1d4ed8;
    transform: scale(1.05);
}

.pa-chat-send-btn:active {
    transform: scale(0.97);
}

/* ---- Mobile ---- */
@media (max-width: 600px) {
    #pa-chat-embed {
        border-radius: 12px;
    }

    #pa-chat-embed.is-open .pa-chat-body {
        max-height: 420px;
    }

    .pa-chat-messages {
        height: 300px;
    }
}
