.grok-chatbot {
    position: fixed;
    bottom: 32px;
    right: 32px;
    z-index: 1200;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    box-shadow: 0 8px 32px rgba(74, 144, 226, 0.10), 0 1.5px 6px rgba(80,201,195,0.08);
    border-radius: 18px;
    transition: box-shadow 0.3s, background 0.3s;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(4px);
    padding: 0;
}
.grok-chatbot-attract {
    position: absolute;
    left: 50%;
    bottom: 78px;
    transform: translateX(-50%);
    min-width: 0;
    max-width: 320px;
    color: #102040; /* dark blue */
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0.97;
    letter-spacing: 0.1px;
    background: none;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    overflow: hidden;
    border-right: 2px solid #102040;
    /* Fix: Use 'ch' unit for width animation to match character count */
    width: 0;
    animation: attract-typing 2.5s steps(13, end) 1s infinite normal both, attract-blink 0.7s steps(1) infinite;
    transition: color 0.3s;
}

@keyframes attract-typing {
    0% { width: 0; }
    60% { width: 13ch; }
    100% { width: 0; }
}

@keyframes attract-blink {
    0%, 100% { border-color: #102040; }
    50% { border-color: transparent; }
}

html[dir="rtl"] .grok-chatbot-attract {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    border-right: none;
    border-left: 2px solid #102040;
}

@media (prefers-color-scheme: dark) {
    .grok-chatbot-attract { 
        color: #0c428c;
        border-right: 2px solid #eaf1fb;
        text-shadow: 0 1px 2px rgba(26,53,91,0.18);
        letter-spacing: 0.15px;
    }
    html[dir="rtl"] .grok-chatbot-attract {
        border-right: none;
        border-left: 2px solid #eaf1fb;
    }
}
.grok-chatbot-toggle {
    width: 60px;
    height: 60px;
    background: ivory;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(26, 53, 91, 0.18); /* Subtle, formal shadow */
    transition: transform 0.3s cubic-bezier(.68,-0.55,.27,1.55), box-shadow 0.3s;
    animation: pulse-glow 2s infinite alternate, bounce 2.5s infinite;
    position: relative;
    overflow: visible;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 6px;
}

.grok-chatbot-toggle .grok-chatbot-icon {
    position: absolute;
    top: -28px;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 32px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(74, 144, 226, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    pointer-events: auto;
    cursor: pointer;
}

@keyframes pulse-glow {
    0% {
        box-shadow: 0 0 0 0 rgba(74, 144, 226, 0.4), 0 4px 15px rgba(0,0,0,0.2);
    }
    70% {
        box-shadow: 0 0 0 18px rgba(74, 144, 226, 0), 0 4px 25px rgba(80,201,195,0.25);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(74, 144, 226, 0.4), 0 4px 15px rgba(0,0,0,0.2);
    }
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0) scale(1);
    }
    10% {
        transform: translateY(-6px) scale(1.05);
    }
    20% {
        transform: translateY(-12px) scale(1.1);
    }
    30% {
        transform: translateY(-6px) scale(1.05);
    }
    40% {
        transform: translateY(0) scale(1);
    }
    100% {
        transform: translateY(0) scale(1);
    }
}

.grok-chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.grok-chatbot-toggle img {
    width: 40px;
    height: 40px;
    display: block;
    margin: 0 auto;
    filter: drop-shadow(0 2px 6px rgba(74, 144, 226, 0.25));
    transition: transform 0.3s;
}

.grok-chatbot-toggle:hover img {
    transform: scale(1.1) rotate(-5deg);
}

