/* ===== PrestaChat Widget ===== */
#prestachat-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--pc-color, #2563eb);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(0,0,0,0.22);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .2s, box-shadow .2s;
}
#prestachat-btn:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(0,0,0,0.28); }
#prestachat-btn svg { width: 28px; height: 28px; }

#prestachat-badge {
    position: absolute;
    top: -4px; right: -4px;
    background: #ef4444;
    color: #fff;
    font-size: 11px; font-weight: 700;
    border-radius: 50%;
    width: 20px; height: 20px;
    display: none;
    align-items: center; justify-content: center;
}

#prestachat-box {
    position: fixed;
    bottom: 96px; right: 24px;
    width: 340px;
    max-height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.18);
    z-index: 9998;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
#prestachat-box.open { display: flex; }

#pc-header {
    background: var(--pc-color, #2563eb);
    color: #fff;
    padding: 14px 16px;
    display: flex; align-items: center; gap: 10px;
}
#pc-header .pc-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.25);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 16px;
}
#pc-header .pc-info { flex: 1; }
#pc-header .pc-name { font-weight: 700; font-size: 15px; }
#pc-header .pc-status { font-size: 12px; opacity: .85; }
#pc-close {
    background: none; border: none; color: #fff;
    font-size: 20px; cursor: pointer; opacity: .8; padding: 0 4px;
}
#pc-close:hover { opacity: 1; }

#pc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex; flex-direction: column; gap: 10px;
    min-height: 200px; max-height: 320px;
    background: #f8fafc;
}

.pc-msg {
    max-width: 82%;
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.45;
    word-break: break-word;
}
.pc-msg.client {
    align-self: flex-end;
    background: var(--pc-color, #2563eb);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.pc-msg.agent, .pc-msg.bot {
    align-self: flex-start;
    background: #fff; color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}
.pc-msg-meta { font-size: 11px; color: #94a3b8; margin-top: 2px; }
.pc-msg-meta.right { text-align: right; }

#pc-identify {
    padding: 16px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}
#pc-identify p { font-size: 13px; color: #475569; margin-bottom: 10px; }
#pc-identify input {
    width: 100%; padding: 8px 10px;
    border: 1px solid #cbd5e1; border-radius: 8px;
    font-size: 14px; margin-bottom: 8px; box-sizing: border-box;
}
#pc-identify button {
    width: 100%; padding: 9px;
    background: var(--pc-color, #2563eb);
    color: #fff; border: none; border-radius: 8px;
    font-size: 14px; font-weight: 600; cursor: pointer;
}

#pc-footer {
    padding: 10px 12px;
    border-top: 1px solid #e2e8f0;
    display: flex; gap: 8px;
    background: #fff;
}
#pc-input {
    flex: 1;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 14px;
    outline: none; resize: none;
    max-height: 80px;
}
#pc-input:focus { border-color: var(--pc-color, #2563eb); }
#pc-send {
    background: var(--pc-color, #2563eb);
    color: #fff; border: none;
    border-radius: 50%;
    width: 38px; height: 38px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: opacity .2s;
}
#pc-send:hover { opacity: .85; }

.pc-typing { display: flex; gap: 4px; align-items: center; padding: 10px 14px; }
.pc-typing span {
    width: 7px; height: 7px; border-radius: 50%;
    background: #94a3b8;
    animation: pcbounce 1.2s infinite;
}
.pc-typing span:nth-child(2) { animation-delay: .2s; }
.pc-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes pcbounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}

@media (max-width: 400px) {
    #prestachat-box { width: calc(100vw - 24px); right: 12px; bottom: 86px; }
    #prestachat-btn { right: 12px; bottom: 12px; }
}
