:root {
    --chatbot-primary: #4f46e5;
    --chatbot-primary-hover: #4338ca;
    --chatbot-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --chatbot-bg: rgba(255, 255, 255, 0.85);
    --chatbot-text: #1f2937;
    --chatbot-text-muted: #6b7280;
    --chatbot-border: rgba(229, 231, 235, 0.6);
    --chatbot-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04), 0 0 40px rgba(79, 70, 229, 0.07);
    --chatbot-bot-bg: #f3f4f6;
    --chatbot-bot-text: #1f2937;
    --chatbot-user-bg: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    --chatbot-user-text: #ffffff;
    --chatbot-glass-border: rgba(255, 255, 255, 0.4);
}

@media (prefers-color-scheme: dark) {
    :root {
        --chatbot-bg: rgba(17, 24, 39, 0.85);
        --chatbot-text: #f9fafb;
        --chatbot-text-muted: #9ca3af;
        --chatbot-border: rgba(55, 65, 81, 0.6);
        --chatbot-bot-bg: #1f2937;
        --chatbot-bot-text: #f3f4f6;
        --chatbot-glass-border: rgba(255, 255, 255, 0.08);
    }
}

/* Container */
#typo3-chatbot-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Chat Bubble (Closed State) */
#typo3-chatbot-bubble {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: 50px;
    background: var(--chatbot-primary-color, var(--chatbot-gradient));
    color: var(--chatbot-text-color, #ffffff);
    border: none;
    cursor: pointer;
    box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.4), 0 4px 6px -2px rgba(79, 70, 229, 0.2);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform: scale(1);
    outline: none;
}

.chatbot-bubble-custom-icon {
    width: 32px;
    height: 32px;
    background-image: var(--chatbot-bubble-icon-url, url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ffffff'%3E%3Cpath d='M20 2H4c-1.1 0-1.99.9-1.99 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zM6 9h12v2H6V9zm8 5H6v-2h8v2zm4-6H6V6h12v2z'/%3E%3C/svg%3E"));
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    display: inline-block;
}

#typo3-chatbot-bubble:hover {
    transform: scale(1.08) translateY(-3px);
    box-shadow: 0 20px 25px -5px rgba(79, 70, 229, 0.5), 0 10px 10px -5px rgba(79, 70, 229, 0.3);
}

#typo3-chatbot-bubble:active {
    transform: scale(0.95);
}

#typo3-chatbot-bubble svg {
    transition: transform 0.3s ease;
}

#typo3-chatbot-bubble:hover svg {
    transform: rotate(5deg);
}

/* Chat Window (Open State) */
#typo3-chatbot-window {
    position: absolute;
    bottom: 76px;
    right: 0;
    width: 380px;
    height: 520px;
    display: flex;
    flex-direction: column;
    background: var(--chatbot-bg-color, var(--chatbot-bg));
    border: 1px solid var(--chatbot-border);
    border-top: 1px solid var(--chatbot-glass-border);
    border-left: 1px solid var(--chatbot-glass-border);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--chatbot-shadow);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    transform-origin: bottom right;
}

#typo3-chatbot-window.chatbot-hidden {
    opacity: 0;
    visibility: hidden;
    transform: scale(0.8) translateY(30px);
    pointer-events: none;
}

/* Header */
#typo3-chatbot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--chatbot-primary-color, var(--chatbot-gradient));
    color: var(--chatbot-text-color, #ffffff);
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-header-avatar-img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-image: var(--chatbot-avatar-url, url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ffffff'%3E%3Cpath d='M12 2a5 5 0 1 0 5 5 5 5 0 0 0-5-5zm0 12c-4.42 0-8 2.24-8 5v3h16v-3c0-2.76-3.58-5-8-5z'/%3E%3C/svg%3E"));
    background-size: cover;
    background-position: center;
    /* border: 2px solid rgba(255, 255, 255, 0.4); */
    display: inline-block;
}

.chatbot-header-avatar {
    font-size: 24px;
    display: inline-block;
    animation: wave 2.5s infinite;
    transform-origin: 70% 70%;
}

@keyframes wave {
    0% { transform: rotate(0deg); }
    10% { transform: rotate(14deg); }
    20% { transform: rotate(-8deg); }
    30% { transform: rotate(14deg); }
    40% { transform: rotate(-4deg); }
    50% { transform: rotate(10deg); }
    60% { transform: rotate(0deg); }
    100% { transform: rotate(0deg); }
}

#typo3-chatbot-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--chatbot-text-color, #ffffff);
}

.chatbot-header-status {
    font-size: 12px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 5px;
}

.chatbot-header-status::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background-color: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.4);
}

#typo3-chatbot-close {
    background: transparent;
    border: none;
    color: #ffffff;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s, transform 0.2s;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

#typo3-chatbot-close:hover {
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.15);
    transform: rotate(90deg);
}

/* Chat Messages */
#typo3-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

