/* Floating Chatbot Widget Styles - Study9 LMS */

/* Toggle Button */
.chatbot-toggle {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9999;
    transition: all 0.3s ease;
    border: none;
    color: white;
}

.chatbot-toggle:hover {
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.chatbot-toggle.active {
    transform: translateY(-50%) scale(0.9);
}

.chatbot-toggle svg {
    width: 28px;
    height: 28px;
}

/* Chat Window — root color so bubbles never inherit app dark-theme body text */
.chatbot-window {
    position: fixed;
    right: 90px;
    top: 50%;
    transform: translateY(-50%);
    width: 400px;
    max-height: 500px;
    background: white;
    color: #1e293b;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    display: none;
    flex-direction: column;
    z-index: 9998;
    overflow: hidden;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-50%) translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
    }
}

/* Header */
.chatbot-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 16px;
    gap: 8px;
}

.chatbot-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chatbot-header-btn {
    font-size: 12px !important;
    font-weight: 600;
    padding: 6px 10px !important;
    border-radius: 8px !important;
    background: rgba(255,255,255,0.2) !important;
    color: white !important;
    border: 1px solid rgba(255,255,255,0.35) !important;
    cursor: pointer;
    font-family: inherit;
}
.chatbot-header-btn:hover {
    background: rgba(255,255,255,0.3) !important;
}

.chatbot-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

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

/* Messages Area */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-welcome {
    text-align: center;
    color: #6c757d;
    padding: 20px;
}

.chat-welcome p {
    margin: 0;
    font-size: 14px;
}

/* Message Bubbles */
.chatbot-msg {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.chatbot-msg a {
    color: #4c51bf;
    text-decoration: underline;
}

.chatbot-msg.user {
    background: #667eea;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chatbot-msg.bot {
    background: #ffffff;
    color: #1e293b;
    align-self: flex-start;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.chatbot-msg.system {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffc107;
    align-self: center;
    text-align: center;
    font-size: 13px;
}

/* Typing Indicator */
.chatbot-msg.typing {
    background: white;
    align-self: flex-start;
    border: 1px solid #e0e0e0;
    padding: 12px 18px;
}

.typing-dots span {
    animation: blink 1.4s infinite;
    font-size: 24px;
    line-height: 0;
}

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

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

@keyframes blink {
    0% { opacity: 0.2; }
    20% { opacity: 1; }
    100% { opacity: 0.2; }
}

/* Input Area */
.chatbot-input-area {
    display: flex;
    padding: 12px;
    background: white;
    border-top: 1px solid #e0e0e0;
    gap: 8px;
}

#chatbot-input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#chatbot-input:focus {
    border-color: #667eea;
}

.chatbot-send-btn {
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

.chatbot-send-btn:hover {
    background: #5a67d8;
}

/* Support Reference Banner */
.support-ref-banner {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    padding: 8px 12px;
    margin-top: 8px;
    font-size: 13px;
    text-align: center;
}

.support-ref-banner code {
    background: #ffeeba;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
    color: #856404;
}

/* Mobile Responsive */
@media (max-width: 600px) {
    .chatbot-window {
        right: 10px;
        left: 10px;
        width: auto;
        max-height: 400px;
        top: 50%;
    }

    /* Allow dragging the bubble without scrolling the page */
    .chatbot-toggle {
        right: 15px;
        width: 50px;
        height: 50px;
        touch-action: none;
        -webkit-user-select: none;
        user-select: none;
        /* Reduce browser pull-to-refresh fighting vertical drags on the bubble */
        overscroll-behavior: contain;
    }

    .chatbot-toggle.chatbot-dragging {
        cursor: grabbing;
        transition: none;
        box-shadow: 0 6px 22px rgba(102, 126, 234, 0.55);
    }

    .chatbot-window.chatbot-panel-mobile-placed {
        animation: none;
    }

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