/* AI Chatbot Styles */

#ai-chat-widget {
    position: fixed;
    bottom: calc(3rem + 48px);
    right: 2rem;
    z-index: 9999;
    font-family: 'DM Sans', sans-serif;
}

#chat-fab {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(79, 156, 249, 0.4);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s;
}

#chat-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 28px rgba(79, 156, 249, 0.5);
}

#chat-fab:active {
    transform: scale(0.95);
}

#chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background: rgba(10, 15, 30, 0.85); /* Matches dark theme modal overlay logic */
    backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    opacity: 1;
    transform: translateY(0) scale(1);
    transform-origin: bottom right;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), visibility 0.3s;
    visibility: visible;
}

#chat-window.hidden {
    opacity: 0;
    transform: translateY(20px) scale(0.9);
    visibility: hidden;
    pointer-events: none;
}

/* Light theme support */
body.light-theme #chat-window {
    background: rgba(255, 255, 255, 0.85);
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid var(--card-border);
}

.chat-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#reset-chat {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

#reset-chat:hover {
    color: var(--accent);
    background: rgba(255, 255, 255, 0.05);
}

.chat-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-status-dot {
    width: 8px;
    height: 8px;
    background: #10B981;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.chat-title h3 {
    font-family: 'Syne', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

#close-chat {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

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

.chat-messages {
    flex: 1;
    padding: 1.25rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Scrollbar styles for chat */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}
.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: var(--card-border);
    border-radius: 10px;
}

.chat-msg {
    display: flex;
    max-width: 85%;
    animation: fadeIn 0.3s ease forwards;
}

.chat-msg.bot {
    align-self: flex-start;
}

.chat-msg.user {
    align-self: flex-end;
}

.msg-bubble {
    padding: 0.85rem 1.15rem;
    border-radius: 20px;
    font-size: 0.92rem;
    line-height: 1.5;
    color: var(--text);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.chat-msg.bot .msg-bubble {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-bottom-left-radius: 4px;
}

.chat-msg.user .msg-bubble {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(79, 156, 249, 0.25);
}

.chat-input-area {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    border-top: 1px solid var(--card-border);
    background: rgba(255, 255, 255, 0.02);
}

#chat-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 0.75rem 1rem;
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
}

#chat-input:focus {
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.08);
}

#chat-input::placeholder {
    color: var(--text-muted);
}

#send-btn {
    background: var(--accent);
    color: white;
    border: none;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    flex-shrink: 0;
}

#send-btn:hover {
    background: var(--accent2);
    transform: scale(1.05);
}

#send-btn:active {
    transform: scale(0.95);
}

#send-btn:disabled {
    background: var(--card-border);
    color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
}

/* Typing Indicator */
.typing-dots {
    display: flex;
    gap: 4px;
    padding: 4px 2px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.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); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

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

/* Mobile Responsiveness */
@media (max-width: 480px) {
    #ai-chat-widget {
        bottom: 1rem;
        right: 1rem;
    }
    
    #chat-window {
        position: fixed;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 80vh;
        max-height: 100vh;
        border-radius: 20px 20px 0 0;
        border-bottom: none;
        border-right: none;
        border-left: none;
    }

    #chat-window.hidden {
        transform: translateY(100%);
    }
}

/* Starter Chips */
.starter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    animation: fadeIn 0.5s ease 0.2s forwards;
    opacity: 0;
}

.chip {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    border-radius: 50px;
    padding: 7px 14px;
    color: var(--text);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
}

.chip:hover {
    background: var(--accent-glow);
    border-color: var(--accent);
    transform: translateY(-3px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);
}

.chip:active {
    transform: translateY(0);
}

/* Markdown Styling in Bubbles */
.msg-bubble p {
    margin: 0 0 0.5rem 0;
}
.msg-bubble p:last-child {
    margin-bottom: 0;
}

.msg-bubble ul, .msg-bubble ol {
    margin: 0.5rem 0;
    padding-left: 1.25rem;
}

.msg-bubble li {
    margin-bottom: 0.25rem;
}

.msg-bubble a {
    color: inherit;
    text-decoration: underline;
    font-weight: 500;
}

.chat-msg.bot .msg-bubble a {
    color: var(--accent);
}

.msg-bubble strong {
    font-weight: 600;
}
