/* =========================================================================
   Vexie — zwevende AI-assistent (rechtsonder). Markup: includes/vexie.php,
   gedrag: assets/js/vexie.js. Gebruikt de kleuren van de site (var(--card),
   var(--text), ...) met fallbacks, dus werkt ook in het lichte paneelthema.
   ========================================================================= */

/* Statusbadge — rechtsonder, direct naast de Vexie-launcher. Gebruikt de
   .status-pill-* kleurklassen uit style.css (online/problemen/offline). */
.vx-status-badge {
    position: fixed;
    right: calc(20px + 82px + 12px); /* naast de 82px-brede launcher, zelfde gap als vexie-root */
    bottom: calc(20px + var(--vexie-lift, 0px) + 26px); /* verticaal gecentreerd op de launcher */
    z-index: 900;
    text-decoration: none;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .35);
    background-color: var(--card, #131318);
}
.vx-status-badge:hover { filter: brightness(1.12); }

@media (max-width: 480px) {
    .vx-status-badge {
        right: 20px;
        bottom: calc(20px + var(--vexie-lift, 0px) + 90px);
    }
}

.vexie-root {
    --vx-teal: #2bcac5;
    --vx-teal-deep: #087a86;
    --vx-panel: var(--card, #131318);
    --vx-border: var(--border, #24242c);
    --vx-text: var(--text, #f4f4f6);
    --vx-muted: var(--text-muted, #a8a8b3);
    --vx-bubble: rgba(127, 127, 140, .16);

    position: fixed;
    right: 20px;
    bottom: calc(20px + var(--vexie-lift, 0px));
    z-index: 900;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--vx-text);
    pointer-events: none;            /* alleen de kinderen vangen kliks */
}
.vexie-root > * { pointer-events: auto; }
.vexie-root button, .vexie-root textarea, .vexie-root a { pointer-events: auto; }

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

/* ------------------------------------------------------------ launcher */
.vexie-launcher {
    all: unset;
    pointer-events: auto;            /* all:unset erft anders 'none' van .vexie-root */
    box-sizing: border-box;
    display: block;
    width: 82px;
    cursor: pointer;
    border-radius: 18px;
    -webkit-tap-highlight-color: transparent;
    transition: transform .2s ease;
}
.vexie-launcher:hover { transform: translateY(-3px) rotate(-3deg); }
.vexie-launcher:active { transform: scale(.94); }
.vexie-launcher:focus-visible { outline: 2px solid var(--vx-teal); outline-offset: 4px; }

.vexie-launcher .vexie-bot {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
    filter: drop-shadow(0 6px 12px rgba(0, 0, 0, .5)) drop-shadow(0 0 16px rgba(43, 202, 197, .28));
    animation: vexie-float 4s ease-in-out infinite;
}
@keyframes vexie-float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-3px); }
}

/* Op lichte achtergronden verdwijnt het witte hoofd: geef het een donkere rand. */
html.theme-light .vexie-head { stroke: #0b5563; stroke-width: 5; stroke-linejoin: round; paint-order: stroke; }
html.theme-light .vexie-launcher .vexie-bot { filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .25)); }

/* ---------------------------------------------------- ogen, knipperen */
.vexie-eye {
    transform-box: fill-box;
    transform-origin: center;
    transition: transform .09s ease-out;
}
.vexie-bot.is-blink .vexie-eye { transform: scaleY(.1); }
.vexie-antenna { transform-box: fill-box; transform-origin: 50% 100%; }
.vexie-launcher:hover .vexie-antenna { animation: vexie-wiggle .5s ease-in-out; }
@keyframes vexie-wiggle {
    0%, 100% { transform: rotate(0); }
    30% { transform: rotate(-4deg); }
    65% { transform: rotate(3deg); }
}

