/* =========================================================
   Chat widget — mascot button + conversational pop-over
   ========================================================= */

:root {
    --chat-bg:        rgba(18, 20, 30, 0.92);
    --chat-border:    rgba(155, 107, 255, 0.35);
    --chat-accent:    #9b6bff;
    --chat-accent-2:  #5ee0c1;
    --chat-text:      #e8eaf2;
    --chat-muted:     #8e93a8;
    --chat-bubble-bot: rgba(155, 107, 255, 0.12);
    --chat-bubble-me:  linear-gradient(135deg, #9b6bff 0%, #6cb8ff 100%);
}

/* ---------- Mascot button ---------- */
#mascot {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 9998;
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.55rem 0.4rem 1rem;
    background: linear-gradient(135deg, rgba(155, 107, 255, 0.92), rgba(108, 184, 255, 0.92));
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 999px;
    box-shadow:
        0 10px 30px rgba(155, 107, 255, 0.35),
        0 4px 12px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease, opacity 0.25s ease;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

#mascot:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow:
        0 14px 36px rgba(155, 107, 255, 0.5),
        0 6px 16px rgba(0, 0, 0, 0.3);
}

#mascot:focus-visible {
    outline: 2px solid var(--chat-accent-2);
    outline-offset: 3px;
}

#mascot img {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    object-fit: cover;
    background: #fff;
    border: 2px solid rgba(255, 255, 255, 0.4);
}

#mascot .mascot-bubble {
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

#mascot.is-hidden {
    opacity: 0;
    transform: translateY(20px) scale(0.8);
    pointer-events: none;
}

/* Speels nudge-animatietje */
@keyframes chat-nudge {
    0%, 100% { transform: translateY(0) rotate(0); }
    20%      { transform: translateY(-6px) rotate(-3deg); }
    40%      { transform: translateY(0) rotate(2deg); }
    60%      { transform: translateY(-3px) rotate(-1deg); }
}
#mascot.is-nudge:not(:hover):not(.is-hidden) {
    animation: chat-nudge 1.6s ease-in-out 1;
}

/* ---------- Chat widget ---------- */
.chat-widget {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 9999;
    width: min(380px, calc(100vw - 2rem));
    max-height: min(640px, calc(100vh - 2rem));
    display: flex;
    flex-direction: column;
    background: var(--chat-bg);
    color: var(--chat-text);
    border: 1px solid var(--chat-border);
    border-radius: 20px;
    box-shadow:
        0 30px 70px rgba(0, 0, 0, 0.5),
        0 10px 30px rgba(155, 107, 255, 0.25);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.28s ease, transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
    font-family: inherit;
}

.chat-widget.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Header */
.chat-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    background: linear-gradient(135deg, rgba(155, 107, 255, 0.25), rgba(108, 184, 255, 0.15));
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.chat-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
}

.chat-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    background: #fff;
    border: 2px solid rgba(255, 255, 255, 0.35);
}

.chat-status-dot {
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #5ee0c1;
    border: 2px solid var(--chat-bg);
    box-shadow: 0 0 0 0 rgba(94, 224, 193, 0.6);
    animation: chat-pulse 2.2s infinite;
}

@keyframes chat-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(94, 224, 193, 0.6); }
    70%  { box-shadow: 0 0 0 10px rgba(94, 224, 193, 0); }
    100% { box-shadow: 0 0 0 0 rgba(94, 224, 193, 0); }
}

.chat-header-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    flex: 1 1 auto;
    min-width: 0;
}

.chat-header-text strong {
    font-size: 1rem;
    color: #fff;
}

.chat-header-text span {
    font-size: 0.75rem;
    color: var(--chat-muted);
}

.chat-close {
    background: transparent;
    border: none;
    color: var(--chat-text);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}
.chat-close:hover { background: rgba(255, 255, 255, 0.08); }
.chat-close:focus-visible {
    outline: 2px solid var(--chat-accent-2);
    outline-offset: 2px;
}

/* Body */
.chat-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    scroll-behavior: smooth;
}

