#chatbot-container {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: auto;
    font-family: Arial, sans-serif;
    z-index: 999999999;
}

/* Knop rechtsonder */
#chatbot-toggle {
    position: fixed;
    right: 20px;
    bottom: calc(20px + env(safe-area-inset-bottom));
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 50%;
    background: #0073aa;
    color: #fff;
    cursor: pointer;
    font-size: 0;
    font-weight: 700;
    z-index: 999999999;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
    transition: background-color 0.25s ease, transform 0.2s ease;
}

#chatbot-toggle::before {
    content: "\1F4AC";
    display: block;
    width: 60px;
    height: 60px;
    font-size: 25px;
    line-height: 60px;
    text-align: center;
}

#chatbot-toggle:hover {
    background: #005f8d;
    transform: scale(1.05);
}

/* Chatbox staat altijd boven de knop */
#chatbot-box {
    position: fixed;
    right: 20px;
    bottom: calc(95px + env(safe-area-inset-bottom));
    width: 360px;
    height: 520px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 130px);
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 14px 45px rgba(0, 0, 0, 0.28);
    overflow: hidden;
    z-index: 999999998;
    flex-direction: column;
}

/* Header */
#chat-titel,
.chat-titel {
    flex: 0 0 auto;
    padding: 14px 16px;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
    background: linear-gradient(135deg, #0073aa, #005f8d);
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Gesprekken */
#chat-log,
.chat-log {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 14px;
    background: #f6f7f8;
    display: flex;
    flex-direction: column;
    gap: 9px;
    box-sizing: border-box;
}

/* Berichten */
.chat-msg {
    display: flex;
    width: 100%;
    margin: 0;
    padding: 0;
}

.chat-msg > div {
    max-width: 88%;
    padding: 9px 12px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.45;
    word-break: normal;
    overflow-wrap: anywhere;
    box-sizing: border-box;
}

.chat-msg-user {
    justify-content: flex-end;
}

.chat-msg-user > div {
    background: #0073aa;
    color: #fff;
    text-align: left;
    border-bottom-right-radius: 4px;
}

.chat-msg-bot {
    justify-content: flex-start;
}

.chat-msg-bot > div {
    background: #e9ecef;
    color: #111;
    text-align: left;
    border-bottom-left-radius: 4px;
}

.chat-msg span {
    font-weight: 700;
    display: inline-block;
    margin-right: 4px;
}

/* Oude fallback als er nog p-tags gebruikt worden */
#chat-log p {
    margin: 0;
    padding: 9px 12px;
    border-radius: 12px;
    max-width: 88%;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

#chat-log .user {
    align-self: flex-end;
    background: #0073aa;
    color: #fff;
}

#chat-log .bot {
    align-self: flex-start;
    background: #e9ecef;
    color: #111;
}

/* Invoerbalk */
#chat-form {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: #fff;
    border-top: 1px solid #e1e1e1;
    box-sizing: border-box;
}

#chat-input {
    flex: 1 1 auto;
    min-width: 0;
    height: 40px;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 7px;
    font-size: 14px;
    line-height: 1;
    box-sizing: border-box;
    outline: none;
}

#chat-input:focus {
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.15);
}

#chat-send {
    flex: 0 0 auto;
    height: 40px;
    padding: 0 14px;
    border: none;
    background: #0073aa;
    color: #fff;
    border-radius: 7px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

#chat-send:hover {
    background: #005f8d;
}

/* Links */
.chat-msg a,
.chat-log a {
    color: inherit;
    text-decoration: underline !important;
}

/* Typing */
#typing-indicator span::after {
    content: "";
    display: inline-block;
    animation: dots 0.8s steps(3, end) infinite;
}

@keyframes dots {
    0% {
        content: "";
    }

    33% {
        content: ".";
    }

    66% {
        content: "..";
    }

    100% {
        content: "...";
    }
}

/* Mobiel */
@media (max-width: 480px) {
    #chatbot-container {
        right: 14px;
        bottom: 14px;
    }

    #chatbot-toggle {
        right: 14px;
        bottom: calc(14px + env(safe-area-inset-bottom));
        width: 58px;
        height: 58px;
    }

    #chatbot-toggle::before {
        width: 58px;
        height: 58px;
        line-height: 58px;
    }

    #chatbot-box {
        left: 10px;
        right: 10px;
        bottom: calc(86px + env(safe-area-inset-bottom));
        width: auto;
        height: min(520px, calc(100vh - 115px));
        max-width: none;
        max-height: calc(100vh - 115px);
        border-radius: 12px;
    }

    #chat-form {
        padding: 10px;
        gap: 6px;
    }

    #chat-input {
        height: 38px;
        font-size: 14px;
    }

    #chat-send {
        height: 38px;
        padding: 0 11px;
        font-size: 13px;
    }

    .chat-msg > div,
    #chat-log p {
        max-width: 92%;
    }
}