/* AI Assistant Widget - Terreta Stylings */
:root {
    /* Based on Terreta Brand Colors */
    --ai-primary: #0a0a0a;
    --ai-accent: #ffffff;
    --ai-bg: rgba(255, 255, 255, 0.98);
    --ai-text: #1a1a1a;
    --ai-shadow: 0 15px 45px rgba(0, 0, 0, 0.2);
    --ai-round: 24px;
}

#ai-chat-widget {
    position: fixed !important;
    bottom: 25px !important;
    right: 25px !important;
    left: auto !important;
    z-index: 20000 !important;
    font-family: inherit;
    /* Use site font */
}

/* Floating Bubble */
.ai-chat-bubble {
    width: 60px;
    height: 60px;
    background: #252423;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--ai-shadow);
    transition: all 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(20px);
}

.ai-chat-bubble:hover {
    transform: scale(1.1) rotate(5deg) !important;
    box-shadow: 0 20px 50px rgba(248, 194, 71, 0.25);
}

.ai-chat-bubble i,
.ai-chat-bubble svg {
    color: var(--ai-accent);
    font-size: 1.6rem;
    width: 28px;
    height: 28px;
}

/* Chat Window */
.ai-chat-window {
    position: absolute;
    bottom: 0px;
    right: 0;
    width: 380px;
    height: 620px;
    background: var(--ai-bg);
    border-radius: var(--ai-round);
    box-shadow: var(--ai-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(30px) scale(0.95);
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

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

/* Header */
.ai-chat-header {
    background: var(--ai-primary);
    padding: 0.25rem 1.5rem;
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid var(--ai-accent);
}

.ai-chat-header-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-chat-header-info img {
    width: 75px;
    height: 75px;
    object-fit: contain;
    background: #0a0a0a;
    border-radius: 10%;
    padding: 1px;
}

.ai-chat-header h4 {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--ai-accent) !important;
}

.ai-chat-close {
    cursor: pointer;
    opacity: 0.8;
    transition: transform 0.2s;
    font-size: 1.2rem;
}

.ai-chat-close:hover {
    opacity: 1;
    transform: rotate(90deg);
}

/* Messages Area */
.ai-chat-messages {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    scroll-behavior: smooth;
}

.ai-message {
    max-width: 88%;
    padding: 0.9rem 1.2rem;
    border-radius: 20px;
    font-size: 0.95rem;
    line-height: 1.55;
    white-space: pre-line;
    word-wrap: break-word;
    animation: aiFadeIn 0.4s ease forwards;
}

.ai-message.bot {
    align-self: flex-start;
    background: #f1f3f5;
    color: var(--ai-text);
    border-bottom-left-radius: 4px;
}

.ai-message.user {
    align-self: flex-end;
    background: var(--ai-primary);
    color: white;
    border-bottom-right-radius: 4px;
    border: 1px solid rgba(248, 194, 71, 0.3);
}

/* Input Area */
.ai-chat-input-area {
    padding: 1rem 1.2rem;
    background: white;
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.ai-chat-input-area input {
    flex: 1;
    min-width: 0;
    /* Allow shrinking in flex */
    border: 1px solid #e0e0e0;
    padding: 0.85rem 1.2rem;
    border-radius: 30px;
    outline: none;
    font-size: 0.95rem;
    transition: all 0.3s;
}

.ai-chat-input-area input:focus {
    border-color: #c49622;
    box-shadow: 0 0 0 1px #c49622;
}

.ai-chat-send,
.ai-chat-mic {
    width: 45px;
    height: 45px;
    min-width: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--ai-primary);
    border: 1px solid var(--ai-accent);
    color: var(--ai-accent);
}

.ai-chat-send:hover,
.ai-chat-mic:hover {
    background: #c49622;
    color: var(--ai-primary);
}

.ai-chat-mic.recording {
    background: #ff4757;
    color: white;
    border-color: #ff4757;
    animation: micPulse 1.5s infinite;
}

@keyframes micPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.4);
    }

    70% {
        transform: scale(1.1);
        box-shadow: 0 0 0 10px rgba(255, 71, 87, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 71, 87, 0);
    }
}


/* Typing Indicator */
.ai-chat-typing {
    padding: 0 1.5rem 1rem;
}

.typing-dots {
    display: flex;
    gap: 5px;
    padding: 10px 18px;
    background: #f1f3f5;
    width: fit-content;
    border-radius: 20px;
    border-bottom-left-radius: 4px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: #adb5bd;
    border-radius: 50%;
    animation: aiTypingBounce 1.4s infinite ease-in-out;
}

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

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

@keyframes aiTypingBounce {

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

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

/* Markdown support */
.ai-message strong {
    font-weight: 700;
    color: var(--ai-accent-dark, #c49622);
}

.ai-message.user strong {
    color: var(--ai-accent);
}

.ai-btn-wa {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: #25D366;
    color: white !important;
    padding: 12px 20px;
    border-radius: 30px;
    text-decoration: none !important;
    font-weight: 700;
    margin-top: 12px;
    font-size: 0.9rem;
    box-shadow: 0 5px 15px rgba(37, 211, 102, 0.3);
    transition: all 0.3s;
}

.ai-btn-wa:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(37, 211, 102, 0.4);
}

.ai-btn-standard {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--ai-primary);
    color: var(--ai-accent) !important;
    padding: 12px 20px;
    border-radius: 30px;
    text-decoration: none !important;
    font-weight: 700;
    margin-top: 12px;
    font-size: 0.9rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s;
    border: 1px solid var(--ai-accent);
}

.ai-btn-standard:hover {
    transform: translateY(-2px);
    background: var(--ai-accent);
    color: var(--ai-primary) !important;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

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

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

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

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

/* Mobile responsive */
@media (max-width: 600px) {
    #ai-chat-widget {
        bottom: 20px !important;
        right: 20px !important;
    }

    .ai-chat-bubble {
        width: 56px;
        height: 56px;
    }

    .ai-chat-window {
        position: fixed;
        left: 50%;
        bottom: 88px;
        width: calc(100vw - 32px);
        height: 70vh;
        transform: translateX(-50%) translateY(20px) scale(0.95);
        right: auto;
    }

    .ai-chat-header {
        padding: 0.2rem 1rem;
    }

    .ai-chat-header h4 {
        font-size: 1.5rem;
    }

    .ai-chat-header-info img {
        width: 50px;
        height: 50px;
    }

    .ai-chat-window.active {
        transform: translateX(-50%) translateY(0) scale(1);
    }

    .ai-chat-input-area {
        padding: 0.8rem 1rem;
        gap: 8px;
    }

    .ai-chat-input-area input {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }

    .ai-chat-send,
    .ai-chat-mic {
        width: 40px;
        height: 40px;
        min-width: 40px;
    }
}