/* AI Chatbot Floating Widget */

/* Floating Button */
.chatbot-toggle {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4e73df 0%, #224abe 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: all 0.3s ease;
}

.chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(78, 115, 223, 0.4);
}

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

.chatbot-toggle .fa-robot {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Chat Window */
.chatbot-window {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 400px;
    height: 550px;
    background-color: var(--bg-card);
    border: 1px solid var(--primary-color);
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    z-index: 999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
    animation: slideUp 0.3s ease-out;
}

/* Minimized State */
.chatbot-window.minimized {
    height: auto; /* Only show header height */
}

.chatbot-window.minimized .chatbot-messages,
.chatbot-window.minimized .chatbot-input-container {
    display: none;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Chat Header */
.chatbot-header {
    background: linear-gradient(135deg, #4e73df 0%, #224abe 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #4e73df;
    position: relative; /* For drag handle positioning */
}

.chatbot-header-title {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chatbot-header-buttons {
    display: flex;
    gap: 4px;
    align-items: center;
}

.chatbot-minimize,
.chatbot-close {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

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

.chatbot-minimize {
    font-size: 16px; /* Slightly smaller minus icon */
}

.chatbot-close {
    font-size: 20px;
}

/* Messages Area */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background-color: var(--bg-primary);
}

.chatbot-message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.chatbot-message.user {
    align-self: flex-end;
}

.chatbot-message.assistant {
    align-self: flex-start;
}

.chatbot-message-content {
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
    line-height: 1.5;
}

.chatbot-message.user .chatbot-message-content {
    background: var(--primary-color);
    color: white;
    border-bottom-right-radius: 4px;
}

.chatbot-message.assistant .chatbot-message-content {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

.chatbot-message-time {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
    padding: 0 4px;
}

.chatbot-message.user .chatbot-message-time {
    text-align: right;
}

/* Typing Indicator */
.chatbot-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: fit-content;
}

.chatbot-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-color);
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.7; }
    30% { transform: translateY(-10px); opacity: 1; }
}

/* Input Area */
.chatbot-input-container {
    padding: 16px;
    background-color: var(--bg-card);
    border-top: 1px solid var(--border-color);
}

.chatbot-input-wrapper {
    display: flex;
    gap: 8px;
}

.chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--input-text);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.chatbot-input:focus {
    border-color: var(--primary-color);
}

.chatbot-input::placeholder {
    color: var(--text-secondary);
}

.chatbot-send {
    padding: 12px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.2s;
}

.chatbot-send:hover {
    background: var(--navbar-bg);
}

.chatbot-send:disabled {
    background: var(--text-secondary);
    cursor: not-allowed;
}

/* Context Badge */
.chatbot-context {
    font-size: 11px;
    color: var(--text-secondary);
    padding: 4px 12px;
    background: var(--bg-secondary);
    border-radius: 4px;
    margin-bottom: 8px;
    display: inline-block;
}

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

.chatbot-messages::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: var(--navbar-bg);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .chatbot-window {
        width: calc(100vw - 20px);
        right: 10px;
        bottom: 90px;
        height: 450px;
    }
    
    .chatbot-toggle {
        bottom: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
}

/* Welcome Message */
.chatbot-welcome {
    text-align: center;
    color: var(--text-secondary);
    padding: 20px;
    font-size: 14px;
}

.chatbot-welcome-icon {
    font-size: 48px;
    color: var(--primary-color);
    margin-bottom: 12px;
}

.chatbot-suggestions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.chatbot-suggestion {
    padding: 10px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    font-size: 13px;
    transition: all 0.2s;
}

.chatbot-suggestion:hover {
    background: var(--bg-card);
    border-color: var(--primary-color);
}

/* ============================================
   DRAGGABLE FUNCTIONALITY (PC/TABLET ONLY)
   ============================================ */

/* Only enable dragging on larger screens */
@media (min-width: 769px) {
    .chatbot-window.draggable .chatbot-header {
        cursor: grab;
        user-select: none;
    }
    
    .chatbot-window.dragging {
        cursor: grabbing;
        opacity: 0.9;
        transform: scale(1.02);
        box-shadow: 0 15px 35px rgba(0,0,0,0.3);
        z-index: 10000;
        transition: none; /* Disable transitions while dragging */
    }
    
    .chatbot-window.dragging .chatbot-header {
        cursor: grabbing;
    }
    
    /* Add drag handle visual indicator */
    .chatbot-header::before {
        content: "⋮⋮";
        position: absolute;
        left: 8px;
        top: 50%;
        transform: translateY(-50%);
        color: var(--text-secondary);
        font-size: 12px;
        opacity: 0.6;
        letter-spacing: 1px;
        pointer-events: none;
    }
    
    .chatbot-header:hover::before {
        opacity: 1;
        color: var(--primary-color);
    }
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .chatbot-header::before {
        display: none !important;
    }
    
    /* Adjust button sizes for mobile */
    .chatbot-minimize,
    .chatbot-close {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }
    
    /* Ensure minimized state works on mobile */
    .chatbot-window.minimized {
        height: auto;
    }
}
