/* 🤖 AI Chatbot Styles */
.ai-chatbot {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9998;
    font-family: 'Prompt', sans-serif;
}

/* ป้องกันการทับซ้อนกับปุ่ม scroll to top */
.ai-chatbot.with-scroll-button {
    bottom: 80px; /* เลื่อนขึ้นเมื่อมีปุ่ม scroll to top */
}

/* หรือใช้ตำแหน่งซ้าย */
.ai-chatbot.left-position {
    right: auto;
    left: 20px;
}

/* Chatbot Toggle Button */
.chatbot-toggle {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #006994, #4fc3f7);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 105, 148, 0.3);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 2s infinite;
}

.chatbot-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(0, 105, 148, 0.4);
}

.chatbot-toggle.active {
    background: linear-gradient(135deg, #dc3545, #fd7e14);
    animation: none;
}

@keyframes pulse {
    0% {
        box-shadow: 0 4px 20px rgba(0, 105, 148, 0.3);
    }
    50% {
        box-shadow: 0 4px 20px rgba(0, 105, 148, 0.6);
    }
    100% {
        box-shadow: 0 4px 20px rgba(0, 105, 148, 0.3);
    }
}

/* Chatbot Window */
.chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s ease;
    overflow: hidden;
    border: 1px solid rgba(0, 105, 148, 0.1);
}

