/* Grok Chatbot v2 – Dark (default) + Light themes */

:root, .theme-dark {
    --grok-primary: #1a1a2e;
    --grok-accent: #00d4ff;
    --grok-bg: #0f0f1a;
    --grok-surface: #1e1e32;
    --grok-text: #e8e8f0;
    --grok-text-muted: #a0a0b8;
    --grok-user-bg: rgba(0, 212, 255, 0.15);
    --grok-bot-bg: #2a2a45;
    --grok-border: rgba(255, 255, 255, 0.08);
    --grok-radius: 16px;
    --grok-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

/* Floating button */
.grok-chat-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--grok-accent);
    color: #0a0a12;
    border: none;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0, 212, 255, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.grok-chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 28px rgba(0, 212, 255, 0.55);
}

.grok-chat-toggle .grok-icon-close { display: none; }

.grok-chatbot-floating.open .grok-chat-toggle .grok-icon-chat { display: none; }
.grok-chatbot-floating.open .grok-chat-toggle .grok-icon-close { display: block; }

/* Chat window */
.grok-chat-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 390px;
    max-width: calc(100vw - 32px);
    height: 580px;
    max-height: calc(100vh - 140px);
    background: var(--grok-bg);
    border-radius: var(--grok-radius);
    box-shadow: var(--grok-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 99998;
    border: 1px solid var(--grok-border);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Shortcode version */
.grok-chatbot-shortcode {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.grok-chatbot-shortcode .grok-chat-window {
    position: relative;
    bottom: auto;
    right: auto;
    width: 100%;
    height: 100%;
    max-height: none;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

/* Header */
.grok-chat-header {
    background: var(--grok-primary);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--grok-border);
    flex-shrink: 0;
}

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

.grok-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--grok-accent), #7b2cbf);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    color: #fff;
    flex-shrink: 0;
}

.grok-bot-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--grok-text);
}

.grok-bot-status {
    font-size: 12px;
    color: #4ade80;
}

.grok-chat-minimize {
    background: transparent;
    border: none;
    color: var(--grok-text-muted);
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
}
.grok-chat-minimize:hover { color: var(--grok-text); }

/* Messages */
.grok-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--grok-bg);
}

.grok-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.55;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.grok-message.user {
    align-self: flex-end;
    background: var(--grok-user-bg);
    color: var(--grok-text);
    border-bottom-right-radius: 4px;
}

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

.grok-message.error {
    align-self: center;
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    font-size: 13px;
    text-align: center;
    max-width: 95%;
}

/* Streaming cursor */
.grok-message.bot.streaming::after {
    content: '▍
    animation: grok-blink 0.8s step-end infinite;
    margin-left: 2px;
    color: var(--grok-accent);
}

@keyframes grok-blink {
    50% { opacity: 0; }
}

/* Typing indicator */
.grok-typing {
    align-self: flex-start;
    background: var(--grok-bot-bg);
    padding: 12px 18px;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}

.grok-typing span {
    display: inline-block;
    width: 7px;
    height: 7px;
    background: var(--grok-accent);
    border-radius: 50%;
    margin: 0 2px;
    animation: grok-bounce 1.2s infinite ease-in-out;
}
.grok-typing span:nth-child(2) { animation-delay: 0.15s; }
.grok-typing span:nth-child(3) { animation-delay: 0.3s; }

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

/* Input area */
.grok-chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 14px;
    background: var(--grok-surface);
    border-top: 1px solid var(--grok-border);
    flex-shrink: 0;
}

.grok-chat-input {
    flex: 1;
    background: var(--grok-bg);
    border: 1px solid var(--grok-border);
    border-radius: 12px;
    padding: 10px 14px;
    color: var(--grok-text);
    font-size: 14px;
    resize: none;
    max-height: 120px;
    outline: none;
    font-family: inherit;
    line-height: 1.4;
}

.grok-chat-input:focus {
    border-color: var(--grok-accent);
}

.grok-chat-input::placeholder {
    color: var(--grok-text-muted);
}

.grok-chat-send {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--grok-accent);
    color: #0a0a12;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.2s, transform 0.15s;
}

.grok-chat-send:hover {
    opacity: 0.9;
    transform: scale(1.05);
}

.grok-chat-send:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

/* Scrollbar */
.grok-chat-messages::-webkit-scrollbar { width: 6px; }
.grok-chat-messages::-webkit-scrollbar-track { background: transparent; }
.grok-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(128, 128, 128, 0.3);
    border-radius: 3px;
}

/* Mobile */
@media (max-width: 480px) {
    .grok-chat-window {
        bottom: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    .grok-chat-toggle {
        bottom: 16px;
        right: 16px;
    }
    .grok-chatbot-floating.open .grok-chat-toggle {
        display: none;
    }
}
