/* AI Chat Styling - Moved from footer.php */

/* Added styles for the end chat button */
/* AI Chat Theme Integation */
.header-action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.95rem;
    cursor: pointer;
    transition: 0.3s;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.header-action-btn:hover {
    color: var(--accent-red);
    background: rgba(127, 127, 127, 0.1);
}

.ai-chat-float {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    /* English default */
    right: auto;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    width: 65px;
    height: 65px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    box-shadow: 0 10px 30px var(--shadow-color);
    z-index: 99999;
    cursor: pointer;
    transition: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 2px solid var(--glass-border);
}

.ai-chat-float:hover {
    transform: scale(1.1) translateY(-5px);
    box-shadow: 0 15px 35px var(--shadow-color);
}

.ai-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--accent-red);
    color: white;
    font-size: 0.6rem;
    font-weight: bold;
    padding: 2px 5px;
    border-radius: 10px;
    border: 2px solid var(--bg-main);
}

.ai-chat-window {
    position: fixed;
    bottom: 7.5rem;
    left: 2rem;
    right: auto;
    width: 380px;
    height: 600px;
    max-height: 80vh;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    padding: 0 !important;
    overflow: hidden;
    visibility: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom left;
    transition: 0.4s cubic-bezier(0.19, 1, 0.22, 1);

    /* THEME ADAPTIVE BACKGROUND */
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 20px 60px var(--shadow-color);
    border-radius: 1.5rem;
}

.ai-chat-window.show {
    visibility: visible;
    opacity: 1;
    transform: translateY(0) scale(1);
}

.ai-chat-header {
    padding: 1.2rem;
    background: linear-gradient(90deg, rgba(var(--primary-rgb), 0.1), transparent);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-main);
}

.ai-avatar {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: white;
    box-shadow: 0 4px 15px var(--shadow-color);
}

.close-chat {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    transition: 0.3s;
    line-height: 1;
    padding: 5px;
    border-radius: 50%;
}

.close-chat:hover {
    color: var(--accent-red);
    background: rgba(127, 127, 127, 0.1);
}

.ai-chat-messages {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    background: transparent;
}

/* Custom Scrollbar */
.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
    opacity: 0.5;
}

.ai-message {
    max-width: 85%;
    padding: 1rem 1.2rem;
    border-radius: 1.2rem;
    font-size: 0.95rem;
    line-height: 1.6;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 2px 5px var(--shadow-color);
    white-space: pre-wrap;
}

.ai-message.assistant {
    /* Adaptive gray background for both light/dark */
    background: rgba(127, 127, 127, 0.1);
    color: var(--text-main);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: 1px solid var(--glass-border);
}

.ai-message.user {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.ai-chat-input-area {
    padding: 1.2rem;
    /* Theme adaptive background */
    background: var(--bg-main);
    display: flex;
    gap: 0.8rem;
    border-top: 1px solid var(--glass-border);
}

.ai-chat-input-area input {
    flex: 1;
    background: var(--bg-card);
    /* Adaptive input bg */
    border: 1px solid var(--glass-border);
    border-radius: 1.5rem;
    padding: 0.8rem 1.2rem;
    color: var(--text-main);
    font-size: 0.95rem;
    outline: none;
    transition: 0.3s;
}

.ai-chat-input-area input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(0, 200, 83, 0.1);
}

.ai-chat-input-area button {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    transition: 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px var(--shadow-color);
}

.ai-chat-input-area button:hover {
    transform: scale(1.05);
}

.typing-loader {
    display: flex;
    gap: 4px;
    padding: 5px 0;
}

.typing-loader span {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 0.8s infinite alternate;
}

.typing-loader span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-loader span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    from {
        opacity: 0.3;
        transform: translateY(0);
    }

    to {
        opacity: 1;
        transform: translateY(-5px);
    }
}

/* RTL Support - Swapped */
[dir="rtl"] .ai-chat-float {
    left: auto;
    right: 2rem;
}

[dir="rtl"] .ai-chat-window {
    left: auto;
    right: 2rem;
    transform-origin: bottom right;
}

[dir="rtl"] .ai-message.assistant {
    border-bottom-left-radius: 1.2rem;
    border-bottom-right-radius: 4px;
}

[dir="rtl"] .ai-message.user {
    border-bottom-right-radius: 1.2rem;
    border-bottom-left-radius: 4px;
}

@media (max-width: 480px) {
    .ai-chat-float {
        width: 50px;
        height: 50px;
        font-size: 1.3rem;
        bottom: 1.2rem;
    }

    [dir="rtl"] .ai-chat-float {
        right: 1.2rem;
    }

    [dir="ltr"] .ai-chat-float {
        left: 1.2rem;
    }

    .ai-chat-window {
        width: calc(100% - 2rem);
        bottom: 4.5rem;
        left: 1rem !important;
        right: 1rem !important;
        height: 70vh;
    }
}