/* 
========================================
   MARCO AI - PREMIUM CHATBOT UI
======================================== 
*/

:root {
    --chat-primary: var(--primary-blue, #0437f2);
    --chat-bg: rgba(15, 15, 15, 0.85);
    --chat-text: #ffffff;
    --chat-text-muted: rgba(255, 255, 255, 0.7);
    --chat-border: rgba(255, 255, 255, 0.1);
    --chat-glass: blur(20px) saturate(180%);
    --chat-radius: 20px;
}

[data-theme="light"] {
    --chat-bg: rgba(255, 255, 255, 0.9);
    --chat-text: #1a1a1a;
    --chat-text-muted: #666666;
    --chat-border: rgba(0, 0, 0, 0.1);
}

#ai-chat-wrapper {
    position: fixed !important;
    bottom: 30px !important;
    right: 32px !important;
    z-index: 9999 !important;
    font-family: 'Poppins', sans-serif;
}

/* Chat Toggle Button */
#chat-toggle {
    width: 62px !important;
    height: 62px !important;
    background: linear-gradient(135deg, var(--chat-primary) 0%, #001a80 100%) !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 10px 30px rgba(4, 55, 242, 0.3) !important;
    cursor: pointer !important;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: white !important;
    font-size: 1.8rem !important;
    position: relative !important;
}

#chat-toggle:hover {
    transform: scale(1.1) rotate(5deg) !important;
    box-shadow: 0 15px 40px rgba(4, 55, 242, 0.5) !important;
    filter: brightness(1.1) !important;
}

.bot-dot {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 12px;
    height: 12px;
    background: #00ff88;
    border-radius: 50%;
    border: 2px solid white;
}

/* Chat Window */
#chat-window {
    position: absolute;
    bottom: 85px;
    right: 0;
    width: 380px;
    height: 550px;
    background: var(--chat-bg);
    backdrop-filter: var(--chat-glass);
    -webkit-backdrop-filter: var(--chat-glass);
    border: 1px solid var(--chat-border);
    border-radius: var(--chat-radius);
    display: none;
    flex-direction: column;
    overflow: hidden;
    color: var(--chat-text);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    animation: chat-slide 0.4s ease-out;
    transform-origin: bottom right;
}

@keyframes chat-slide {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

#chat-window.active {
    display: flex;
}

/* Header */
.chat-header {
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid var(--chat-border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header .avatar {
    width: 40px;
    height: 40px;
    background: var(--chat-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.chat-header .info h4 {
    font-size: 0.95rem;
    margin: 0;
    font-weight: 700;
}

.chat-header .info p {
    font-size: 0.75rem;
    margin: 0;
    color: #00ff88;
    font-weight: 500;
}

#close-chat {
    margin-left: auto;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    font-size: 1.2rem;
}

/* Body */
#chat-body {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scroll-behavior: smooth;
}

.msg {
    max-width: 85%;
    padding: 0.8rem 1.2rem;
    border-radius: 15px;
    font-size: 0.85rem;
    line-height: 1.5;
    position: relative;
    animation: msg-pop 0.3s ease-out;
}

@keyframes msg-pop {
    from {
        transform: scale(0.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.msg.bot {
    background: rgba(var(--primary-rgb, 4, 55, 242), 0.08);
    color: var(--chat-text);
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

.msg.user {
    background: var(--chat-primary);
    color: #ffffff;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

/* Typing Indicator */
.typing {
    display: flex;
    gap: 4px;
    padding: 0.5rem 1rem;
}

.typing span {
    width: 6px;
    height: 6px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    animation: typing 1s infinite alternate;
}

.typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(-5px);
    }
}

/* Input Area */
.chat-input-area {
    padding: 1.2rem;
    border-top: 1px solid var(--chat-border);
    display: flex;
    gap: 10px;
}

#chat-input {
    flex: 1;
    background: rgba(var(--primary-rgb, 4, 55, 242), 0.03);
    border: 1px solid var(--chat-border);
    border-radius: 25px;
    padding: 0.6rem 1.2rem;
    color: var(--chat-text);
    font-size: 0.85rem;
    outline: none;
    transition: all 0.3s;
}

#chat-input:focus {
    border-color: var(--chat-primary);
    background: rgba(255, 255, 255, 0.08);
}

#send-chat {
    width: 40px;
    height: 40px;
    background: var(--chat-primary);
    border-radius: 50%;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.3s;
}

#send-chat:hover {
    transform: rotate(15deg);
}

/* RTL Adjustments */
[dir="rtl"] #ai-chat-wrapper {
    right: auto !important;
    left: 32px !important;
}

[dir="rtl"] #chat-window {
    right: auto;
    left: 0;
    transform-origin: bottom left;
}

[dir="rtl"] .msg.bot {
    border-bottom-left-radius: 15px;
    border-bottom-right-radius: 2px;
    align-self: flex-start;
}

[dir="rtl"] .msg.user {
    border-bottom-right-radius: 15px;
    border-bottom-left-radius: 2px;
    align-self: flex-end;
}

/* Action Cards & Buttons */
.action-card {
    border: 1px solid var(--chat-border);
    animation: action-slide 0.5s cubic-bezier(0.23, 1, 0.32, 1);
}

@keyframes action-slide {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.action-card .btn-primary {
    background: var(--chat-primary);
    border: none;
    color: white;
    font-weight: 600;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(4, 55, 242, 0.3);
}

.action-card .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(4, 55, 242, 0.5);
}

/* Scrollbar Style */
#chat-body::-webkit-scrollbar {
    width: 4px;
}

#chat-body::-webkit-scrollbar-track {
    background: transparent;
}

#chat-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

@media (max-width: 768px) {
    #ai-chat-wrapper {
        bottom: 20px !important;
        right: 20px !important;
    }

    #chat-toggle {
        width: 55px !important;
        height: 55px !important;
        font-size: 1.6rem !important;
    }

    #chat-window {
        position: fixed !important;
        bottom: 0 !important;
        right: 0 !important;
        width: 100vw !important;
        height: 100dvh !important;
        height: 100% !important;
        /* Fallback */
        max-height: 100dvh !important;
        border-radius: 0 !important;
        z-index: 10001 !important;
        transform: none !important;
    }

    .chat-header {
        padding: 1rem !important;
    }

    [dir="rtl"] #ai-chat-wrapper {
        right: auto !important;
        left: 20px !important;
    }
}