.grok-chatbot-window {
    display: none;
    width: 320px;
    height: 450px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    position: absolute;
    bottom: 80px;
    right: 0;
    flex-direction: column;
    transform: translateY(20px);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.grok-chatbot-window.open {
    display: flex;
    transform: translateY(0);
    opacity: 1;
}

.grok-chatbot-header {
    background: linear-gradient(90deg, #1a355b, #4a90e2); /* Deep blue for professionalism */
    color: #fff;
    padding: 14px 20px;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e5eaf3;
    font-family: 'Segoe UI', 'Microsoft YaHei', Arial, sans-serif;
}

.grok-chatbot-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.grok-chatbot-close:hover {
    transform: rotate(90deg);
}

.grok-chatbot-messages {
    flex: 1;
    padding: 24px 12px 16px 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
    scrollbar-color: #b3c2d1 #eaeef3;
    border-top: 1px solid #dbe4ee;
    border-bottom: 1px solid #dbe4ee;

    /* Formal, transparent background for trading/import-export */
    background: rgba(255, 255, 255, 0.7); /* semi-transparent white */
    backdrop-filter: blur(2px);
    /* Remove pattern for a clean, professional look */
}


.grok-chatbot-messages::-webkit-scrollbar {
    width: 8px;
    background: #eaeef3;
}

.grok-chatbot-messages::-webkit-scrollbar-thumb {
    background: #b3c2d1;
    border-radius: 4px;
}

.grok-message {
    margin-bottom: 12px;
    padding: 10px 14px;
    border-radius: 12px;
    max-width: 80%;
    font-size: 14px;
    line-height: 1.4;
    animation: fadeIn 0.3s ease;
}

.grok-message.user {
    background: #4a90e2;
    color: #fff;
    margin-left: auto;
    border-bottom-right-radius: 2px;
}

.grok-message.bot {
    background: #e8ecef;
    color: #333;
    margin-right: auto;
    border-bottom-left-radius: 2px;
}

.grok-message.typing {
    display: flex;
    align-items: center;
    background: #e8ecef;
    padding: 8px;
    border-radius: 12px;
    width: fit-content;
}

.grok-message.typing span {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: #666;
    border-radius: 50%;
    margin: 0 2px;
    animation: typing 1s infinite;
}

.grok-message.typing span:nth-child(2) { animation-delay: 0.2s; }
.grok-message.typing span:nth-child(3) { animation-delay: 0.4s; }

.grok-chatbot-input {
    display: flex;
    padding: 12px;
    background: #fff;
    border-top: 1px solid #eee;
}

.grok-chatbot-input input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

.grok-chatbot-input input:focus {
    border-color: #4a90e2;
}

.grok-chatbot-send {
    background: #4a90e2;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    margin-left: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    transition: background 0.2s ease;
}

.grok-chatbot-send:hover {
    background: #357abd;
}

.grok-chatbot-send svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}

.grok-chatbot-send::after {
    content: '';
    position: absolute;
    width: 100px;
    height: 100px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: scale(0);
    transition: transform 0.3s ease;
}

.grok-chatbot-send:active::after {
    transform: scale(1);
}

@keyframes pulse {
    0% { box-shadow: 0 4px 15px rgba(74, 144, 226, 0.2); }
    50% { box-shadow: 0 4px 25px rgba(74, 144, 226, 0.5); }
    100% { box-shadow: 0 4px 15px rgba(74, 144, 226, 0.2); }
}

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

@keyframes typing {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* RTL Support */
html[dir="rtl"] .grok-chatbot {
    right: auto;
    left: 20px;
}

html[dir="rtl"] .grok-chatbot-window {
    right: auto;
    left: 0;
}

html[dir="rtl"] .grok-message.user {
    margin-left: 0;
    margin-right: auto;
    border-bottom-right-radius: 12px;
    border-bottom-left-radius: 2px;
}

html[dir="rtl"] .grok-message.bot {
    margin-right: 0;
    margin-left: auto;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 2px;
}

html[dir="rtl"] .grok-chatbot-send {
    margin-left: 0;
    margin-right: 8px;
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
    .grok-chatbot-window { background: #1e1e1e; }
    .grok-chatbot-messages { background: #2a2a2a; }
    .grok-message.bot { background: #3a3a3a; color: #ddd; }
    .grok-chatbot-input { background: #1e1e1e; border-top-color: #333; }
    .grok-chatbot-input input { background: #2a2a2a; border-color: #444; color: #ddd; }
}