/* Widget Chatbot BPOLBF — self-hosted, kompatibel CSP (style-src 'self'). */

.bpolbf-cb-root {
    position: fixed;
    bottom: 24px;
    z-index: 99990;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

.bpolbf-cb-root.bpolbf-cb-right { right: 24px; }
.bpolbf-cb-root.bpolbf-cb-left { left: 24px; }

/* ---------- Drag & snap ---------- */

/* Saat digeser: matikan transisi & animasi supaya mengikuti jari/kursor 1:1. */
.bpolbf-cb-root.bpolbf-cb-dragging .bpolbf-cb-launcher {
    animation: none;
    transition: none;
    cursor: grabbing;
}

/* Saat dilepas: meluncur halus menempel ke tepi terdekat. */
.bpolbf-cb-root.bpolbf-cb-snapping {
    transition: left 0.25s ease, top 0.25s ease;
}

@media (prefers-reduced-motion: reduce) {
    .bpolbf-cb-root.bpolbf-cb-snapping { transition: none; }
}

/* ---------- Tombol launcher ---------- */

.bpolbf-cb-launcher {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    transition: transform 0.15s ease;
    padding: 0;
    overflow: hidden;
}

.bpolbf-cb-launcher { touch-action: none; }
.bpolbf-cb-launcher:hover { transform: scale(1.06); }
.bpolbf-cb-launcher:focus { outline: 3px solid rgba(255, 255, 255, 0.6); outline-offset: 2px; }

.bpolbf-cb-launcher img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.bpolbf-cb-launcher svg { width: 30px; height: 30px; fill: #ffffff; }

/* Animasi launcher (dipilih dari dashboard admin) */
@keyframes bpolbf-cb-pulse {
    0% { box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.28); }
    70% { box-shadow: 0 0 0 16px rgba(0, 0, 0, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 0, 0, 0); }
}

@keyframes bpolbf-cb-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes bpolbf-cb-wave {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-8deg); }
    75% { transform: rotate(8deg); }
}

.bpolbf-cb-anim-pulse { animation: bpolbf-cb-pulse 2s infinite; }
.bpolbf-cb-anim-bounce { animation: bpolbf-cb-bounce 1.6s ease-in-out infinite; }
.bpolbf-cb-anim-wave { animation: bpolbf-cb-wave 1.2s ease-in-out infinite; }

@media (prefers-reduced-motion: reduce) {
    .bpolbf-cb-anim-pulse,
    .bpolbf-cb-anim-bounce,
    .bpolbf-cb-anim-wave { animation: none; }
}

/* ---------- Panel chat ---------- */

