/* AI Chatbot Container */
.chatbot-container {
    position: fixed;
    bottom: 100px;
    /* Initial position */
    right: 20px;
    width: 360px;
    height: 520px;
    background: rgba(var(--bg-secondary-rgb), 0.85);
    /* Glassmorphism base */
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    border-radius: 20px;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    font-family: 'Inter', sans-serif;
}

.chatbot-container.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Chatbot Header - Draggable Area */
.chatbot-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    padding: 16px 20px;
    color: white;
    cursor: grab;
    /* Indicates draggable */
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    user-select: none;
}

.chatbot-header:active {
    cursor: grabbing;
}

.chatbot-title {
    font-weight: 600;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.chatbot-close-btn:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* Messages Area */
.chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: transparent;
    scroll-behavior: smooth;
}

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

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

.chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(150, 150, 150, 0.3);
    border-radius: 3px;
}

/* Message Bubbles */
.chat-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
}

.chat-message.bot {
    align-self: flex-start;
    background: rgba(var(--bg-primary-rgb), 0.7);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.chat-message.user {
    align-self: flex-end;
    background: var(--primary-color);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 10px rgba(var(--primary-rgb), 0.3);
}

/* Input Area */
.chatbot-input-area {
    padding: 15px;
    border-top: 1px solid var(--border-color);
    background: rgba(var(--bg-secondary-rgb), 0.9);
    display: flex;
    gap: 10px;
    align-items: center;
}

.chatbot-input-field {
    flex: 1;
    padding: 12px 16px;
    border-radius: 24px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    outline: none;
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.chatbot-input-field:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.chatbot-send-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.3);
}

.chatbot-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(var(--primary-rgb), 0.4);
}

.chatbot-send-btn:active {
    transform: scale(0.95);
}

/* Mobile Responsiveness - Bottom Sheet Style */
@media (max-width: 480px) {
    .chatbot-container {
        width: 100% !important;
        height: 85vh !important;
        /* Bottom sheet height */
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        /* Override drag position */
        border-radius: 24px 24px 0 0;
        /* Rounded top corners */
        transform: translateY(100%);
        box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.15);
        border: none;
        border-top: 1px solid rgba(255, 255, 255, 0.2);
    }

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

    .chatbot-header {
        border-radius: 24px 24px 0 0;
        cursor: default;
        /* Disable drag on mobile */
        padding: 20px;
        justify-content: center;
        position: relative;
    }

    /* Drag Handle Visual */
    .chatbot-header::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: rgba(255, 255, 255, 0.3);
        border-radius: 2px;
    }

    .chatbot-title {
        font-size: 1.1rem;
    }

    .chatbot-close-btn {
        position: absolute;
        right: 20px;
        background: rgba(255, 255, 255, 0.15);
    }

    .chatbot-messages {
        padding: 15px;
        padding-bottom: 80px;
        /* Extra padding for scrolling past input */
    }

    .chatbot-input-area {
        padding: 15px;
        background: var(--bg-secondary);
        border-top: 1px solid var(--border-color);
        /* Ensure input area stays at bottom if needed, though flex handles it */
    }

    /* Hide the floating toggle button when chat is open on mobile */
    .chatbot-container.active~.chatbot-toggle-btn {
        display: none;
    }
}