/* Floating Chatbot Launcher */
.chatbot-launcher {
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 60px;
    height: 60px;
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    cursor: grab;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.05);
    user-select: none;
    touch-action: none;
}

.chatbot-launcher:active,
.chatbot-launcher.is-dragging {
    cursor: grabbing;
    transition: none !important;
}

.chatbot-launcher:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.chatbot-launcher.is-dragging:hover {
    transform: none !important;
}

.chatbot-launcher img {
    width: 38px;
    height: 38px;
    object-fit: contain;
    pointer-events: none;
}

/* Chatbot Window Container */
.chatbot-window {
    position: fixed;
    bottom: 95px;
    right: 25px;
    width: 360px;
    height: 500px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    z-index: 999999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.chatbot-window.is-dragging {
    transition: none !important;
    transform: none !important;
    user-select: none;
}

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

.chatbot-window.active.is-dragging {
    transform: none !important;
}

/* Chat Header */
.chatbot-header {
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    color: #ffffff;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    cursor: grab;
    user-select: none;
    touch-action: none;
}

.chatbot-header:active,
.chatbot-header.is-dragging {
    cursor: grabbing;
}

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

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

.chatbot-header-avatar img {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.chatbot-header-title {
    display: flex;
    flex-direction: column;
}

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

.chatbot-header-status {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    gap: 4px;
}

.chatbot-status-dot {
    width: 6px;
    height: 6px;
    background: #10b981;
    border-radius: 50%;
    display: inline-block;
    animation: status-pulse 1.5s infinite;
}

@keyframes status-pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.5; }
    100% { transform: scale(1); opacity: 1; }
}

.chatbot-close-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 22px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.chatbot-close-btn:hover {
    color: #ffffff;
}

/* Chat Body */
.chatbot-body {
    flex: 1;
    overflow-y: auto;
    background: #f8fafc;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Scrollbar styling for chatbot body */
.chatbot-body::-webkit-scrollbar {
    width: 5px;
}
.chatbot-body::-webkit-scrollbar-track {
    background: transparent;
}
.chatbot-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

/* Chat Messages */
.chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: msg-fade-in 0.25s ease-out forwards;
}

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

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

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

.chat-msg-bubble {
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.4;
}

.chat-msg.bot .chat-msg-bubble {
    background: #ffffff;
    color: #1e293b;
    border-radius: 14px 14px 14px 2px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02), 0 1px 2px rgba(0, 0, 0, 0.02);
    border: 1px solid #e2e8f0;
}

.chat-msg.user .chat-msg-bubble {
    background: #4f46e5;
    color: #ffffff;
    border-radius: 14px 14px 2px 14px;
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.15);
}

.chat-msg-meta {
    font-size: 10px;
    color: #94a3b8;
    margin-top: 4px;
    padding: 0 4px;
}

.chat-msg.user .chat-msg-meta {
    text-align: right;
}

/* Chat Input */
.chatbot-input-area {
    padding: 12px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chatbot-input-field {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: #f8fafc;
}

.chatbot-input-field:focus {
    border-color: #4f46e5;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.chatbot-send-btn {
    width: 36px;
    height: 36px;
    background: #4f46e5;
    color: #ffffff;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
    padding: 0;
}

.chatbot-send-btn:hover {
    background: #4338ca;
}

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

.chatbot-file-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #64748b;
    transition: color 0.2s ease, background-color 0.2s ease;
    border-radius: 50%;
}

.chatbot-file-btn:hover {
    color: #4f46e5;
    background-color: #f1f5f9;
}

.chatbot-file-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.chatbot-send-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
    transform: rotate(-45deg) translate(2px, -2px);
}

/* Typing Indicator Animation */
.typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    display: inline-block;
    animation: typing-bounce 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typing-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

/* Hide chat window by default */
@media (max-width: 480px) {
    .chatbot-window {
        right: 15px;
        bottom: 85px;
        width: calc(100% - 30px);
        height: 450px;
    }
    .chatbot-launcher {
        right: 15px;
        bottom: 15px;
    }
}
