/* ==================== AI Chatbot Styles ==================== */
/* CSS riêng biệt cho chatbot, không ảnh hưởng đến giao diện chính */

:root {
    --chatbot-primary: #B8641A;
    --chatbot-primary-dark: #8B4513;
    --chatbot-primary-light: #D2691E;
    --chatbot-bg: #FFFFFF;
    --chatbot-bg-secondary: #F9F6F2;
    --chatbot-text: #2C2416;
    --chatbot-text-secondary: #6B5D4F;
    --chatbot-border: #E8DCC8;
    --chatbot-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    --chatbot-shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.2);
    --chatbot-radius: 12px;
    --chatbot-radius-lg: 16px;
}

/* Chatbot Container - Fixed position */
.chatbot-container {
    position: fixed;
    bottom: 30px;
    right: 20px;
    z-index: 99999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    max-width: 380px;
    width: auto;
}

/* Desktop Chatbot Styles */
@media screen and (min-width: 769px) {
    .chatbot-container {
        bottom: 30px;
        right: 20px;
        max-width: 380px;
        width: 380px;
    }
    
    .chatbot-window {
        bottom: 80px;
        right: 0;
        left: auto;
        max-width: 380px;
        width: 380px;
        min-width: 380px;
        height: 500px;
    }
    
    .chatbot-toggle {
        width: 60px;
        height: 60px;
        font-size: 24px;
    }
}

.chatbot-container * {
    pointer-events: auto;
}

/* Chatbot Toggle Button */
.chatbot-toggle {
    width: 60px;
    height: 60px;
    background: linear-gradient(45deg, var(--chatbot-primary), var(--chatbot-primary-dark));
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(184, 100, 26, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    position: relative;
    overflow: visible;
    border: 2px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    margin-left: auto;
}

.chatbot-toggle:hover {
    transform: scale(1.15);
    box-shadow: 0 8px 30px rgba(184, 100, 26, 0.6);
    border-color: rgba(255, 255, 255, 0.4);
}

/* Pulse animation for attention */
@keyframes chatbotPulse {
    0% {
        box-shadow: 0 4px 20px rgba(184, 100, 26, 0.4);
    }
    50% {
        box-shadow: 0 4px 20px rgba(184, 100, 26, 0.8), 0 0 0 10px rgba(184, 100, 26, 0.1);
    }
    100% {
        box-shadow: 0 4px 20px rgba(184, 100, 26, 0.4);
    }
}

.chatbot-toggle.pulse {
    animation: chatbotPulse 2s infinite;
}

.chatbot-toggle::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
    border-radius: 50%;
    overflow: hidden;
}

.chatbot-toggle:hover::after {
    left: 100%;
}

/* Notification Badge */
.chatbot-notification {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background: #FF4444;
    color: white;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 2s infinite;
    z-index: 100000;
    box-shadow: 0 2px 8px rgba(255, 68, 68, 0.5);
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Chatbot Window */
.chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    left: auto;
    width: 380px;
    max-width: 380px;
    height: 500px;
    background: var(--chatbot-bg);
    border-radius: var(--chatbot-radius-lg);
    box-shadow: var(--chatbot-shadow);
    border: 1px solid var(--chatbot-border);
    display: none;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chatbot-window.active {
    display: flex;
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* Chatbot Header */
.chatbot-header {
    background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-primary-dark));
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: var(--chatbot-radius-lg) var(--chatbot-radius-lg) 0 0;
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.chatbot-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.chatbot-subtitle {
    font-size: 12px;
    opacity: 0.9;
    margin: 0;
}

.chatbot-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.chatbot-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Chatbot Messages Area */
.chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--chatbot-bg-secondary);
}

.chatbot-messages::-webkit-scrollbar {
    width: 4px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--chatbot-border);
    border-radius: 2px;
}

/* Message Bubbles */
.chatbot-message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: var(--chatbot-radius);
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    animation: messageSlide 0.3s ease-out;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chatbot-message.user {
    background: var(--chatbot-primary);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chatbot-message.bot {
    background: var(--chatbot-bg);
    color: var(--chatbot-text);
    align-self: flex-start;
    border: 1px solid var(--chatbot-border);
    border-bottom-left-radius: 4px;
}

.chatbot-message.system {
    background: #E3F2FD;
    color: #1976D2;
    align-self: center;
    text-align: center;
    font-size: 12px;
    padding: 8px 12px;
    border-radius: 20px;
}

/* Typing Indicator */
.chatbot-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--chatbot-bg);
    border: 1px solid var(--chatbot-border);
    border-radius: var(--chatbot-radius);
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    max-width: 80px;
}

