/* Chatbot Wrapper */
.chatbot-wrapper {
    position: fixed;
    bottom: 25px;
    right: 38px;
    z-index: 9999;
    font-family: var(--font-primary, 'Inter', sans-serif);
}

/* Floating Button */
.chatbot-btn {
    width: 75px;
    height: 75px;
    background: transparent;
    padding: 0;
    color: #fff;
    border: none;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.chatbot-btn:hover {
    transform: translateY(-5px) scale(1.05);
}
[data-theme="dark"] .chatbot-btn {
    background: transparent;
}

/* Axel Hide/Show Toggle Arrow Button - Pinned to right screen edge so it NEVER covers Axel */
.axel-toggle-btn {
    position: fixed;
    right: 0;
    bottom: 45px;
    width: 24px;
    height: 38px;
    border-radius: 10px 0 0 10px;
    background: var(--bg-card, #ffffff);
    color: var(--primary, #10b981);
    border: 1.5px solid var(--primary, #10b981);
    border-right: none;
    box-shadow: -2px 3px 10px rgba(0, 0, 0, 0.14);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    z-index: 10001;
    padding: 0;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.axel-toggle-btn:hover {
    background: var(--primary, #10b981);
    color: #ffffff;
    width: 30px;
    box-shadow: -3px 4px 14px rgba(16, 185, 129, 0.35);
}
[data-theme="dark"] .axel-toggle-btn {
    background: var(--bg-card, #1a1d21);
    color: var(--primary, #10b981);
    border-color: var(--primary, #10b981);
    box-shadow: -2px 3px 10px rgba(0, 0, 0, 0.45);
}
[data-theme="dark"] .axel-toggle-btn:hover {
    background: var(--primary, #10b981);
    color: #ffffff;
}

/* Axel Collapsed/Hidden State */
.chatbot-wrapper.axel-hidden .chatbot-btn {
    transform: translateX(120px) scale(0.5);
    opacity: 0;
    pointer-events: none;
}
.chatbot-wrapper.axel-hidden .chatbot-window {
    display: none !important;
}
.chatbot-wrapper.axel-hidden .axel-toggle-btn {
    width: 28px;
    height: 42px;
    background: var(--bg-card, #ffffff);
    color: var(--primary, #10b981);
    box-shadow: -4px 4px 14px rgba(0, 0, 0, 0.18);
}
.chatbot-wrapper.axel-hidden .axel-toggle-btn:hover {
    width: 36px;
    background: var(--primary, #10b981);
    color: #ffffff;
}
[data-theme="dark"] .chatbot-wrapper.axel-hidden .axel-toggle-btn {
    background: var(--bg-card, #1a1d21);
    color: var(--primary, #10b981);
}

/* Chat Window Modal */
.chatbot-window {
    position: absolute;
    bottom: 0;
    right: 95px;
    width: 290px;
    max-width: calc(100vw - 160px);
    max-height: 400px;
    background: var(--bg-card, #ffffff);
    border-radius: 20px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transform: scale(0);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
    border: 1px solid var(--border-color, rgba(0,0,0,0.05));
    pointer-events: none;
}
.chatbot-window.active {
    transform: scale(1);
    opacity: 1;
    pointer-events: all;
}

[data-theme="dark"] .chatbot-window {
    background: var(--bg-card, #1a1d21);
    border-color: rgba(255,255,255,0.08);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
}

/* Header */
.chatbot-header {
    background: var(--primary-main, #2c3e50);
    color: #fff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
[data-theme="dark"] .chatbot-header {
    background: var(--bg-main, #121417);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}
.chatbot-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #fff;
    padding: 3px;
    color: var(--primary-main, #2c3e50);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
[data-theme="dark"] .chatbot-avatar {
    background: rgba(255,255,255,0.1);
    color: #fff;
}
.chatbot-name {
    font-weight: 600;
    font-size: 1rem;
    line-height: 1.2;
    letter-spacing: 0.3px;
}
.chatbot-status {
    font-size: 0.75rem;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2ecc71;
    display: inline-block;
    box-shadow: 0 0 5px rgba(46, 204, 113, 0.5);
}

.chatbot-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap;
}
.chatbot-controls button {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
    transition: color 0.2s ease, transform 0.2s ease;
}
.chatbot-controls button:hover {
    color: #fff;
    transform: scale(1.1);
}

/* Chat Body */
.chatbot-body {
    flex: 1;
    height: 230px;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bg-main, #f8f9fa);
    scroll-behavior: smooth;
}
[data-theme="dark"] .chatbot-body {
    background: var(--bg-card, #1a1d21);
}

.chatbot-body::-webkit-scrollbar {
    width: 6px;
}
.chatbot-body::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.15);
    border-radius: 10px;
}
[data-theme="dark"] .chatbot-body::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
}

.chat-msg {
    max-width: 85%;
    display: flex;
    flex-direction: column;
    animation: fadeInMsg 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes fadeInMsg {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-msg.bot {
    align-self: flex-start;
}
.chat-msg.user {
    align-self: flex-end;
    align-items: flex-end;
}

.chat-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.85rem;
    line-height: 1.4;
    word-wrap: break-word;
}

.chat-msg.bot .chat-bubble {
    background: #fff;
    color: var(--text-main, #2c3e50);
    border-bottom-left-radius: 6px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.03);
    border: 1px solid var(--border-color, rgba(0,0,0,0.06));
}
[data-theme="dark"] .chat-msg.bot .chat-bubble {
    background: #2a2d32;
    color: var(--text-main, #f0f0f0);
    border-color: rgba(255,255,255,0.06);
}

.chat-msg.user .chat-bubble {
    background: var(--primary-main, #2c3e50);
    color: #fff;
    border-bottom-right-radius: 6px;
    box-shadow: 0 3px 10px rgba(44, 62, 80, 0.2);
}
[data-theme="dark"] .chat-msg.user .chat-bubble {
    background: var(--primary-light, #34495e);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}

/* Typing Indicator */
.typing-indicator {
    display: none;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: #fff;
    border-radius: 16px;
    border-bottom-left-radius: 6px;
    width: fit-content;
    border: 1px solid var(--border-color, rgba(0,0,0,0.06));
    box-shadow: 0 3px 10px rgba(0,0,0,0.03);
}
[data-theme="dark"] .typing-indicator {
    background: #2a2d32;
    border-color: rgba(255,255,255,0.06);
}
.typing-indicator span {
    width: 7px;
    height: 7px;
    background: #a0a0a0;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}
.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* Input Area */
.chatbot-footer {
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid var(--border-color, rgba(0,0,0,0.06));
    display: flex;
    align-items: center;
    gap: 6px; /* Reduced gap to fit mic button */
}
[data-theme="dark"] .chatbot-footer {
    background: var(--bg-card, #1a1d21);
    border-color: rgba(255,255,255,0.08);
}

.chat-input {
    flex: 1;
    min-width: 0; /* Prevents intrinsic input width from blowing out flex container */
    box-sizing: border-box;
    border: 1px solid transparent;
    outline: none;
    background: var(--bg-main, #f4f6f8);
    padding: 10px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--text-main, #333);
    transition: border-color 0.3s ease, background 0.3s ease;
}
.chat-input:focus {
    border-color: var(--primary-main, #2c3e50);
    background: #fff;
}
[data-theme="dark"] .chat-input {
    background: #212429;
    color: var(--text-main, #eee);
}
[data-theme="dark"] .chat-input:focus {
    border-color: var(--primary-light, #34495e);
    background: #2a2d32;
}

.chat-send-btn {
    background: var(--primary-main, #2c3e50);
    color: #fff;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
    flex-shrink: 0;
    transition: background 0.2s ease, transform 0.2s ease;
}
.chat-send-btn:hover {
    background: var(--primary-dark, #1a252f);
    transform: scale(1.05);
}
[data-theme="dark"] .chat-send-btn {
    background: var(--primary-light, #34495e);
}
[data-theme="dark"] .chat-send-btn:hover {
    background: var(--primary-main, #2c3e50);
}

/* Quick Replies */
.quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}
.quick-reply-btn {
    background: transparent;
    border: 1px solid var(--primary-main, #2c3e50);
    color: var(--primary-main, #2c3e50);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}
.quick-reply-btn:hover {
    background: var(--primary-main, #2c3e50);
    color: #fff;
    transform: translateY(-2px);
}
[data-theme="dark"] .quick-reply-btn {
    border-color: var(--primary-light, #6c7a89);
    color: var(--primary-light, #d1d5db);
}
[data-theme="dark"] .quick-reply-btn:hover {
    background: var(--primary-light, #34495e);
    color: #fff;
    border-color: var(--primary-light, #34495e);
}

/* Mobile Responsiveness */
@media (max-width: 576px) {
    .chatbot-btn {
        width: 65px;
        height: 65px;
        padding: 0;
    }
    .chatbot-window {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 100dvh !important;
        max-width: none !important;
        max-height: none !important;
        border-radius: 0 !important;
        border: none !important;
    }
    .chatbot-header {
        border-radius: 0 !important;
        padding: 16px;
    }
    .chatbot-body {
        height: 0 !important; /* Let flex: 1 take over */
        padding: 16px;
    }
    .chatbot-wrapper {
        bottom: 16px;
        right: 28px;
    }
    .axel-toggle-btn {
        bottom: 30px;
        width: 22px;
        height: 34px;
        font-size: 0.72rem;
    }
    .chatbot-footer {
        padding: 16px;
        padding-bottom: env(safe-area-inset-bottom, 16px);
    }
    .chat-input {
        font-size: 1rem; /* Prevent iOS zoom on focus */
        padding: 12px 16px;
    }
    .chat-send-btn {
        width: 42px;
        height: 42px;
    }
}
