/* Explain: CSS for AI assistant chat interface and buttons. */
.ai-inline-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    background: var(--field-bg);
    padding: 0.4rem 0.85rem;
    color: var(--sage-dark);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    transition: border-color 250ms ease, color 250ms ease;
}

.ai-inline-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.ai-inline-btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

.ai-launcher {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 60;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border: 0;
    border-radius: 999px;
    background: var(--primary-color);
    padding: 0.85rem 1.15rem;
    color: #ffffff;
    font-size: 0.9rem;
    font-weight: 700;
    box-shadow: var(--shadow-button);
    transition: transform 250ms ease, background 250ms ease;
}

.ai-launcher:hover {
    background: var(--accent-color);
    transform: translateY(-2px);
}

body.has-mobile-cta .ai-launcher {
    bottom: 6.25rem;
}

.ai-chat-panel {
    position: fixed;
    right: 1.25rem;
    bottom: 5.5rem;
    z-index: 60;
    display: flex;
    width: min(23rem, calc(100vw - 2.5rem));
    height: min(30rem, calc(100vh - 12rem));
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    border-radius: 1.6rem;
    background: #ffffff;
    box-shadow: 0 30px 80px rgba(27, 46, 92, 0.22);
}

body.has-mobile-cta .ai-chat-panel {
    bottom: 10.5rem;
}

@media (min-width: 1024px) {
    body.has-mobile-cta .ai-launcher {
        bottom: 1.5rem;
    }

    body.has-mobile-cta .ai-chat-panel {
        bottom: 5.5rem;
    }
}

.ai-chat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    background: var(--primary-color);
    padding: 0.9rem 1rem;
    color: #ffffff;
}

.ai-chat-title {
    margin: 0;
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 700;
}

.ai-chat-sub {
    margin: 0.1rem 0 0;
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.78);
}

.ai-chat-close {
    display: inline-flex;
    height: 2.25rem;
    width: 2.25rem;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
    transition: background 250ms ease;
}

.ai-chat-close:hover {
    background: rgba(255, 255, 255, 0.32);
}

.ai-chat-log {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: var(--background-color);
}

.ai-row {
    display: flex;
    margin-bottom: 0.6rem;
}

.ai-row-user {
    justify-content: flex-end;
}

.ai-row-bot {
    justify-content: flex-start;
}

.ai-bubble {
    max-width: 86%;
    border-radius: 1.1rem;
    padding: 0.6rem 0.85rem;
    font-size: 0.86rem;
    line-height: 1.55;
    word-break: break-word;
}

.ai-bubble-bot {
    border: 1px solid var(--glass-border);
    border-bottom-left-radius: 0.3rem;
    background: #ffffff;
    color: var(--text-color);
}

.ai-bubble-user {
    border-bottom-right-radius: 0.3rem;
    background: var(--primary-color);
    color: #ffffff;
}

.ai-link {
    color: var(--accent-color);
    font-weight: 700;
    text-decoration: underline;
}

.ai-dots {
    display: inline-flex;
    gap: 0.25rem;
}

.ai-dots span {
    display: block;
    width: 0.4rem;
    height: 0.4rem;
    border-radius: 999px;
    background: var(--text-muted);
    animation: ai-bounce 1s infinite ease-in-out;
}

.ai-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.ai-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes ai-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

.ai-chat-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-top: 1px solid var(--glass-border);
    background: #ffffff;
    padding: 0.7rem;
}

.ai-chat-input {
    flex: 1;
    height: 2.75rem;
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    background: var(--field-bg);
    padding: 0 1rem;
    color: var(--text-color);
    font-size: 0.86rem;
}

.ai-chat-input:focus {
    border-color: var(--accent-color);
    outline: none;
}

.ai-chat-send {
    display: inline-flex;
    height: 2.75rem;
    width: 2.75rem;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 999px;
    background: var(--primary-color);
    color: #ffffff;
    transition: background 250ms ease;
}

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