/* ===========================
   Chatbot Floating Widget
============================= */

/* Floating Action Button (FAB) */
.chat-fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 8px 25px rgb(99 102 241 / 40%);
    cursor: pointer;
    z-index: 9999;
    transition: all var(--transition-smooth);
    border: none;
    outline: none;
}

.chat-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 35px rgb(99 102 241 / 60%);
}

/* Chat Window Container */
.chat-window {
    position: fixed;
    bottom: 110px;
    right: 30px;
    width: 350px;
    max-height: 500px;
    background: var(--glass-bg);
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(16px);
    box-shadow: var(--glass-shadow);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.chat-window.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

/* Chat Header */
.chat-header {
    background: rgb(255 255 255 / 10%);
    padding: 15px 20px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h3 {
    margin: 0;
    font-size: 16px;
    font-family: var(--font-heading);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-header h3 i {
    color: #6366f1;
}

.close-chat {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.close-chat:hover {
    color: var(--text-primary);
}

/* Chat Messages Area */
.chat-messages {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    height: 300px;
}

/* Scrollbar styling for chat */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgb(0 0 0 / 10%);
    border-radius: 10px;
}

/* Individual Messages */
.message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.4;
    font-family: var(--font-body);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.bot {
    align-self: flex-start;
    background: rgb(255 255 255 / 70%);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.message.user {
    align-self: flex-end;
    background: var(--primary-gradient);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.system {
    align-self: center;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    text-align: center;
    max-width: 100%;
}

/* API Key Setup State */
.api-key-setup {
    padding: 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.api-key-setup p {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
}

.api-key-setup input {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    background: rgb(255 255 255 / 50%);
    font-size: 14px;
    outline: none;
    transition: all var(--transition-fast);
}

.api-key-setup input:focus {
    border-color: #6366f1;
    background: white;
}

.api-key-setup button {
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.api-key-setup button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgb(99 102 241 / 30%);
}

.api-key-setup a {
    color: #6366f1;
    font-size: 12px;
    text-decoration: none;
}

.api-key-setup a:hover {
    text-decoration: underline;
}

/* Chat Input Area */
.chat-input-area {
    display: flex;
    padding: 15px;
    border-top: 1px solid var(--glass-border);
    background: rgb(255 255 255 / 20%);
    gap: 10px;
}

.chat-input-area input {
    flex-grow: 1;
    padding: 10px 15px;
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    font-family: var(--font-body);
    font-size: 14px;
    outline: none;
    background: rgb(255 255 255 / 70%);
    transition: all var(--transition-fast);
}

.chat-input-area input:focus {
    background: white;
    border-color: #6366f1;
}

.chat-input-area button {
    background: var(--primary-gradient);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.chat-input-area button:hover {
    transform: scale(1.1);
}

.chat-input-area button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    align-items: center;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: typingBounce 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;
}

@keyframes typingBounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Adjustments for smaller screens */
@media (width <=480px) {
    .chat-window {
        bottom: 0;
        right: 0;
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
        transform: translateY(100%);
    }

    .chat-messages {
        height: auto;
    }

    .chat-fab {
        bottom: 20px;
        right: 20px;
    }
}