/* --- Trade Expert AI Chatbot Styles --- */
.chatbot-wrapper {
    position: fixed;
    bottom: 30px;
    right: 90px;
    z-index: 10000;
    font-family: var(--font-sans);
}

/* FAB - Floating Action Button */
.chatbot-fab {
    width: 60px;
    height: 60px;
    background: var(--accent-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(85, 107, 47, 0.4);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
}

.chatbot-fab:hover {
    transform: scale(1.1) rotate(10deg);
    background: #3f5022;
}

.chatbot-fab i {
    transition: transform 0.3s ease;
}

.chatbot-fab.active i {
    transform: scale(0.8) rotate(180deg);
}

.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    animation: pulse-red 2s infinite;
}

@keyframes pulse-red {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

/* Chat Window */
.chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 550px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(30px) scale(0.9);
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    transform-origin: bottom right;
}

.chat-window.active {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

/* Header */
.chat-header {
    background: var(--accent-color);
    padding: 20px;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.expert-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.expert-avatar {
    position: relative;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.online-status {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    background: #22c55e;
    border: 2px solid var(--accent-color);
    border-radius: 50%;
}

.chat-header h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.chat-header p {
    margin: 0;
    font-size: 0.75rem;
    opacity: 0.8;
}

.chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.chat-close:hover {
    opacity: 1;
}

/* Messages Area */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: rgba(248, 250, 252, 0.4);
}

.message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 0.9rem;
    line-height: 1.4;
    position: relative;
    display: flex;
    flex-direction: column;
}

.message-status {
    align-self:self-end;
    font-size: 0.75rem;
    margin-top: 4px;
    color: #3b82f6;
    /* Modern Blue */
    opacity: 0.9;
}

.user-message .message-status {
    color: rgba(15, 30, 240, 0.8);
    /* White ticks for user's dark green background */
}

.expert-message .message-status {
    color: #3b82f6;
}

.system-message {
    align-self: flex-start;
    background: white;
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.user-message {
    align-self: flex-end;
    background: var(--accent-color);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(85, 107, 47, 0.2);
}

.expert-message {
    align-self: flex-start;
    background: #f1f5f9;
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

/* Input Area */
.chat-input-area {
    padding: 20px;
    background: white;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

#chatForm {
    display: flex;
    gap: 10px;
}

#chatInput {
    flex: 1;
    border: 1px solid #e2e8f0;
    padding: 10px 16px;
    border-radius: 99px;
    outline: none;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

#chatInput:focus {
    border-color: var(--accent-color);
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.chat-send-btn:hover {
    transform: scale(1.1);
}

/* Typing Indicator */
.typing-indicator {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    display: none;
    align-items: center;
    gap: 4px;
}

.typing-indicator span {
    width: 4px;
    height: 4px;
    background: #cbd5e1;
    border-radius: 50%;
    animation: typing-bounce 1s infinite alternate;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-bounce {
    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(-4px);
    }
}

/* Mobile Adjustments */
@media (max-width: 480px) {
    .chatbot-wrapper {
        bottom: 20px;
        right: 20px;
    }

    .chat-window {
        width: calc(100vw - 40px);
        height: 70vh;
        bottom: 70px;
    }
}