/* ═══════════════════════════════════════════════════════════════
   CleanCalc Chatbot – Styles
   ═══════════════════════════════════════════════════════════════ */

/* ─── Chatbot Bubble (Float Button) ──────────────────────────── */
#chatbot-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9998;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4), 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
    animation: chatbot-pulse 3s ease-in-out infinite;
}

#chatbot-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(59, 130, 246, 0.5), 0 4px 12px rgba(0, 0, 0, 0.15);
}

#chatbot-bubble svg {
    width: 28px;
    height: 28px;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

#chatbot-bubble .chatbot-icon-close {
    position: absolute;
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

#chatbot-bubble.open .chatbot-icon-chat {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

#chatbot-bubble.open .chatbot-icon-close {
    opacity: 1;
    transform: rotate(0) scale(1);
}

/* Notification Badge */
#chatbot-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    transition: opacity 0.3s ease;
}

@keyframes chatbot-pulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4), 0 2px 8px rgba(0, 0, 0, 0.1); }
    50% { box-shadow: 0 4px 28px rgba(59, 130, 246, 0.6), 0 2px 12px rgba(0, 0, 0, 0.15); }
}

/* ─── Chat Window ────────────────────────────────────────────── */
#chatbot-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    z-index: 9999;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 580px;
    max-height: calc(100vh - 140px);
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15), 0 4px 16px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#chatbot-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ─── Header ─────────────────────────────────────────────────── */
.chatbot-header {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.chatbot-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chatbot-header-avatar svg {
    width: 22px;
    height: 22px;
}

.chatbot-header-info {
    flex: 1;
    min-width: 0;
}

.chatbot-header-name {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.2;
}

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

.chatbot-header-status::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    display: inline-block;
}

.chatbot-header-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.chatbot-header-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ─── Messages ───────────────────────────────────────────────── */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8fafc;
    scroll-behavior: smooth;
}

.chatbot-messages::-webkit-scrollbar {
    width: 5px;
}

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

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

.chatbot-msg {
    display: flex;
    gap: 8px;
    max-width: 85%;
    animation: chatbot-msg-in 0.3s ease-out;
}

.chatbot-msg.bot {
    align-self: flex-start;
}

.chatbot-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chatbot-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
}

.chatbot-msg.bot .chatbot-msg-avatar {
    background: #dbeafe;
    color: #3b82f6;
}

.chatbot-msg.user .chatbot-msg-avatar {
    background: #e0e7ff;
    color: #4f46e5;
}

.chatbot-msg-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
}

.chatbot-msg.bot .chatbot-msg-bubble {
    background: #fff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}

.chatbot-msg.user .chatbot-msg-bubble {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}

@keyframes chatbot-msg-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.chatbot-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #94a3b8;
    animation: chatbot-typing-bounce 1.4s infinite ease-in-out;
}

.chatbot-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.chatbot-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatbot-typing-bounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Quick actions / suggested questions */
.chatbot-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 16px 12px;
    flex-shrink: 0;
}

.chatbot-suggestion-btn {
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    white-space: nowrap;
}

.chatbot-suggestion-btn:hover {
    background: #dbeafe;
    border-color: #93c5fd;
}

/* ─── Input Area ─────────────────────────────────────────────── */
.chatbot-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
    flex-shrink: 0;
}

.chatbot-input-wrapper {
    flex: 1;
    position: relative;
}

#chatbot-input {
    width: 100%;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    line-height: 1.4;
    resize: none;
    outline: none;
    background: #f8fafc;
    color: #1e293b;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
    max-height: 100px;
    overflow-y: auto;
}

#chatbot-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    background: #fff;
}

#chatbot-input::placeholder {
    color: #94a3b8;
}

#chatbot-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.2s, transform 0.2s;
}

#chatbot-send:hover {
    opacity: 0.9;
    transform: scale(1.05);
}

#chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

#chatbot-send svg {
    width: 18px;
    height: 18px;
}

/* ─── Branding Footer ────────────────────────────────────────── */
.chatbot-branding {
    text-align: center;
    padding: 6px;
    font-size: 10px;
    color: #94a3b8;
    background: #fff;
    border-top: 1px solid #f1f5f9;
}

.chatbot-branding a {
    color: #3b82f6;
    text-decoration: none;
}

/* ─── Mobile Responsive ──────────────────────────────────────── */
@media (max-width: 480px) {
    #chatbot-window {
        bottom: 0;
        right: 0;
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    #chatbot-bubble {
        bottom: 16px;
        right: 16px;
        width: 54px;
        height: 54px;
    }

    #chatbot-bubble svg {
        width: 24px;
        height: 24px;
    }

    .chatbot-header {
        padding: 14px 16px;
        border-radius: 0;
    }

    .chatbot-messages {
        padding: 12px;
    }
}

/* ─── Dark Mode Support ──────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
    body.dark-mode #chatbot-window,
    .dark-mode #chatbot-window {
        background: #1e293b;
    }

    body.dark-mode .chatbot-messages,
    .dark-mode .chatbot-messages {
        background: #0f172a;
    }

    body.dark-mode .chatbot-msg.bot .chatbot-msg-bubble,
    .dark-mode .chatbot-msg.bot .chatbot-msg-bubble {
        background: #1e293b;
        color: #e2e8f0;
        border-color: #334155;
    }

    body.dark-mode .chatbot-input-area,
    .dark-mode .chatbot-input-area {
        background: #1e293b;
        border-color: #334155;
    }

    body.dark-mode #chatbot-input,
    .dark-mode #chatbot-input {
        background: #0f172a;
        color: #e2e8f0;
        border-color: #334155;
    }

    body.dark-mode .chatbot-branding,
    .dark-mode .chatbot-branding {
        background: #1e293b;
        border-color: #334155;
    }

    body.dark-mode .chatbot-suggestion-btn,
    .dark-mode .chatbot-suggestion-btn {
        background: #1e3a5f;
        color: #93c5fd;
        border-color: #1e40af;
    }
}

/* Mobile: Chatbot-Bubble über den Wizard-Footer verschieben */
@media (max-width: 767px) {
    #chatbot-bubble {
        bottom: 90px !important;
    }
    #chatbot-window {
        bottom: 160px;
        max-height: calc(100vh - 200px);
    }
}
