/* ============================================================
   Chatbot AI — widget phía khách/user trên web (tách biệt hoàn
   toàn khỏi chat-widget.css/.pmchat-* — đó là live-chat người-
   người). Dùng chung biến --theme-primary của hệ thống.
   ============================================================ */
:root {
    --pmbot-primary: var(--theme-primary, #0c4c29);
    --pmbot-bg: #f4f8f6;
    --pmbot-text: #050505;
    --pmbot-text-sub: #65676b;
    --pmbot-border: rgba(12, 76, 41, 0.12);
    --pmbot-shadow: 0 16px 48px rgba(12, 76, 41, 0.16);
    --pmbot-radius-panel: 22px;
    --pmbot-radius-bubble: 16px;
}

.pmbot-launcher {
    position: fixed;
    right: 20px;
    bottom: 96px; /* trên launcher live-chat (bottom:24px, height:60px) để không chồng nhau */
    z-index: 9999;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: var(--pmbot-primary);
    color: #fff;
    box-shadow: var(--pmbot-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    cursor: pointer;
    transition: transform .2s ease;
}
.pmbot-launcher:hover { transform: scale(1.06); }
.pmbot-launcher .pmbot-badge {
    position: absolute;
    top: -2px; right: -2px;
    min-width: 18px; height: 18px;
    border-radius: 9px;
    background: #dc2626;
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.pmbot-panel {
    display: none;
    position: fixed;
    right: 20px;
    bottom: 96px;
    z-index: 10000;
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: var(--pmbot-radius-panel);
    box-shadow: var(--pmbot-shadow);
    overflow: hidden;
    flex-direction: column;
}
.pmbot-panel.pmbot-open { display: flex; }

.pmbot-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--pmbot-primary);
    color: #fff;
}
.pmbot-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,.18);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
}
.pmbot-htitle { font-weight: 700; font-size: 0.95rem; line-height: 1.2; }
.pmbot-hsub { font-size: 0.75rem; opacity: .85; display: flex; align-items: center; gap: 5px; }
.pmbot-hsub .dot { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; display: inline-block; }
.pmbot-close {
    margin-left: auto;
    background: transparent; border: none; color: #fff;
    font-size: 1.4rem; line-height: 1; cursor: pointer; opacity: .85;
}
.pmbot-close:hover { opacity: 1; }

.pmbot-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    background: var(--pmbot-bg);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.pmbot-empty { color: var(--pmbot-text-sub); font-size: 0.85rem; text-align: center; margin: auto; }

.pmbot-msg { display: flex; flex-direction: column; max-width: 85%; }
.pmbot-msg--user { align-self: flex-end; align-items: flex-end; }
.pmbot-msg--bot, .pmbot-msg--staff { align-self: flex-start; align-items: flex-start; }
.pmbot-bubble {
    padding: 9px 13px;
    border-radius: var(--pmbot-radius-bubble);
    font-size: 0.88rem;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
}
.pmbot-msg--user .pmbot-bubble { background: var(--pmbot-primary); color: #fff; border-bottom-right-radius: 4px; }
.pmbot-msg--bot .pmbot-bubble { background: #fff; color: var(--pmbot-text); border: 1px solid var(--pmbot-border); border-bottom-left-radius: 4px; }
.pmbot-msg--staff .pmbot-bubble { background: #fef3c7; color: #78350f; border: 1px solid #fde68a; border-bottom-left-radius: 4px; }
.pmbot-msg-label { font-size: 0.68rem; color: var(--pmbot-text-sub); margin-bottom: 2px; }
.pmbot-msg-time { font-size: 0.65rem; color: var(--pmbot-text-sub); margin-top: 2px; }

.pmbot-products { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.pmbot-product-card {
    display: flex; gap: 8px; align-items: center;
    background: #fff; border: 1px solid var(--pmbot-border); border-radius: 12px;
    padding: 6px; text-decoration: none; color: inherit;
}
.pmbot-product-card img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.pmbot-product-card .name { font-size: 0.8rem; font-weight: 600; color: var(--pmbot-text); }
.pmbot-product-card .price { font-size: 0.78rem; color: var(--pmbot-primary); font-weight: 700; }

.pmbot-images { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.pmbot-images img { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; cursor: pointer; }

.pmbot-videos { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.pmbot-videos video { max-width: 100%; border-radius: 10px; }

.pmbot-files { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.pmbot-file-link {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.8rem; color: var(--pmbot-primary);
    text-decoration: none; background: #fff;
    border: 1px solid var(--pmbot-border); border-radius: 10px;
    padding: 6px 10px;
}
.pmbot-file-link:hover { text-decoration: underline; }

.pmbot-foot {
    padding: 10px 12px;
    background: #fff;
    border-top: 1px solid var(--pmbot-border);
    display: flex;
    gap: 8px;
    align-items: flex-end;
}
.pmbot-foot textarea {
    flex: 1;
    resize: none;
    border: 1px solid var(--pmbot-border);
    border-radius: 14px;
    padding: 9px 12px;
    font-size: 0.88rem;
    max-height: 90px;
    font-family: inherit;
}
.pmbot-foot textarea:focus { outline: none; border-color: var(--pmbot-primary); }
.pmbot-send {
    width: 38px; height: 38px;
    border-radius: 50%;
    border: none;
    background: var(--pmbot-primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}
.pmbot-send:disabled { opacity: .5; cursor: not-allowed; }

@media (max-width: 480px) {
    .pmbot-panel { right: 8px; left: 8px; width: auto; bottom: 8px; height: calc(100vh - 88px); }
    .pmbot-launcher { right: 12px; bottom: 84px; }
}

/* Lightbox xem ảnh — z-index cao hơn panel (10000) để không bị che khuất. */
.pmbot-lightbox {
    display: none;
    position: fixed; inset: 0; z-index: 10100;
    background: rgba(15, 23, 42, 0.86);
    align-items: center; justify-content: center;
    padding: 24px;
}
.pmbot-lb-img {
    max-width: 92vw; max-height: 88vh;
    border-radius: 12px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    object-fit: contain;
}
.pmbot-lb-close {
    position: absolute; top: 18px; right: 24px;
    width: 44px; height: 44px; border: none; border-radius: 50%;
    background: rgba(255, 255, 255, 0.15); color: #fff;
    font-size: 1.4rem; cursor: pointer;
}