.chatbot-typing-dots {
    display: flex;
    gap: 4px;
}

.chatbot-typing-dot {
    width: 6px;
    height: 6px;
    background: var(--chatbot-text-secondary);
    border-radius: 50%;
    animation: typingDot 1.4s infinite ease-in-out;
}

.chatbot-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.chatbot-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingDot {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Chatbot Input Area */
.chatbot-input-area {
    padding: 16px 20px;
    background: var(--chatbot-bg);
    border-top: 1px solid var(--chatbot-border);
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.chatbot-input {
    flex: 1;
    border: 1px solid var(--chatbot-border);
    border-radius: var(--chatbot-radius);
    padding: 12px 16px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 100px;
    min-height: 40px;
    outline: none;
    transition: border-color 0.2s;
}

.chatbot-input:focus {
    border-color: var(--chatbot-primary);
    box-shadow: 0 0 0 3px rgba(184, 100, 26, 0.1);
}

.chatbot-send {
    width: 40px;
    height: 40px;
    background: var(--chatbot-primary);
    border: none;
    border-radius: var(--chatbot-radius);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chatbot-send:hover {
    background: var(--chatbot-primary-dark);
    transform: scale(1.05);
}

.chatbot-send:disabled {
    background: var(--chatbot-border);
    cursor: not-allowed;
    transform: none;
}

/* Quick Actions */
.chatbot-quick-actions {
    padding: 12px 20px;
    background: var(--chatbot-bg-secondary);
    border-top: 1px solid var(--chatbot-border);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Quick actions toolbar + collapse */
.chatbot-quick-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 6px 12px 0 12px;
    background: var(--chatbot-bg-secondary);
    border-top: 1px solid var(--chatbot-border);
}

.chatbot-quick-toggle {
    background: transparent;
    border: 1px solid var(--chatbot-border);
    color: var(--chatbot-text-secondary);
    font-size: 12px;
    border-radius: 14px;
    padding: 4px 10px;
    cursor: pointer;
}

.chatbot-quick-toggle:hover {
    background: var(--chatbot-bg);
}

.chatbot-quick-actions.collapsed {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    overflow: hidden;
    border-top: none;
}

.chatbot-quick-btn {
    background: var(--chatbot-bg);
    border: 1px solid var(--chatbot-border);
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 12px;
    color: var(--chatbot-text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.chatbot-quick-btn:hover {
    background: var(--chatbot-primary);
    color: white;
    border-color: var(--chatbot-primary);
}

/* Welcome Message */
.chatbot-welcome {
    text-align: center;
    padding: 20px;
    color: var(--chatbot-text-secondary);
}

.chatbot-welcome-icon {
    font-size: 48px;
    margin-bottom: 12px;
    color: var(--chatbot-primary);
}

.chatbot-welcome-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--chatbot-text);
}

.chatbot-welcome-text {
    font-size: 14px;
    line-height: 1.4;
}

/* Mobile Chatbot Styles */
@media (max-width: 768px) {
    .chatbot-container {
        bottom: 20px;
        right: 16px;
        left: auto;
        max-width: none;
        width: auto;
    }
    
    .chatbot-window {
        bottom: 80px;
        right: 0;
        left: auto;
        max-width: calc(100vw - 32px);
        width: calc(100vw - 32px);
        height: calc(100vh - 200px);
        max-height: 500px;
    }
    
    .chatbot-toggle {
        width: 56px;
        height: 56px;
        font-size: 22px;
        margin-left: 0;
    }
}

@media (max-width: 480px) {
    .chatbot-container {
        bottom: 15px;
        right: 12px;
        left: auto;
        max-width: none;
        width: auto;
    }
    
    .chatbot-window {
        bottom: 75px;
        right: 0;
        left: auto;
        max-width: calc(100vw - 24px);
        width: calc(100vw - 24px);
        height: calc(100vh - 180px);
        max-height: 450px;
    }
    
    .chatbot-toggle {
        width: 50px;
        height: 50px;
        font-size: 20px;
        margin-left: 0;
    }
}

/* Animation for opening/closing */
@keyframes chatbotSlideIn {
    from {
        transform: translateY(20px) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

@keyframes chatbotSlideOut {
    from {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    to {
        transform: translateY(20px) scale(0.95);
        opacity: 0;
    }
}

/* Loading state */
.chatbot-loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Error state */
.chatbot-error {
    background: #FFEBEE;
    color: #C62828;
    border: 1px solid #FFCDD2;
}

/* Success state */
.chatbot-success {
    background: #E8F5E8;
    color: #2E7D32;
    border: 1px solid #C8E6C9;
}
