/* Bot Variables */
:root {
    --bot-primary: #ff6b9d;
    /* Matching the secondary color from main theme */
    --bot-bg: rgba(255, 255, 255, 0.85);
    --bot-text: #1d1d1f;
    --bot-user-bg: #0071e3;
    --bot-user-text: #ffffff;
    --bot-font-tech: 'Courier New', Courier, monospace;
    --bot-width: 350px;
    --bot-height: 500px;
    --bot-radius: 20px;
    --bot-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] {
    --bot-bg: rgba(30, 30, 35, 0.85);
    --bot-text: #f5f5f7;
    --bot-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

/* Floating Action Button (Avatar) */
.bot-avatar-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    cursor: pointer;
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.6s ease;
}

.bot-avatar-container.hidden {
    transform: translateY(100px) scale(0.5);
    opacity: 0;
    pointer-events: none;
}

.bot-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bot-primary), #ff8fa3);
    box-shadow: 0 4px 12px rgba(255, 107, 157, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    position: relative;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.5);
}

.bot-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s ease;
}

.bot-avatar-container:hover {
    transform: scale(1.1);
}

/* Breathing Animation */
@keyframes breathe {

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

    50% {
        transform: scale(1.05);
    }
}

.bot-avatar-container.idle {
    animation: breathe 3s infinite ease-in-out;
}

/* Tooltip */
.bot-tooltip {
    position: absolute;
    right: 75px;
    top: 50%;
    transform: translateY(-50%) translateX(10px);
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 14px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    box-shadow: var(--elevation-2);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
}

.bot-tooltip.show {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

/* Chat Window */
.chat-window {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: var(--bot-width);
    height: var(--bot-height);
    background: var(--bot-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: var(--bot-radius);
    box-shadow: var(--bot-shadow);
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9998;
    transform-origin: bottom right;
    transform: scale(0);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

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

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

.chat-title {
    font-weight: 600;
    font-size: 16px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-status-dot {
    width: 8px;
    height: 8px;
    background: #34c759;
    border-radius: 50%;
    display: inline-block;
}

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

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

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

/* Message Bubbles */
.message {
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
    animation: popIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }

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

.message.bot {
    align-self: flex-start;
    background: rgba(0, 0, 0, 0.05);
    color: var(--bot-text);
    border-bottom-left-radius: 4px;
    font-family: var(--bot-font-tech);
}

[data-theme="dark"] .message.bot {
    background: rgba(255, 255, 255, 0.1);
}

.message.user {
    align-self: flex-end;
    background: var(--bot-user-bg);
    color: var(--bot-user-text);
    border-bottom-right-radius: 4px;
}

.message-link {
    display: inline-block;
    margin-top: 8px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.2);
    color: inherit;
    text-decoration: none;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    transition: background 0.2s;
}

.message-link:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Typing Indicator */
.typing-indicator {
    align-self: flex-start;
    background: rgba(0, 0, 0, 0.05);
    padding: 10px 15px;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    display: none;
    /* Hidden by default */
    gap: 4px;
    align-items: center;
    height: 40px;
}

[data-theme="dark"] .typing-indicator {
    background: rgba(255, 255, 255, 0.1);
}

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

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

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

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

.chat-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid transparent;
    border-radius: 20px;
    padding: 10px 15px;
    font-family: var(--font-primary);
    font-size: 14px;
    color: var(--text-primary);
    outline: none;
    transition: all 0.2s;
}

[data-theme="dark"] .chat-input {
    background: rgba(255, 255, 255, 0.1);
}

.chat-input:focus {
    background: var(--bg-secondary);
    border-color: var(--accent);
}

.chat-send {
    background: var(--bot-primary);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.chat-send:hover {
    transform: scale(1.1);
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .chat-window {
        width: 90%;
        right: 5%;
        bottom: 100px;
        height: 60vh;
    }
}