/* public/css/chatbot.css */
/* Premium, High-Aesthetic Bilingual Chatbot Widget Stylesheet */

/* Floating Action Button (FAB) */
.cm-chatbot-fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary, #4f46e5) 0%, #6366f1 100%);
    color: #ffffff;
    border: none;
    box-shadow: 0 10px 25px rgba(79, 70, 229, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9999;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}

.cm-chatbot-fab:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 15px 30px rgba(79, 70, 229, 0.5);
}

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

/* Pulsing notification indicator on FAB */
.cm-chatbot-fab::after {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ef4444;
    border: 2px solid #ffffff;
    display: block;
    animation: cm-pulse 2s infinite;
}

body.dark-mode .cm-chatbot-fab::after {
    border-color: #1e293b;
}

@keyframes cm-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }
    70% {
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

/* Chatbot Panel Window */
.cm-chatbot-window {
    position: fixed;
    bottom: 6rem;
    right: 2rem;
    width: 380px;
    height: 520px;
    border-radius: var(--radius-xl, 20px);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: var(--shadow-2xl, 0 25px 50px -12px rgba(0, 0, 0, 0.15));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9998;
    transform: translateY(30px) scale(0.9);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
    box-sizing: border-box;
}

/* Open State */
.cm-chatbot-window.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

/* Dark Mode Tweaks */
body.dark-mode .cm-chatbot-window {
    background: rgba(26, 36, 50, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-main, #f1f5f9);
}

/* Chatbot Header */
.cm-chatbot-header {
    background: linear-gradient(135deg, var(--primary, #4f46e5) 0%, #6366f1 100%);
    padding: 1.25rem;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.cm-chatbot-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.cm-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: 1.25rem;
    border: 2px solid rgba(255, 255, 255, 0.4);
}

.cm-chatbot-info h3 {
    margin: 0;
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
}

.cm-chatbot-status {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    opacity: 0.85;
    margin-top: 2px;
}

.cm-chatbot-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
    display: inline-block;
    box-shadow: 0 0 6px #10b981;
}

.cm-chatbot-close {
    background: none;
    border: none;
    color: #ffffff;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s, transform 0.2s;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cm-chatbot-close:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Chatbot Messages Area */
.cm-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: var(--bg-main, #f8fafc);
    box-sizing: border-box;
}

body.dark-mode .cm-chatbot-messages {
    background: #0f172a;
}

/* Message Bubbles */
.cm-chat-bubble {
    max-width: 80%;
    padding: 0.85rem 1.1rem;
    border-radius: 16px;
    font-size: 0.92rem;
    line-height: 1.5;
    word-wrap: break-word;
    box-sizing: border-box;
    animation: cm-bubble-in 0.25s ease-out;
}

@keyframes cm-bubble-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Bot Message */
.cm-chat-bubble.bot {
    align-self: flex-start;
    background: var(--bg-surface, #ffffff);
    color: var(--text-main, #1e293b);
    border: 1px solid var(--border-light, #e2e8f0);
    border-bottom-left-radius: 4px;
}

body.dark-mode .cm-chat-bubble.bot {
    background: rgba(30, 41, 59, 0.7);
    border-color: rgba(255, 255, 255, 0.08);
}

/* User Message */
.cm-chat-bubble.user {
    align-self: flex-end;
    background: var(--primary, #4f46e5);
    color: #ffffff;
    border-bottom-right-radius: 4px;
    margin-left: auto;
}

/* Custom links inside bot bubbles */
.cm-chat-bubble.bot a {
    color: var(--primary, #4f46e5);
    font-weight: 700;
    text-decoration: underline;
    transition: color 0.2s;
}

.cm-chat-bubble.bot a:hover {
    color: #3b82f6;
}

/* Typing Indicator */
.cm-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    align-self: flex-start;
    background: var(--bg-surface, #ffffff);
    border: 1px solid var(--border-light, #e2e8f0);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
}

body.dark-mode .cm-typing-indicator {
    background: rgba(30, 41, 59, 0.7);
    border-color: rgba(255, 255, 255, 0.08);
}

.cm-typing-dot {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: cm-typing 1.4s infinite ease-in-out both;
}

.cm-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.cm-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes cm-typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Fallback Card Styling (When UNKNOWN is returned) */
.cm-fallback-card {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.06) 0%, rgba(249, 115, 22 0.06) 100%);
    border: 1px dashed rgba(239, 68, 68, 0.25);
    border-radius: var(--radius-lg, 12px);
    padding: 1rem;
    margin: 0.25rem 0;
    color: var(--text-main, #1e293b);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    box-sizing: border-box;
    animation: cm-bubble-in 0.3s ease;
}

body.dark-mode .cm-fallback-card {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, rgba(249, 115, 22 0.05) 100%);
    border-color: rgba(239, 68, 68, 0.2);
}

.cm-fallback-title {
    font-weight: 700;
    font-size: 0.92rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.cm-fallback-desc {
    font-size: 0.82rem;
    color: var(--text-muted, #64748b);
    line-height: 1.4;
}

.cm-fallback-btn {
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, var(--secondary, #ec4899) 0%, #f43f5e 100%);
    color: #ffffff !important;
    text-decoration: none !important;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md, 8px);
    font-size: 0.82rem;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.25);
    transition: transform 0.2s, box-shadow 0.2s;
    border: none;
    cursor: pointer;
}

.cm-fallback-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(236, 72, 153, 0.4);
}

/* Chat Input Bar */
.cm-chatbot-input-bar {
    padding: 0.75rem;
    background: var(--bg-surface, #ffffff);
    border-top: 1px solid var(--border-light, #e2e8f0);
    display: flex;
    gap: 0.5rem;
    box-sizing: border-box;
}

body.dark-mode .cm-chatbot-input-bar {
    background: rgba(26, 36, 50, 0.95);
    border-color: rgba(255, 255, 255, 0.08);
}

.cm-chatbot-input {
    flex: 1;
    background: var(--bg-main, #f8fafc);
    color: var(--text-main, #1e293b);
    border: 1px solid var(--border-light, #e2e8f0);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-lg, 12px);
    font-size: 0.92rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

body.dark-mode .cm-chatbot-input {
    background: #0f172a;
    border-color: rgba(255, 255, 255, 0.08);
}

.cm-chatbot-input:focus {
    border-color: var(--primary, #4f46e5);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.cm-chatbot-submit {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-lg, 12px);
    background: var(--primary, #4f46e5);
    color: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
    flex-shrink: 0;
}

.cm-chatbot-submit:hover {
    background: #4338ca;
    transform: scale(1.05);
}

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

/* Custom Scrollbar for messages */
.cm-chatbot-messages::-webkit-scrollbar {
    width: 5px;
}

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

.cm-chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.12);
    border-radius: 10px;
}

body.dark-mode .cm-chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
}

/* Responsiveness */
@media (max-width: 480px) {
    .cm-chatbot-window {
        bottom: 5.5rem;
        right: 1rem;
        left: 1rem;
        width: auto;
        height: calc(100vh - 8rem);
        max-height: 480px;
    }
    
    .cm-chatbot-fab {
        bottom: 1.5rem;
        right: 1.5rem;
        width: 52px;
        height: 52px;
    }
}
