/* Xat de Jera Applications (chatbot.js) */
.jb-launcher,
.jb-panel {
    --jb-primary: #536cf4;
    --jb-primary-hover: #4058e0;
    --jb-ink: #0e1220;
    --jb-copy: #3d4560;
    --jb-muted: #6b7390;
    --jb-soft: #f4f6fd;
    --jb-line: #e3e7f3;
    --jb-shadow: 0 30px 60px -12px rgba(30, 40, 110, .28), 0 18px 36px -18px rgba(0, 0, 0, .3);
    --jb-ease: cubic-bezier(.25, .1, .25, 1);
    font-family: 'Inter', 'DM Sans', Arial, sans-serif;
}

.jb-launcher {
    position: fixed;
    right: 30px;
    bottom: 30px;
    z-index: 999;
    display: grid;
    place-items: center;
    width: 60px;
    height: 60px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--jb-primary);
    color: #fff;
    box-shadow: 0 13px 27px -5px rgba(30, 40, 110, .35), 0 8px 16px -8px rgba(0, 0, 0, .3);
    cursor: pointer;
    transition: transform 200ms var(--jb-ease), background 200ms var(--jb-ease);
}
.jb-launcher:hover { background: var(--jb-primary-hover); transform: translateY(-2px); }
.jb-launcher:focus-visible { outline: 3px solid rgba(83, 108, 244, .4); outline-offset: 3px; }
.jb-launcher svg { width: 28px; height: 28px; }
.jb-launcher .jb-launcher__close { display: none; }
.jb-open .jb-launcher .jb-launcher__chat { display: none; }
.jb-open .jb-launcher .jb-launcher__close { display: block; }

.jb-panel {
    position: fixed;
    right: 30px;
    bottom: 104px;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    width: 380px;
    height: min(600px, calc(100vh - 190px));
    overflow: hidden;
    border-radius: 16px;
    background: #fff;
    color: var(--jb-ink);
    box-shadow: var(--jb-shadow);
    animation: jb-in 200ms var(--jb-ease);
}
.jb-panel[hidden] { display: none; }
@keyframes jb-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

.jb-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 16px 16px 20px;
    border-bottom: 1px solid var(--jb-line);
}
.jb-who { display: flex; align-items: center; gap: 12px; }
.jb-avatar {
    flex: none;
    width: 44px;
    height: 44px;
    overflow: hidden;
    border-radius: 50%;
    background: #0b1a4a;
    box-shadow: 0 2px 6px -1px rgba(30, 40, 110, .3);
}
.jb-avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.jb-title { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -.01em; color: var(--jb-ink); }
.jb-subtitle { margin: 2px 0 0; font-size: 13px; color: var(--jb-muted); }
.jb-close {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--jb-muted);
    cursor: pointer;
    transition: background 150ms var(--jb-ease), color 150ms var(--jb-ease);
}
.jb-close:hover { background: var(--jb-soft); color: var(--jb-ink); }
.jb-close:focus-visible { outline: 3px solid rgba(83, 108, 244, .4); }
.jb-close svg { width: 18px; height: 18px; }

.jb-list {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 10px;
    padding: 20px;
    overflow-y: auto;
    background: var(--jb-soft);
    overscroll-behavior: contain;
}
.jb-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 15px;
    line-height: 1.5;
    white-space: pre-line;
    overflow-wrap: anywhere;
}
.jb-msg--bot {
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    background: #fff;
    color: var(--jb-copy);
    box-shadow: 0 1px 3px rgba(30, 40, 110, .08);
}
.jb-msg--user {
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    background: var(--jb-primary);
    color: #fff;
}
.jb-msg a { color: var(--jb-primary); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.jb-msg--user a { color: #fff; }

.jb-typing { display: inline-flex; gap: 4px; padding: 14px; }
.jb-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--jb-muted);
    animation: jb-dot 1s infinite ease-in-out;
}
.jb-typing span:nth-child(2) { animation-delay: .15s; }
.jb-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes jb-dot {
    0%, 80%, 100% { opacity: .3; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-3px); }
}

.jb-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 12px 8px 16px;
    border-top: 1px solid var(--jb-line);
    background: #fff;
}
.jb-input {
    flex: 1;
    min-height: 40px;
    max-height: 120px;
    padding: 9px 12px;
    border: 1px solid var(--jb-line);
    border-radius: 10px;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.4;
    color: var(--jb-ink);
    resize: none;
    transition: border-color 150ms var(--jb-ease), box-shadow 150ms var(--jb-ease);
}
.jb-input::placeholder { color: var(--jb-muted); }
.jb-input:focus { outline: 0; border-color: var(--jb-primary); box-shadow: 0 0 0 3px rgba(83, 108, 244, .18); }
.jb-send {
    display: grid;
    flex: none;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--jb-primary);
    color: #fff;
    cursor: pointer;
    transition: background 150ms var(--jb-ease);
}
.jb-send:hover { background: var(--jb-primary-hover); }
.jb-send:disabled { opacity: .5; cursor: default; }
.jb-send:focus-visible { outline: 3px solid rgba(83, 108, 244, .4); outline-offset: 2px; }
.jb-send svg { width: 18px; height: 18px; }

.jb-foot { padding: 0 16px 12px; background: #fff; }
.jb-human,
.jb-legal { margin: 0; font-size: 12px; line-height: 1.5; color: var(--jb-muted); }
.jb-foot a { color: var(--jb-primary); font-weight: 600; }
.jb-wa {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.jb-wa svg { width: 16px; height: 16px; flex: none; color: #25d366; }

.jb-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

@media (max-width: 520px) {
    .jb-launcher { right: 18px; bottom: 18px; width: 56px; height: 56px; }
    .jb-panel {
        right: 8px;
        bottom: 84px;
        left: 8px;
        width: auto;
        height: calc(100vh - 100px);
        height: calc(100dvh - 100px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .jb-panel, .jb-typing span { animation: none; }
    .jb-launcher, .jb-launcher:hover { transition: none; transform: none; }
}
