/* ============================================
   AI Chat UI Styles
   ============================================ */
.ai-fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--accent-gradient);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    box-shadow: var(--shadow-glow);
    cursor: pointer;
    z-index: 1000;
    transition: all var(--transition-base);
    box-sizing: border-box;
}

.ai-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 0 20px var(--accent-glow);
}

.ai-chat-panel {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.ai-chat-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.ai-chat-header {
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-chat-header-title {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.ai-chat-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.ai-chat-action-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    transition: color var(--transition-fast), transform var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.ai-chat-action-btn:hover {
    color: var(--text-primary);
    transform: scale(1.1);
}

.ai-chat-panel.fullscreen {
    top: 5vh;
    left: 5vw;
    bottom: 5vh;
    right: 5vw;
    width: 90vw;
    height: 90vh;
    max-height: 90vh;
    transform: translateY(0) scale(1);
    z-index: 9999;
}

.ai-chat-messages {
    flex: 1;
    padding: var(--space-md);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    background: #0b0f19;
}

.ai-message {
    max-width: 85%;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    line-height: 1.5;
    animation: fadeIn 0.3s ease;
}

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

.ai-message-bot {
    align-self: flex-start;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

/* Markdown elements styling inside bot messages */
.ai-message-bot p {
    margin: 0;
}
.ai-message-bot p + p {
    margin-top: 0.5em;
}

.ai-message-bot h1,
.ai-message-bot h2,
.ai-message-bot h3 {
    margin: 1em 0 0.5em;
    color: var(--text-primary);
    font-weight: 700;
    line-height: 1.3;
}
.ai-message-bot h1 { font-size: 1.4em; }
.ai-message-bot h2 { font-size: 1.25em; }
.ai-message-bot h3 { font-size: 1.1em; }
.ai-message-bot *:first-child { margin-top: 0; }

.ai-message-bot ul, 
.ai-message-bot ol {
    margin: 0.5em 0 0.5em 1.5em;
    padding: 0;
}
.ai-message-bot li {
    margin-bottom: 0.3em;
}
.ai-message-bot ul li { list-style-type: disc; }
.ai-message-bot ol li { list-style-type: decimal; }

.ai-message-bot strong {
    font-weight: 700;
    color: var(--text-primary);
}

.ai-message-bot code {
    background: var(--bg-hover);
    padding: 0.1em 0.3em;
    border-radius: 4px;
    font-family: Consolas, 'Courier New', monospace;
    font-size: 0.9em;
    color: var(--accent-secondary);
}

.ai-message-bot pre code {
    background: transparent;
    padding: 0;
    color: inherit;
}

.ai-message-bot blockquote {
    border-left: 3px solid var(--accent-primary);
    margin: 0.8em 0;
    padding-left: 0.8em;
    color: var(--text-muted);
    font-style: italic;
}

.ai-chat-input-area {
    padding: var(--space-md);
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
    display: flex;
    gap: var(--space-sm);
}

.ai-chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    outline: none;
    font-size: var(--text-sm);
    transition: all var(--transition-fast);
}

.ai-chat-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.ai-chat-send {
    background: var(--accent-primary);
    color: var(--white);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.ai-chat-send:hover {
    background: var(--accent-secondary);
}

.ai-typing-indicator {
    display: inline-flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}

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

.ai-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.ai-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

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

@media (max-width: 768px) {
    .ai-chat-panel {
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        transform: translateY(100%);
    }
    .ai-fab {
        bottom: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
        font-size: 24px;
    }
}