/* Scrollbar styling */
#typo3-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

#typo3-chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

#typo3-chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

#typo3-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Chat Bubbles */
.chatbot-message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    animation: messageFadeIn 0.3s cubic-bezier(0.165, 0.84, 0.44, 1) forwards;
}

@keyframes messageFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chatbot-message-bot {
    align-self: flex-start;
    background-color: var(--chatbot-bot-bubble, var(--chatbot-bot-bg));
    color: var(--chatbot-bot-text, #1f2937);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.chatbot-message-user {
    align-self: flex-end;
    background: var(--chatbot-user-bubble, var(--chatbot-user-bg));
    color: var(--chatbot-user-text, #ffffff);
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.15);
}

.chatbot-message-sources {
    margin-top: 6px;
    font-size: 11px;
    opacity: 0.7;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Conversation Starters (Predefined Questions) */
.chatbot-suggested-questions-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
    margin-bottom: 8px;
    align-self: flex-start;
    width: 90%;
    animation: messageFadeIn 0.3s cubic-bezier(0.165, 0.84, 0.44, 1) forwards;
}

.chatbot-suggested-q-btn {
    border: 1px solid var(--chatbot-primary-color, var(--chatbot-primary));
    background: rgba(255, 255, 255, 0.95);
    color: var(--chatbot-primary-color, var(--chatbot-primary));
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.165, 0.84, 0.44, 1);
    font-weight: 500;
    width: 100%;
    box-sizing: border-box;
    font-family: inherit;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
    border-bottom-left-radius: 4px;
}

.chatbot-suggested-q-btn:hover {
    background: var(--chatbot-primary-color, var(--chatbot-primary));
    color: var(--chatbot-text-color, #ffffff);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.08);
}

.chatbot-suggested-q-btn:active {
    transform: translateY(0);
}

@media (prefers-color-scheme: dark) {
    .chatbot-suggested-q-btn {
        background: rgba(31, 41, 55, 0.95);
        color: #818cf8;
        border-color: rgba(129, 140, 248, 0.5);
    }
    .chatbot-suggested-q-btn:hover {
        background: #818cf8;
        color: #ffffff;
    }
}

/* Typing Indicator */
.chatbot-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 4px 0;
    align-items: center;
}

.chatbot-typing-dot {
    width: 6px;
    height: 6px;
    background-color: var(--chatbot-text-muted);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.chatbot-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.chatbot-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Chat Input Form */
#typo3-chatbot-form {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid var(--chatbot-border);
    background: rgba(255, 255, 255, 0.2);
}

#typo3-chatbot-input {
    flex: 1;
    border: 1px solid var(--chatbot-border);
    border-radius: 30px;
    padding: 10px 18px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.9);
    color: #1f2937;
    outline: none;
    transition: all 0.2s ease;
}

@media (prefers-color-scheme: dark) {
    #typo3-chatbot-input {
        background: rgba(31, 41, 55, 0.9);
        color: #f9fafb;
    }
}

#typo3-chatbot-input:focus {
    border-color: var(--chatbot-primary);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
}

#typo3-chatbot-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--chatbot-primary-color, var(--chatbot-gradient));
    color: var(--chatbot-text-color, #ffffff);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

#typo3-chatbot-submit:hover {
    transform: scale(1.05);
    background: var(--chatbot-primary-hover);
}

#typo3-chatbot-submit:active {
    transform: scale(0.95);
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    #typo3-chatbot-container {
        bottom: 16px;
        right: 16px;
    }
    
    #typo3-chatbot-window {
        bottom: 0;
        right: 0;
        width: calc(100vw - 32px);
        height: calc(100vh - 100px);
        max-height: 580px;
    }
}

/* Sidebar Layout overrides (Ask Nuxi style) */
#typo3-chatbot-window.chatbot-window-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 400px;
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border: none;
    border-left: 1px solid var(--chatbot-border);
    margin: 0;
    box-shadow: -4px 0 30px rgba(0, 0, 0, 0.15);
    z-index: 100000;
    transform: translateX(0);
}

/* Slide animation for sidebar */
#typo3-chatbot-window.chatbot-window-sidebar.chatbot-hidden {
    transform: translateX(100%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

@media (max-width: 480px) {
    #typo3-chatbot-window.chatbot-window-sidebar {
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
    }
}

/* Custom Header Trigger Button Style (Ask Assistant) */
.typo3-chatbot-trigger {
    background: var(--chatbot-primary-color, var(--chatbot-gradient));
    color: var(--chatbot-text-color, #ffffff);
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
    transition: transform 0.2s ease, opacity 0.2s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.typo3-chatbot-trigger:hover {
    transform: translateY(-1px);
    opacity: 0.95;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.typo3-chatbot-trigger:active {
    transform: translateY(0);
}

.typo3-chatbot-trigger svg {
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.typo3-chatbot-trigger:hover svg {
    transform: rotate(10deg) scale(1.05);
}
