/* Hivique AI-assistent in de admin. Alleen zichtbaar als de edge beschikbaar is. */
.ai-chat {
    --ai-purple-1: #667eea;
    --ai-purple-2: #764ba2;
    --ai-purple-rgb: 118, 75, 162;
    position: fixed;
    right: var(--sp-5, 1.25rem);
    bottom: var(--sp-5, 1.25rem);
    z-index: 1080;
    font-size: 0.9rem;
}
.ai-chat[hidden] {
    display: none;
}
.ai-chat-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.25rem;
    height: 3.25rem;
    border: none;
    border-radius: 50%;
    padding: 0;
    background: linear-gradient(135deg, var(--ai-purple-1), var(--ai-purple-2));
    color: #fff;
    box-shadow: 0 8px 24px rgba(var(--ai-purple-rgb), 0.38);
}
.ai-chat-toggle:hover {
    filter: brightness(1.07);
}
.ai-chat-toggle .bi-stars {
    font-size: 1.35rem;
}
.ai-chat.is-online .ai-chat-toggle {
    animation: ai-chat-online-pop 0.7s cubic-bezier(0.2, 0.9, 0.25, 1.3);
}
.ai-chat.is-online .ai-chat-toggle::after {
    content: "";
    position: absolute;
    inset: -5px;
    border-radius: 50%;
    border: 2px solid var(--ai-purple-2);
    pointer-events: none;
    animation: ai-chat-online-ring 1.25s ease-out 2;
}
.ai-chat.is-offline .ai-chat-toggle {
    animation: ai-chat-offline 0.28s ease-in forwards;
}
.ai-chat-toggle.is-clicked {
    animation: ai-chat-click-pop 0.34s cubic-bezier(0.2, 0.9, 0.25, 1.3);
}
@keyframes ai-chat-online-pop {
    0% { transform: scale(0.72); opacity: 0.4; }
    55% { transform: scale(1.09); opacity: 1; }
    100% { transform: scale(1); }
}
@keyframes ai-chat-online-ring {
    0% { transform: scale(0.82); opacity: 0.65; }
    100% { transform: scale(1.45); opacity: 0; }
}
@keyframes ai-chat-offline {
    to { transform: scale(0.7); opacity: 0; }
}
@keyframes ai-chat-click-pop {
    0% { transform: scale(1); }
    45% { transform: scale(0.9); }
    100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
    .ai-chat.is-online .ai-chat-toggle,
    .ai-chat.is-offline .ai-chat-toggle,
    .ai-chat-toggle.is-clicked {
        animation: none;
    }
    .ai-chat.is-online .ai-chat-toggle::after { display: none; }
}
.ai-chat-panel {
    position: absolute;
    right: 0;
    bottom: 3.6rem;
    width: min(390px, calc(100vw - 2rem));
    max-height: min(70vh, 580px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
    border: 0;
    border-radius: 16px;
    box-shadow: 0 18px 48px rgba(29, 27, 32, 0.22);
}
.ai-chat-panel[hidden] {
    display: none;
}
.ai-chat-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    background: linear-gradient(135deg, var(--ai-purple-1), var(--ai-purple-2));
    color: #fff;
}
.ai-chat-header strong {
    display: block;
    line-height: 1.2;
}
.ai-chat-header small {
    display: block;
    opacity: 0.8;
    font-size: 0.75rem;
    margin-top: 0.15rem;
}
.ai-chat-header-actions {
    display: flex;
    gap: 0.1rem;
}
.ai-chat-header-actions .btn-link {
    color: #fff;
    text-decoration: none;
    padding: 0.1rem 0.35rem;
    line-height: 1;
}
.ai-chat-messages {
    flex: 1 1 auto;
    min-height: 150px;
    overflow-y: auto;
    padding: 0.9rem;
    background: #f7f8fa;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}
.ai-chat-message {
    max-width: 88%;
    padding: 0.55rem 0.7rem;
    border-radius: 12px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.35;
}
.ai-chat-message-bot {
    align-self: flex-start;
    background: #fff;
    border: 1px solid rgba(29, 27, 32, 0.08);
}
.ai-chat-message-user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--ai-purple-1), var(--ai-purple-2));
    color: #fff;
}
.ai-chat-message-error {
    align-self: flex-start;
    background: #f8d7da;
    color: #842029;
}
.ai-chat-message-pending {
    align-self: flex-start;
    color: #6c757d;
    font-style: italic;
}
.ai-chat-typing {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 18px;
    padding: 0.7rem 0.85rem;
}
.ai-chat-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ai-purple-2);
    animation: ai-chat-dot-bounce 1.15s ease-in-out infinite;
}
.ai-chat-dot:nth-child(2) { animation-delay: 0.14s; }
.ai-chat-dot:nth-child(3) { animation-delay: 0.28s; }
.ai-chat-message.is-typing::after {
    content: "▍";
    margin-left: 1px;
    color: var(--ai-purple-2);
    animation: ai-chat-caret 0.8s steps(1) infinite;
}
.ai-chat-message a {
    color: var(--ai-purple-2);
    font-weight: 600;
    text-decoration: underline;
    overflow-wrap: anywhere;
}
.ai-chat-product-preview {
    display: block;
    margin-top: 0.55rem;
    border-radius: 9px;
    overflow: hidden;
    line-height: 0;
    border: 1px solid rgba(29, 27, 32, 0.08);
}
.ai-chat-product-preview img {
    display: block;
    width: 100%;
    max-height: 170px;
    object-fit: cover;
}
.ai-chat-message a:hover {
    color: var(--ai-purple-1);
}
@keyframes ai-chat-dot-bounce {
    0%, 70%, 100% { transform: translateY(0); opacity: 0.38; }
    35% { transform: translateY(-4px); opacity: 1; }
}
@keyframes ai-chat-caret {
    50% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
    .ai-chat-dot { animation: none; opacity: 1; }
    .ai-chat-message.is-typing::after { display: none; }
}
.ai-chat-form {
    display: flex;
    gap: 0.4rem;
    align-items: flex-end;
    padding: 0.7rem 0.9rem;
    border-top: 1px solid rgba(29, 27, 32, 0.08);
}
.ai-chat-form textarea {
    resize: none;
    min-height: 42px;
    max-height: 110px;
    font-size: 0.88rem;
}
.ai-chat-form .btn {
    flex: 0 0 auto;
}
.ai-chat-form .btn-primary {
    background: linear-gradient(135deg, var(--ai-purple-1), var(--ai-purple-2));
    border-color: transparent;
}
.ai-chat-form .btn-primary:hover {
    filter: brightness(1.07);
}
.ai-chat-note {
    padding: 0 0.9rem 0.65rem;
    color: #6c757d;
    font-size: 0.7rem;
}
.ai-chat-disclaimer {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    padding: 0.5rem 0.9rem;
    background: rgba(255, 193, 7, 0.14);
    color: #6c5b1e;
    font-size: 0.72rem;
    line-height: 1.35;
}
.ai-chat-disclaimer i {
    flex: 0 0 auto;
    margin-top: 0.08rem;
}
.ai-chat-disclaimer-top {
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.ai-chat-disclaimer-bottom {
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}
@media (max-width: 575.98px) {
    .ai-chat {
        right: 0.75rem;
        bottom: 0.75rem;
    }
    .ai-chat-panel {
        width: calc(100vw - 1.5rem);
        max-height: 72vh;
    }
}