/* ------------------------------------------------------------ teaser */
.vexie-teaser {
    position: relative;
    max-width: 210px;
    padding: 9px 30px 9px 14px;
    background: var(--vx-panel);
    color: var(--vx-text);
    border: 1px solid var(--vx-border);
    border-radius: 14px 14px 4px 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
    font-weight: 600;
    font-size: 13.5px;
    animation: vexie-pop .3s ease;
}
.vexie-teaser[hidden] { display: none; }
.vexie-teaser-close {
    all: unset;
    position: absolute; top: 4px; right: 6px;
    width: 22px; height: 22px;
    text-align: center; line-height: 22px;
    cursor: pointer; color: var(--vx-muted); font-size: 18px;
    border-radius: 50%;
}
.vexie-teaser-close:hover { color: var(--vx-text); }
.vexie-teaser-close:focus-visible { outline: 2px solid var(--vx-teal); }
@keyframes vexie-pop {
    from { opacity: 0; transform: translateY(8px) scale(.96); }
    to   { opacity: 1; transform: none; }
}

/* -------------------------------------------------------------- panel */
.vexie-panel {
    display: flex;
    flex-direction: column;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: min(600px, calc(100vh - 150px));
    height: min(600px, calc(100dvh - 150px));
    background: var(--vx-panel);
    border: 1px solid var(--vx-border);
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
    overflow: hidden;

    opacity: 0;
    visibility: hidden;
    transform: translateY(14px) scale(.98);
    transform-origin: bottom right;
    transition: opacity .18s ease, transform .18s ease, visibility 0s linear .18s;
    /* Dicht paneel neemt geen ruimte in de kolom in: */
    position: absolute;
    right: 0;
    bottom: calc(100% + 12px);
}
.vexie-root.is-open .vexie-panel {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: opacity .18s ease, transform .18s ease;
}
/* Het paneel staat boven de launcher; zonder eigen hoogte in de flexkolom. */
.vexie-root { align-items: flex-end; }

.vexie-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 12px 12px 14px;
    background: linear-gradient(135deg, #032f3b, #075e69);
    color: #fff;
}
.vexie-avatar { flex: none; width: 46px; }
.vexie-avatar .vexie-bot { display: block; width: 100%; height: auto; overflow: visible; }
.vexie-header-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.vexie-header-text strong { font-size: 15px; }
.vexie-header-text span { font-size: 12px; color: rgba(255, 255, 255, .78); }

.vexie-icon-btn {
    all: unset;
    box-sizing: border-box;
    flex: none;
    display: flex; align-items: center; justify-content: center;
    width: 32px; height: 32px;
    border-radius: 9px;
    color: rgba(255, 255, 255, .85);
    cursor: pointer;
}
.vexie-icon-btn:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.vexie-icon-btn:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }

/* ----------------------------------------------------------- berichten */
.vexie-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
}
.vexie-msg { display: flex; max-width: 100%; }
.vexie-msg-user { justify-content: flex-end; }
.vexie-msg-body {
    max-width: 88%;
    padding: 9px 13px;
    border-radius: 14px;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}
.vexie-msg-assistant .vexie-msg-body {
    background: var(--vx-bubble);
    border-bottom-left-radius: 4px;
}
.vexie-msg-user .vexie-msg-body {
    background: linear-gradient(135deg, var(--vx-teal-deep), #0b9199);
    color: #fff;
    border-bottom-right-radius: 4px;
    white-space: pre-wrap;
}
.vexie-msg-error .vexie-msg-body {
    background: rgba(239, 68, 68, .14);
    border: 1px solid rgba(239, 68, 68, .45);
}

.vexie-msg-body p { margin: 0 0 8px; }
.vexie-msg-body p:last-child,
.vexie-msg-body ul:last-child,
.vexie-msg-body ol:last-child { margin-bottom: 0; }
.vexie-msg-body ul, .vexie-msg-body ol { margin: 0 0 8px; padding-left: 20px; }
.vexie-msg-body li { margin: 2px 0; }
.vexie-msg-body a { color: var(--vx-teal); text-decoration: underline; text-underline-offset: 2px; }
html.theme-light .vexie-msg-body a { color: var(--vx-teal-deep); }
.vexie-msg-body code {
    padding: 1px 5px;
    border-radius: 5px;
    background: rgba(127, 127, 140, .22);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .92em;
}
.vexie-msg-body pre {
    margin: 0 0 8px;
    padding: 10px 12px;
    border-radius: 9px;
    background: rgba(0, 0, 0, .35);
    color: #e9e9ee;
    overflow-x: auto;
}
.vexie-msg-body pre code { padding: 0; background: none; color: inherit; font-size: 12.5px; }

/* typ-indicator */
.vexie-typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.vexie-typing i {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--vx-muted);
    animation: vexie-dot 1.1s infinite ease-in-out;
}
.vexie-typing i:nth-child(2) { animation-delay: .15s; }
.vexie-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes vexie-dot {
    0%, 80%, 100% { transform: translateY(0); opacity: .45; }
    40% { transform: translateY(-4px); opacity: 1; }
}