.chat-body::-webkit-scrollbar { width: 6px; }
.chat-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 999px;
}

/* Messages */
.chat-msg {
    display: flex;
    max-width: 100%;
    animation: chat-in 0.28s ease both;
}
.chat-msg-bot  { justify-content: flex-start; }
.chat-msg-me   { justify-content: flex-end; }

@keyframes chat-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.chat-bubble {
    max-width: 85%;
    padding: 0.6rem 0.85rem;
    border-radius: 16px;
    font-size: 0.92rem;
    line-height: 1.4;
    word-wrap: break-word;
}

.chat-msg-bot .chat-bubble {
    background: var(--chat-bubble-bot);
    border: 1px solid rgba(155, 107, 255, 0.25);
    border-top-left-radius: 4px;
    color: var(--chat-text);
}

.chat-msg-me .chat-bubble {
    background: var(--chat-bubble-me);
    color: #fff;
    border-top-right-radius: 4px;
    box-shadow: 0 6px 18px rgba(155, 107, 255, 0.35);
}

.chat-bubble a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.chat-bubble code {
    background: rgba(0, 0, 0, 0.25);
    padding: 0.05rem 0.4rem;
    border-radius: 6px;
    font-size: 0.85em;
}

/* Typing indicator */
.chat-typing { display: inline-flex; gap: 4px; align-items: center; }
.chat-typing span {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--chat-accent);
    opacity: 0.5;
    animation: chat-blink 1s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chat-blink {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.35; }
    40%           { transform: scale(1);   opacity: 1; }
}

/* Quick-reply options */
.chat-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    padding: 0.65rem 0.9rem 0.9rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(0, 0, 0, 0.18);
}

.chat-options:empty { display: none; }

.chat-option {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.85rem;
    background: rgba(155, 107, 255, 0.14);
    color: var(--chat-text);
    border: 1px solid rgba(155, 107, 255, 0.4);
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: inherit;
    transition: background 0.2s ease, transform 0.15s ease, border-color 0.2s ease;
}

.chat-option:hover {
    background: rgba(155, 107, 255, 0.28);
    border-color: var(--chat-accent);
    transform: translateY(-1px);
}

.chat-option:focus-visible {
    outline: 2px solid var(--chat-accent-2);
    outline-offset: 2px;
}

.chat-option i { font-size: 0.95rem; }

.chat-option-ghost {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.18);
    color: var(--chat-muted);
}
.chat-option-ghost:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--chat-text);
}

.chat-option-primary {
    background: linear-gradient(135deg, #9b6bff, #6cb8ff);
    border-color: transparent;
    color: #fff;
}
.chat-option-primary:hover {
    filter: brightness(1.08);
}

/* Free-form form */
.chat-form {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    width: 100%;
}

.chat-form label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.78rem;
    color: var(--chat-muted);
}

.chat-form input,
.chat-form textarea {
    width: 100%;
    padding: 0.5rem 0.7rem;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    color: var(--chat-text);
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.chat-form input:focus,
.chat-form textarea:focus {
    outline: none;
    border-color: var(--chat-accent);
    background: rgba(0, 0, 0, 0.45);
}

.chat-form-actions {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.2rem;
}

/* Footer */
.chat-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 0.75rem;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.72rem;
    color: var(--chat-muted);
}
.chat-footer i { color: var(--chat-accent-2); }

/* Small screens */
@media (max-width: 480px) {
    .chat-widget {
        right: 0.5rem;
        bottom: 0.5rem;
        left: 0.5rem;
        width: auto;
        max-height: calc(100vh - 1rem);
    }
    #mascot {
        right: 0.75rem;
        bottom: 0.75rem;
    }
    #mascot .mascot-bubble { display: none; }
    #mascot { padding: 0.3rem; }
}

@media (prefers-reduced-motion: reduce) {
    #mascot, .chat-widget, .chat-msg, .chat-status-dot, .chat-typing span {
        animation: none !important;
        transition: none !important;
    }
}