.bpolbf-cb-panel {
    position: absolute;
    bottom: 76px;
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 500px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(12px) scale(0.98);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.bpolbf-cb-right .bpolbf-cb-panel { right: 0; }
.bpolbf-cb-left .bpolbf-cb-panel { left: 0; }

/* Bila launcher berada di paruh atas layar, panel membuka ke BAWAH tombol. */
.bpolbf-cb-root.bpolbf-cb-panel-below .bpolbf-cb-panel {
    bottom: auto;
    top: 76px;
}

.bpolbf-cb-root.bpolbf-cb-open .bpolbf-cb-panel {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.bpolbf-cb-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    color: #ffffff;
}

.bpolbf-cb-header-logo {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.22);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.bpolbf-cb-header-logo img { width: 100%; height: 100%; object-fit: cover; }
.bpolbf-cb-header-logo svg { width: 20px; height: 20px; fill: #ffffff; }

.bpolbf-cb-header-title { font-weight: 600; flex: 1; }
.bpolbf-cb-header-status { display: block; font-size: 11px; font-weight: 400; opacity: 0.85; }

.bpolbf-cb-close {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
}

.bpolbf-cb-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    background: #f5f7fa;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bpolbf-cb-msg {
    max-width: 85%;
    padding: 9px 13px;
    border-radius: 14px;
    white-space: pre-wrap;
    word-break: break-word;
}

.bpolbf-cb-msg-bot {
    align-self: flex-start;
    background: #ffffff;
    color: #24292f;
    border: 1px solid #e3e8ee;
    border-bottom-left-radius: 4px;
}

.bpolbf-cb-msg-user {
    align-self: flex-end;
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.bpolbf-cb-msg-error {
    align-self: center;
    background: #fdecea;
    color: #b02a37;
    border: 1px solid #f5c2c7;
    font-size: 12.5px;
}

.bpolbf-cb-typing { display: inline-flex; gap: 4px; align-items: center; padding: 4px 2px; }
.bpolbf-cb-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #9aa5b1;
    animation: bpolbf-cb-blink 1.2s infinite both;
}
.bpolbf-cb-typing span:nth-child(2) { animation-delay: 0.2s; }
.bpolbf-cb-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bpolbf-cb-blink {
    0%, 80%, 100% { opacity: 0.25; }
    40% { opacity: 1; }
}

.bpolbf-cb-form {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #e3e8ee;
    background: #ffffff;
}

.bpolbf-cb-input {
    flex: 1;
    border: 1px solid #cfd7e0;
    border-radius: 22px;
    padding: 9px 14px;
    font-size: 14px;
    resize: none;
    max-height: 90px;
    font-family: inherit;
}

.bpolbf-cb-input:focus { outline: 2px solid rgba(14, 107, 168, 0.35); border-color: transparent; }

.bpolbf-cb-send {
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    align-self: flex-end;
}

.bpolbf-cb-send:disabled { opacity: 0.5; cursor: not-allowed; }
.bpolbf-cb-send svg { width: 18px; height: 18px; fill: #ffffff; }

.bpolbf-cb-footer-note {
    text-align: center;
    font-size: 10.5px;
    color: #8a94a0;
    padding: 0 12px 8px;
    background: #ffffff;
}

/* Eskalasi ke petugas (ticketing) */
.bpolbf-cb-escalation {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #ffffff;
    border: 1px dashed #b9c6d2;
    border-radius: 10px;
    padding: 12px;
    margin-top: 12px;
}

.bpolbf-cb-escalation-text {
    font-size: 12.5px;
    color: #4a5560;
    line-height: 1.5;
}

.bpolbf-cb-escalation-input {
    border: 1px solid #d5dde5;
    border-radius: 8px;
    padding: 9px 11px;
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    outline: none;
}

.bpolbf-cb-escalation-input:focus {
    border-color: #8fb3d9;
}

.bpolbf-cb-escalation-error {
    font-size: 12px;
    color: #c0392b;
    min-height: 0;
}

.bpolbf-cb-escalation-btn {
    border: none;
    border-radius: 8px;
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    padding: 9px 12px;
    cursor: pointer;
}

.bpolbf-cb-escalation-btn:disabled {
    opacity: 0.7;
    cursor: default;
}

/* Layar form identitas (UU PDP) — tampil sebelum chat pertama */
.bpolbf-cb-contact {
    display: none; /* diaktifkan JS saat kontak belum ada */
    flex: 1;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    padding: 16px;
    background: #f5f7fa;
}

.bpolbf-cb-contact-intro {
    font-size: 12.5px;
    color: #4a5560;
    line-height: 1.5;
}

.bpolbf-cb-contact-input {
    border: 1px solid #d5dde5;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13.5px;
    background: #ffffff;
    outline: none;
}

.bpolbf-cb-contact-input:focus {
    border-color: #8fb3d9;
}

.bpolbf-cb-contact-consent {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    font-size: 11.5px;
    color: #4a5560;
    line-height: 1.45;
    cursor: pointer;
}

.bpolbf-cb-contact-consent input {
    margin-top: 2px;
    flex-shrink: 0;
}

.bpolbf-cb-contact-error {
    font-size: 12px;
    color: #c0392b;
    min-height: 16px;
}

.bpolbf-cb-contact-submit {
    border: none;
    border-radius: 8px;
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    padding: 11px 14px;
    cursor: pointer;
}

.bpolbf-cb-contact-submit:disabled {
    opacity: 0.7;
    cursor: default;
}

.bpolbf-cb-privacy-note {
    text-align: center;
    font-size: 10.5px;
    color: #6b7683;
    padding: 6px 12px;
    background: #f5f7f9;
    border-top: 1px solid #e6eaee;
}

@media (max-width: 480px) {
    .bpolbf-cb-panel { width: calc(100vw - 32px); height: 70vh; }
}