/* ---------------------------------------------------------- suggesties */
.vexie-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 14px 10px;
}
.vexie-chips[hidden] { display: none; }
.vexie-chip {
    all: unset;
    box-sizing: border-box;
    padding: 6px 11px;
    border: 1px solid var(--vx-border);
    border-radius: 999px;
    font-size: 12.5px;
    color: var(--vx-text);
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.vexie-chip:hover { border-color: var(--vx-teal); background: rgba(43, 202, 197, .1); }
.vexie-chip:focus-visible { outline: 2px solid var(--vx-teal); }

/* ------------------------------------------------------------ invoer */
.vexie-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--vx-border);
}
.vexie-input {
    flex: 1;
    min-width: 0;
    box-sizing: border-box;
    resize: none;
    max-height: 110px;
    padding: 9px 12px;
    font: inherit;
    color: var(--vx-text);
    background: var(--vx-bubble);
    border: 1px solid transparent;
    border-radius: 12px;
    outline: none;
}
.vexie-input::placeholder { color: var(--vx-muted); }
.vexie-input:focus { border-color: var(--vx-teal); }

.vexie-send {
    all: unset;
    box-sizing: border-box;
    flex: none;
    display: flex; align-items: center; justify-content: center;
    width: 38px; height: 38px;
    border-radius: 12px;
    background: var(--vx-teal-deep);
    color: #fff;
    cursor: pointer;
    transition: background .15s, opacity .15s;
}
.vexie-send:hover { background: #0a8f9c; }
.vexie-send:focus-visible { outline: 2px solid var(--vx-teal); outline-offset: 2px; }
.vexie-send[disabled] { opacity: .45; cursor: default; }
.vexie-stop-icon { display: none; }
.vexie-send.is-busy .vexie-send-icon { display: none; }
.vexie-send.is-busy .vexie-stop-icon { display: block; }

.vexie-note {
    margin: 0;
    padding: 0 14px 10px;
    font-size: 11px;
    line-height: 1.45;
    color: var(--vx-muted);
}
.vexie-note a { color: inherit; text-decoration: underline; }

/* ------------------------------------------------------------ mobiel */
@media (max-width: 520px) {
    .vexie-root { right: 12px; bottom: calc(12px + var(--vexie-lift, 0px)); }
    .vexie-launcher { width: 70px; }
    .vexie-root.is-open .vexie-panel {
        position: fixed;
        inset: 8px;
        width: auto;
        max-width: none;
        height: auto;
    }
    .vexie-panel { border-radius: 16px; }
    .vexie-root.is-open .vexie-launcher,
    .vexie-root.is-open .vexie-teaser { display: none; }
    .vexie-input { font-size: 16px; }   /* voorkomt inzoomen op iOS */
}

@media (prefers-reduced-motion: reduce) {
    .vexie-launcher .vexie-bot,
    .vexie-launcher:hover .vexie-antenna,
    .vexie-typing i,
    .vexie-teaser { animation: none; }
    .vexie-panel, .vexie-launcher { transition: none; }
    .vexie-messages { scroll-behavior: auto; }
}