/* ═══════════════════════════════════════════════════════════════
   MSP Live Chat — chat-app.css v2.5.0
   ═══════════════════════════════════════════════════════════════ */

/* ── Floating toggle button ─────────────────────────────────── */
#msp-chat-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: #E50A25;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(229,10,37,0.45);
    z-index: 999998;
    transition: transform 0.2s;
}
#msp-chat-toggle:hover { transform: scale(1.08); }

/* Pulse ring when new message arrives while widget is closed */
#msp-chat-toggle.msp-has-new::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 3px solid #E50A25;
    animation: msp-ring 1.2s ease-out infinite;
}
@keyframes msp-ring {
    0%   { transform: scale(1);   opacity: 0.8; }
    100% { transform: scale(1.5); opacity: 0;   }
}

/* ── Widget container ───────────────────────────────────────── */
#msp-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 360px;
    height: 540px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    overflow: hidden;
    transform: translateY(120%) scale(0.95);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), opacity 0.25s ease;
}
#msp-chat-widget.active {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: all;
}

/* ── Header ─────────────────────────────────────────────────── */
.msp-chat-header {
    background: #E50A25;
    color: #fff;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    border-radius: 16px 16px 0 0;
}
.msp-header-agent {
    display: flex;
    align-items: center;
    gap: 10px;
}
.msp-agent-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255,255,255,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    border: 2px solid rgba(255,255,255,0.5);
    flex-shrink: 0;
}
.msp-agent-name   { font-weight: 700; font-size: 14px; line-height: 1.2; }
.msp-agent-status { font-size: 11px; opacity: 0.85; }
.msp-header-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}
.msp-header-actions span {
    cursor: pointer;
    font-size: 18px;
    opacity: 0.85;
    transition: opacity 0.15s;
    user-select: none;
    line-height: 1;
}
.msp-header-actions span:hover { opacity: 1; }

/* ── Message area ────────────────────────────────────────────── */
.msp-chat-messages {
    flex: 1;
    padding: 16px 14px;
    overflow-y: auto;
    background: #f7f7f8;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* ── Message bubbles ─────────────────────────────────────────── */
.msp-message {
    padding: 10px 14px;
    border-radius: 18px;
    max-width: 80%;
    font-size: 14px;
    line-height: 1.45;
    word-wrap: break-word;
    animation: msp-bubble-in 0.2s ease;
}
@keyframes msp-bubble-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.msp-message.visitor {
    background: #E50A25;
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.msp-message.agent {
    background: #fff;
    color: #222;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

/* ── Quick reply buttons ─────────────────────────────────────── */
.msp-quick-replies {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    margin-top: 4px;
    animation: msp-bubble-in 0.25s ease;
}
.msp-qr-btn {
    background: #fff;
    color: #E50A25;
    border: 1.5px solid #E50A25;
    border-radius: 20px;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background 0.18s, color 0.18s;
    font-family: inherit;
    max-width: 88%;
}
.msp-qr-btn:hover {
    background: #E50A25;
    color: #fff;
}

/* ── Input area ──────────────────────────────────────────────── */
.msp-chat-input-area {
    display: flex;
    padding: 10px;
    border-top: 1px solid #eee;
    background: #fff;
    flex-shrink: 0;
    gap: 8px;
}
.msp-chat-input-area input {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid #ddd;
    border-radius: 22px;
    outline: none;
    font-size: 14px;
    color: #333;
    font-family: inherit;
    transition: border-color 0.2s;
    background: #fafafa;
}
.msp-chat-input-area input:focus { border-color: #E50A25; background: #fff; }
.msp-chat-input-area button {
    background: #E50A25;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 15px;
    flex-shrink: 0;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.msp-chat-input-area button:hover { background: #c4081f; }

/* ═══════════════════════════════════════════════════════════════
   AGENT DASHBOARD
   ═══════════════════════════════════════════════════════════════ */
.msp-agent-container  { display: flex; height: 80vh; border: 1px solid #ddd; background: #fff; }
.msp-agent-sidebar    { width: 300px; border-right: 1px solid #ddd; overflow-y: auto; background: #f9f9f9; }
.msp-agent-chat-area  { flex: 1; display: flex; flex-direction: column; }

.msp-tabs             { display: flex; border-bottom: 1px solid #ddd; background: #f5f5f5; }
.msp-tab              { flex: 1; padding: 12px; text-align: center; cursor: pointer; font-weight: bold; color: #666; transition: 0.2s; }
.msp-tab.active       { background: #E50A25; color: #fff; }
.msp-tab-content         { display: none; }
.msp-tab-content.active  { display: block; }

.msp-chat-session {
    padding: 15px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    color: #333;
    position: relative;
    border-left: 4px solid transparent !important;
    transition: background-color 0.2s;
}
.msp-chat-session:hover        { background: #E50A25; color: #fff; }
.msp-chat-session:hover small  { color: #ffe6e6 !important; }
.msp-chat-session.active-chat-session { border-left-color: #E50A25 !important; background-color: #f9f9f9; }

/* Unread dot */
.unread-indicator {
    display: none;
    position: absolute;
    top: 50%; right: 12px;
    transform: translateY(-50%);
    width: 10px; height: 10px;
    background: #E50A25;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(229,10,37,0.7);
    animation: pulse-dot 1.2s infinite;
}
.has-unread .unread-indicator { display: block; }
.has-unread { background: #fff5f5; border-left: 3px solid #E50A25 !important; }

@keyframes pulse-dot {
    0%,100% { transform: translateY(-50%) scale(1);   opacity: 1; }
    50%      { transform: translateY(-50%) scale(1.4); opacity: 0.7; }
}

/* Unread count badge */
.msp-unread-badge {
    display: inline-block;
    background: #E50A25;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    border-radius: 10px;
    padding: 0 5px;
    position: absolute;
    top: 50%; right: 12px;
    transform: translateY(-50%);
    box-shadow: 0 2px 6px rgba(229,10,37,0.45);
    animation: badge-pop 0.25s cubic-bezier(0.175,0.885,0.32,1.275);
}
@keyframes badge-pop {
    from { transform: translateY(-50%) scale(0.5); opacity: 0; }
    to   { transform: translateY(-50%) scale(1);   opacity: 1; }
}
.msp-chat-session:has(.msp-unread-badge) .unread-indicator { display: none; }

/* Agent chat messages */
#msp-agent-chat-box {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px;
}
#msp-agent-chat-box .msp-message.visitor { align-self: flex-start; background: #f0f0f0; color: #222; }
#msp-agent-chat-box .msp-message.agent   { align-self: flex-end;   background: #E50A25; color: #fff; }

/* ── Agent status dot ────────────────────────────────────────── */
.msp-agent-status {
    color: rgba(255,255,255,0.6); /* default: away/grey */
    transition: color 0.4s ease;
}
.msp-agent-status.is-online {
    color: #4ade80; /* green */
}
