/* ============================================================================
   CHATBOT WIDGET - Floating side panel
   ============================================================================ */

/* Widget Button (Floating) */
.chatbot-toggle {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FF6B6B 0%, #FF8E53 100%);
    color: white;
    border: 3px solid white;
    font-size: 32px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.5), 0 0 0 0 rgba(255, 107, 107, 0.7);
    z-index: 9998;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: chatbotPulse 2s infinite;
}

@keyframes chatbotPulse {
    0%, 100% {
        box-shadow: 0 6px 20px rgba(255, 107, 107, 0.5), 0 0 0 0 rgba(255, 107, 107, 0.7);
    }
    50% {
        box-shadow: 0 6px 20px rgba(255, 107, 107, 0.5), 0 0 0 10px rgba(255, 107, 107, 0);
    }
}

.chatbot-toggle:hover {
    transform: scale(1.15);
    box-shadow: 0 8px 24px rgba(255, 107, 107, 0.6), 0 0 0 4px rgba(255, 107, 107, 0.3);
    animation: none;
}

/* Chatbot Popup Bubble */
.chatbot-popup {
    position: fixed;
    bottom: 110px;
    right: 30px;
    width: 300px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    z-index: 9997;
    animation: popupSlideIn 0.4s ease;
    opacity: 1;
    transform: translateY(0);
    transition: all 0.3s ease;
}

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

.chatbot-popup-content {
    padding: 20px;
    position: relative;
}

.chatbot-popup-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 1rem;
    color: var(--color-text);
}

.chatbot-popup-icon {
    font-size: 1.5rem;
}

.chatbot-popup-text {
    font-size: 0.9375rem;
    color: var(--color-text-secondary);
    line-height: 1.5;
    margin-bottom: 16px;
}

.chatbot-popup-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chatbot-popup-btn {
    flex: 1;
    background: linear-gradient(135deg, #FF6B6B 0%, #FF8E53 100%);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chatbot-popup-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.4);
}

.chatbot-popup-dismiss {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    transition: color 0.2s ease;
}

.chatbot-popup-dismiss:hover {
    color: var(--color-text);
}

.chatbot-popup-arrow {
    position: absolute;
    bottom: -8px;
    right: 40px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid white;
}

/* Mobile popup adjustments */
@media (max-width: 768px) {
    .chatbot-popup {
        width: calc(100vw - 40px);
        right: 20px;
        left: 20px;
        bottom: 100px;
    }
    
    .chatbot-popup-arrow {
        right: auto;
        left: 40px;
    }
}

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

/* Notification Badge */
.chatbot-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #4CAF50;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Chat Panel */
.chatbot-panel {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 380px;
    height: 600px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.chatbot-panel.open {
    display: flex;
}

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

/* Panel Header */
.chatbot-header {
    background: linear-gradient(135deg, #FF6B6B 0%, #FF8E53 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chatbot-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.chatbot-title h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chatbot-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    opacity: 0.9;
    margin-top: 2px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4CAF50;
    animation: pulse 2s infinite;
}

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

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

/* Messages Area */
.chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8f9fa;
}

.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

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

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

/* Chat Messages */
.chat-message {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    animation: messageSlide 0.3s ease;
}

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FF6B6B 0%, #FF8E53 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.user-message .message-avatar {
    background: #e9ecef;
}

.message-content {
    flex: 1;
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.user-message .message-content {
    background: linear-gradient(135deg, #FF6B6B 0%, #FF8E53 100%);
    color: white;
}

.message-content p {
    margin: 0 0 8px 0;
    line-height: 1.5;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul {
    margin: 8px 0;
    padding-left: 20px;
}

.message-content li {
    margin: 4px 0;
    line-height: 1.5;
}

.message-content strong {
    font-weight: 600;
}

/* Loading Animation */
.chat-loading {
    display: flex;
    gap: 6px;
    align-items: center;
}

.chat-loading::after {
    content: '';
    display: inline-block;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #666;
    animation: loading 1.4s infinite both;
}

.chat-loading::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #666;
    animation: loading 1.4s -0.32s infinite both;
}

@keyframes loading {
    0%, 80%, 100% { opacity: 0; }
    40% { opacity: 1; }
}

/* Input Area */
.chatbot-input {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #e9ecef;
}

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

.chatbot-input textarea {
    flex: 1;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 12px 16px;
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    transition: border-color 0.2s;
}

.chatbot-input textarea:focus {
    outline: none;
    border-color: #FF6B6B;
}

.chatbot-send-btn {
    background: linear-gradient(135deg, #FF6B6B 0%, #FF8E53 100%);
    color: white;
    border: none;
    border-radius: 12px;
    width: 44px;
    height: 44px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.chatbot-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
}

.chatbot-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Suggested Questions */
.suggested-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.suggested-btn {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    color: #495057;
}

.suggested-btn:hover {
    background: #f8f9fa;
    border-color: #FF6B6B;
    color: #FF6B6B;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .chatbot-toggle {
        width: 56px;
        height: 56px;
        bottom: 85px !important; /* Above mobile tab bar (70px) + safe padding (15px) */
        right: 20px;
        font-size: 24px;
        z-index: 9997; /* Below mobile nav but above content */
    }
    
    .chatbot-popup {
        bottom: 95px !important; /* Above chatbot button */
    }
    
    .chatbot-panel {
        bottom: 95px !important; /* Above chatbot button */
        right: 20px;
        left: auto;
        width: calc(100vw - 40px);
        max-width: 380px;
        height: 500px;
        max-height: calc(100vh - 200px); /* Leave space for button and nav */
        border-radius: 20px 20px 8px 20px; /* Rounded corners with speech bubble style */
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
        border: 2px solid var(--color-border-light);
        overflow: hidden;
    }
    
    /* Speech bubble tail pointing to button */
    .chatbot-panel::after {
        content: '';
        position: absolute;
        bottom: -12px;
        right: 30px;
        width: 0;
        height: 0;
        border-left: 12px solid transparent;
        border-right: 12px solid transparent;
        border-top: 12px solid white;
        filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
    }
    
    .chatbot-header {
        padding: 16px;
        border-bottom: 1px solid var(--color-border-light);
        background: linear-gradient(135deg, #FF6B6B 0%, #FF8E53 100%);
        color: white;
        border-radius: 20px 20px 0 0; /* Match top corners of speech bubble */
    }
    
    .chatbot-close {
        color: white;
    }
    
    .chatbot-messages {
        padding: 16px;
        height: calc(100% - 140px); /* Account for header and input */
        overflow-y: auto;
    }
    
    .chatbot-input-container {
        padding: 12px 16px;
        border-top: 1px solid var(--color-border-light);
    }
}

/* Desktop - smaller screens */
@media (max-width: 1200px) and (min-width: 769px) {
    .chatbot-panel {
        width: 340px;
        height: 550px;
    }
}
