/* ==========================================================================
   CHATBOT - InfinitySpace42 Chat Component
   ========================================================================== */

/* ==================== CONTAINER ==================== */

.infinity-chatbot-container {
    position: fixed;
    bottom: 1.75rem;
    right: 1.75rem;
    z-index: 12000;
    display: none;
    flex-direction: column;
    width: 380px;
    max-width: calc(100vw - 2.5rem);
    height: calc(100vh - 100px);
    max-height: calc(100vh - 100px);
    border-radius: var(--radius-xl);
    background: rgba(2, 6, 23, 0.97);
    border: 1px solid var(--cyan-25);
    box-shadow: 0 24px 60px rgba(3, 7, 18, 0.6);
    overflow: hidden;
}

.infinity-chatbot-container.is-visible {
    display: flex;
}

/* Hide floating button when chat is open */
.infinity-chatbot-container.is-visible ~ .infinity-chatbot-floating-button,
body:has(.infinity-chatbot-container.is-visible) .infinity-chatbot-floating-button {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: scale(0) !important;
}

/* ==================== WRAPPER ==================== */

.chatbot-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* ==================== HEADER ==================== */

.chatbot-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: var(--space-md) 1.25rem;
    background: linear-gradient(135deg, var(--cyan-15), rgba(59, 130, 246, 0.18));
    border-bottom: 1px solid var(--cyan-20);
}

.chatbot-title {
    font-size: var(--font-size-base);
    font-weight: 700;
    color: #f8fafc;
    flex: 1 1 auto;
}

.chatbot-close {
    background: transparent;
    border: none;
    color: rgba(226, 232, 240, 0.8);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    transition: color var(--transition-base);
}

.chatbot-close:hover {
    color: var(--text-white);
}

/* ==================== TABS ==================== */

.chatbot-tabs-wrapper {
    display: inline-flex;
    gap: var(--space-sm);
}

.chatbot-tab {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid transparent;
    color: rgba(226, 232, 240, 0.85);
    padding: 0.35rem 0.85rem;
    border-radius: var(--radius-full);
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all var(--transition-base);
}

.chatbot-tab.is-active {
    background: var(--cyan-15);
    border-color: var(--cyan-35);
}

/* ==================== MAIN (Message-Bereich) ==================== */

.chatbot-main {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* ==================== MESSAGES ==================== */

.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.chat-message {
    line-height: var(--line-height-base);
}

.chat-message.bot {
    align-self: flex-start;
    background: var(--cyan-10);
    border: 1px solid var(--cyan-20);
    color: var(--text-light);
}

.chat-message.user {
    align-self: flex-end;
    background: var(--gradient-cyan-purple);
    color: var(--bg-dark);
}

/* ==================== FOOTER ==================== */

.chatbot-footer {
    border-top: 1px solid var(--cyan-15);
    padding: 0.5rem 0.75rem 0.75rem;
}

.chatbot-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.chatbot-action {
    flex: 1;
    padding: 0.4rem 0.5rem;
    border-radius: var(--radius-full);
    border: 1px solid var(--cyan-25);
    background: rgba(15, 23, 42, 0.5);
    color: rgba(226, 232, 240, 0.85);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    white-space: nowrap;
}

.chatbot-action:hover {
    background: var(--cyan-15);
    border-color: var(--cyan-35);
    color: var(--text-white);
}

.chatbot-input-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* ==================== INPUT ==================== */

.chatbot-input-area {
    padding: var(--space-md);
    border-top: 1px solid var(--cyan-15);
    display: flex;
    gap: var(--space-sm);
}

.chatbot-input {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-full);
    border: 1px solid var(--cyan-30);
    background: rgba(15, 23, 42, 0.6);
    color: var(--text-white);
    font-size: var(--font-size-base);
}

.chatbot-input:focus {
    outline: none;
    border-color: var(--primary-cyan);
    box-shadow: 0 0 0 3px var(--cyan-15);
}

.chatbot-send {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    background: var(--gradient-cyan-purple);
    border: none;
    color: var(--bg-dark);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition-base);
}

.chatbot-send:hover {
    transform: scale(1.05);
}

/* Mic Button */
.chatbot-mic {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: var(--text-white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all var(--transition-base);
}
.chatbot-mic:hover {
    background: rgba(99, 102, 241, 0.25);
    border-color: rgba(99, 102, 241, 0.5);
}
.chatbot-mic.listening {
    background: rgba(239, 68, 68, 0.25);
    border-color: rgba(239, 68, 68, 0.5);
    animation: mic-pulse 1.5s infinite;
}
@keyframes mic-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

/* ==================== FLOATING BUTTON ==================== */

.infinity-chatbot-floating-button {
    position: fixed;
    bottom: 1.75rem;
    right: 1.75rem;
    width: 60px;
    height: 60px;
    border-radius: var(--radius-full);
    background: var(--gradient-cyan-purple);
    border: none;
    cursor: pointer;
    box-shadow: var(--shadow-glow-md);
    z-index: 11000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.infinity-chatbot-floating-button:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-glow-lg);
}

/* ==================== MOBILE ==================== */

@media (max-width: 768px) {
    .infinity-chatbot-container {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .infinity-chatbot-floating-button {
        bottom: 1rem;
        right: 1rem;
        width: 56px;
        height: 56px;
    }
}

/* ==================== THINKING & TYPING ANIMATION ==================== */

.emma-thinking {
    color: rgba(226, 232, 240, 0.85);
    font-style: italic;
    font-size: 0.9rem;
}

.thinking-dots::after {
    content: '';
    animation: thinking-dots 1.5s steps(4, end) infinite;
}

@keyframes thinking-dots {
    0%  { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
}

.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 4px 0;
    align-items: center;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: rgba(0, 255, 204, 0.6);
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
.typing-indicator span:nth-child(3) { animation-delay: 0s; }

@keyframes typing-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ==================== MOBILE TOOLBAR INTEGRATION ==================== */
/* Floating Button ausblenden wenn Mobile-Toolbar aktiv ist */

@media (max-width: 900px) {
    .infinity-chatbot-floating-button {
        display: none !important;
    }

    /* Chat Container: Beruecksichtigt Toolbar-Hoehe */
    .infinity-chatbot-container {
        height: calc(100vh - 72px - env(safe-area-inset-bottom, 0px));
        max-height: calc(100vh - 72px - env(safe-area-inset-bottom, 0px));
    }
}