.chatbot-window.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Chatbot Header */
.chatbot-header {
    background: linear-gradient(135deg, #006994, #4fc3f7);
    color: white;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.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: 20px;
}

.chatbot-info h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chatbot-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 5px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #28a745;
    border-radius: 50%;
    animation: blink 2s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

.chatbot-minimize {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background 0.3s ease;
}

.chatbot-minimize:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Chatbot Messages */
.chatbot-messages {
    height: 350px;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    position: relative;
}

.message {
    margin-bottom: 15px;
    display: flex;
    animation: messageSlideIn 0.3s ease-out;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.bot {
    justify-content: flex-start;
}

.message.user {
    justify-content: flex-end;
}

.message-bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
}

.message.bot .message-bubble {
    background: white;
    color: #333;
    border-bottom-left-radius: 5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.message.user .message-bubble {
    background: linear-gradient(135deg, #006994, #4fc3f7);
    color: white;
    border-bottom-right-radius: 5px;
}

.message-time {
    font-size: 11px;
    opacity: 0.6;
    margin-top: 5px;
    text-align: right;
}

.message.bot .message-time {
    text-align: left;
}

/* Typing Indicator */
.typing-indicator {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    border-bottom-left-radius: 5px;
    max-width: 80%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.typing-indicator.show {
    display: flex;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typingAnimation 1.5s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingAnimation {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* Quick Actions */
.quick-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 10px 0;
}

.quick-action {
    background: white;
    border: 2px solid #006994;
    color: #006994;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.quick-action:hover {
    background: #006994;
    color: white;
    transform: translateY(-1px);
}

/* Chatbot Input */
.chatbot-input {
    padding: 15px 20px;
    background: white;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.input-wrapper {
    flex: 1;
    position: relative;
}

.message-input {
    width: 100%;
    border: 2px solid #e9ecef;
    border-radius: 20px;
    padding: 10px 15px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s ease;
    resize: none;
    max-height: 80px;
    min-height: 40px;
    font-family: 'Prompt', sans-serif;
}

.message-input:focus {
    border-color: #006994;
}

.message-input::placeholder {
    color: #999;
}

.send-button {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #006994, #4fc3f7);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0, 105, 148, 0.3);
}

.send-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Attachment Button */
.attachment-button {
    width: 35px;
    height: 35px;
    background: none;
    border: 2px solid #e9ecef;
    border-radius: 50%;
    color: #666;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.attachment-button:hover {
    border-color: #006994;
    color: #006994;
}

/* Welcome Message */
.welcome-message {
    text-align: center;
    padding: 30px 20px;
    color: #666;
}

.welcome-message h3 {
    color: #006994;
    margin-bottom: 10px;
    font-size: 18px;
}

.welcome-message p {
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 20px;
}

/* Suggestions */
.suggestions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.suggestion {
    background: white;
    border: 2px solid #e9ecef;
    color: #333;
    padding: 10px 15px;
    border-radius: 15px;
    text-align: left;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 13px;
}

.suggestion:hover {
    border-color: #006994;
    background: #f8fbff;
    transform: translateX(5px);
}

/* Scrollbar Styling */
.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Notification Badge */
.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    animation: badgePulse 2s infinite;
}

@keyframes badgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .ai-chatbot {
        bottom: 15px;
        right: 15px;
    }
    
    /* เมื่อมีปุ่ม scroll to top ในมือถือ */
    .ai-chatbot.with-scroll-button {
        bottom: 75px;
    }
    
    /* เมื่ออยู่ซ้ายในมือถือ */
    .ai-chatbot.left-position {
        left: 15px;
        right: auto;
    }
    
    .chatbot-window {
        width: calc(100vw - 30px);
        height: calc(100vh - 100px);
        max-width: 400px;
        max-height: 600px;
    }
    
    .chatbot-messages {
        height: calc(100% - 140px);
    }
}

@media (max-width: 480px) {
    .chatbot-toggle {
        width: 55px;
        height: 55px;
        font-size: 22px;
    }
    
    .chatbot-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 80px);
        bottom: 70px;
        right: 10px;
    }
    
    .message-bubble {
        max-width: 85%;
        font-size: 13px;
    }
    
    .chatbot-header {
        padding: 12px 15px;
    }
    
    .chatbot-input {
        padding: 12px 15px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .chatbot-window {
        background: #2c3e50;
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .chatbot-messages {
        background: #34495e;
    }
    
    .message.bot .message-bubble {
        background: #3c5063;
        color: #ecf0f1;
    }
    
    .typing-indicator {
        background: #3c5063;
    }
    
    .message-input {
        background: #3c5063;
        color: #ecf0f1;
        border-color: #555;
    }
    
    .message-input::placeholder {
        color: #bbb;
    }
    
    .welcome-message {
        color: #bdc3c7;
    }
    
    .suggestion {
        background: #3c5063;
        color: #ecf0f1;
        border-color: #555;
    }
    
    .quick-action {
        background: #3c5063;
        color: #4fc3f7;
        border-color: #4fc3f7;
    }
}

/* Loading Animation */
.message-loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #666;
    font-size: 12px;
}

.loading-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #006994;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Message Actions */
.message-actions {
    margin-top: 8px;
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.message:hover .message-actions {
    opacity: 1;
}

.message-action {
    background: none;
    border: none;
    color: #999;
    font-size: 12px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.message-action:hover {
    background: #f0f0f0;
    color: #333;
}

/* Chatbot Features */
.feature-highlight {
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    border-left: 4px solid #006994;
    padding: 10px 12px;
    margin: 10px 0;
    border-radius: 8px;
    font-size: 13px;
}

.feature-highlight .feature-icon {
    color: #006994;
    margin-right: 8px;
}

/* Connection Status */
.connection-status {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #666;
    display: none;
}

.connection-status.show {
    display: block;
}

.connection-status .status-icon {
    font-size: 48px;
    color: #ccc;
    margin-bottom: 10px;
}

/* Emoji Support */
.emoji {
    font-size: 16px;
    margin-right: 4px;
}

/* Voice Input Button */
.voice-button {
    width: 35px;
    height: 35px;
    background: none;
    border: 2px solid #e9ecef;
    border-radius: 50%;
    color: #666;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.voice-button:hover {
    border-color: #dc3545;
    color: #dc3545;
}

.voice-button.recording {
    border-color: #dc3545;
    color: #dc3545;
    background: rgba(220, 53, 69, 0.1);
    animation: pulse 1s infinite;
}

/* Chat History Toggle */
.history-toggle {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    cursor: pointer;
    padding: 5px;
    border-radius: 5px;
    transition: all 0.3s ease;
}

.history-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
} 