/* Chatbot Variables */
:root {
    --chat-primary: var(--color-primary);
    --chat-accent: var(--color-accent);
    --chat-bg: #ffffff;
    --chat-text: var(--color-gray-900);
    --chat-width: 380px;
    --chat-height: 500px;
    --chat-radius: 16px;
    --chat-shadow: 0 12px 28px rgba(0, 0, 0, 0.15);
}

[data-theme='dark'] {
    --chat-bg: #04052e;
    --chat-text: #ffffff;
    --chat-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
}

/* Chatbot Container */
#chatbot-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
}

/* Chat Toggle Button */
.chatbot-toggle {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--chat-primary), var(--color-primary-dark));
    border-radius: 50%;
    border: none;
    box-shadow: 0 4px 12px rgba(4, 102, 200, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.chatbot-toggle:hover {
    transform: scale(1.1) rotate(-5deg);
    box-shadow: 0 8px 24px rgba(4, 102, 200, 0.4);
}

.chatbot-toggle i,
.chatbot-toggle img {
    transition: transform 0.3s ease;
}

.chatbot-toggle.active i,
.chatbot-toggle.active img {
    transform: rotate(90deg);
}

/* Chat Window */
.chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: var(--chat-width);
    height: var(--chat-height);
    background: var(--chat-bg);
    border-radius: var(--chat-radius);
    box-shadow: var(--chat-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: 1px solid rgba(128, 128, 128, 0.1);
}

.chatbot-window.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Header */
.chat-header {
    background: linear-gradient(135deg, var(--chat-primary), var(--color-primary-dark));
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #fff;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chat-header span {
    font-size: 12px;
    opacity: 0.8;
}

.chat-close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    font-size: 18px;
    padding: 5px;
}

.chat-close:hover {
    color: #fff;
}

/* Messages Area */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: rgba(0, 0, 0, 0.02);
}

.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    animation: fadeIn 0.3s ease;
}

.message-bot {
    background: rgba(4, 102, 200, 0.1);
    color: var(--chat-text);
    border-bottom-left-radius: 2px;
    align-self: flex-start;
}

.message-user {
    background: var(--chat-primary);
    color: #fff;
    border-bottom-right-radius: 2px;
    align-self: flex-end;
    box-shadow: 0 2px 5px rgba(4, 102, 200, 0.2);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: rgba(4, 102, 200, 0.1);
    border-radius: 12px;
    border-bottom-left-radius: 2px;
    align-self: flex-start;
    width: fit-content;
    margin-bottom: 10px;
    display: none;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--color-primary);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

/* Input Area */
.chat-input-area {
    padding: 15px;
    background: var(--chat-bg);
    border-top: 1px solid rgba(128, 128, 128, 0.1);
    display: flex;
    gap: 10px;
    align-items: center;
}

#chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid rgba(128, 128, 128, 0.2);
    border-radius: 20px;
    background: transparent;
    color: var(--chat-text);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#chat-input:focus {
    border-color: var(--chat-primary);
}

.send-btn {
    background: var(--chat-primary);
    color: #fff;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.send-btn:hover {
    transform: scale(1.05);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Disclaimer */
.chat-disclaimer {
    font-size: 10px;
    text-align: center;
    padding: 8px;
    color: var(--color-gray-500);
    background: var(--chat-bg);
    border-top: 1px solid rgba(128, 128, 128, 0.05);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes typing {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .chatbot-window {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
        position: fixed;
        top: 0;
        z-index: 10000;
    }

    #chatbot-container {
        bottom: 20px;
        right: 20px;
    }

    .chatbot-toggle {
        width: 50px;
        height: 50px;
    }
}