/* ─── Groq AI Chatbot Widget ─────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&display=swap');

/* ── CSS Variables ──────────────────────────────────────────────── */
#groq-chatbot-wrapper {
    --groq-font: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --groq-radius-window: 20px;
    --groq-radius-bubble: 18px;
    --groq-shadow-window: 0 24px 64px rgba(0,0,0,.18), 0 4px 16px rgba(0,0,0,.08);
    --groq-shadow-btn: 0 6px 24px rgba(0,0,0,.28);
    --groq-bg-messages: #f4f6f8;
    --groq-bg-window: #ffffff;
    --groq-bubble-bot-bg: #ffffff;
    --groq-bubble-bot-color: #1a1a2e;
    --groq-text-meta: #a0a7b5;
    --groq-border: rgba(0,0,0,.07);
    --groq-transition: .22s cubic-bezier(.4,0,.2,1);

    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 2147483647;
    font-family: var(--groq-font) !important;
}

/* ── Reset all child elements ───────────────────────────────────── */
#groq-chatbot-wrapper * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ══════════════════════════════════════════════════════════════════
   TOGGLE BUTTON  (div — immune to theme button overrides)
══════════════════════════════════════════════════════════════════ */
#groq-chatbot-wrapper #groq-chat-toggle {
    /* Hard-lock the shape — nothing can override a div */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 68px !important;
    height: 68px !important;
    min-width: 68px !important;
    min-height: 68px !important;
    max-width: 68px !important;
    max-height: 68px !important;
    aspect-ratio: 1 / 1 !important;
    border-radius: 50% !important;
    padding: 7px !important;
    cursor: pointer !important;
    box-shadow: 0 6px 22px rgba(0,0,0,.30), 0 2px 6px rgba(0,0,0,.15) !important;
    transition: transform var(--groq-transition), box-shadow var(--groq-transition) !important;
    outline: none !important;
    overflow: hidden !important;
    position: relative !important;
    /* Prevent float/block weirdness */
    float: none !important;
    flex-shrink: 0 !important;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}



#groq-chatbot-wrapper #groq-chat-toggle:hover {
    transform: scale(1.1) !important;
    box-shadow: 0 10px 30px rgba(0,0,0,.35) !important;
}
#groq-chatbot-wrapper #groq-chat-toggle:active {
    transform: scale(.93) !important;
}

/* Robot icon */
#groq-chatbot-wrapper #groq-chat-toggle #groq-icon-open {
    width: 54px !important;
    height: 54px !important;
    display: block !important;
    position: relative !important;
    z-index: 1 !important;
    flex-shrink: 0 !important;
}

/* Close X */
#groq-chatbot-wrapper #groq-chat-toggle #groq-icon-close {
    width: 24px !important;
    height: 24px !important;
    flex-shrink: 0 !important;
    position: relative !important;
    z-index: 1 !important;
    transition: transform var(--groq-transition) !important;
}
#groq-chatbot-wrapper #groq-chat-toggle:hover #groq-icon-close {
    transform: rotate(90deg) !important;
}

/* ══════════════════════════════════════════════════════════════════
   CHAT WINDOW
══════════════════════════════════════════════════════════════════ */
#groq-chat-window {
    position: absolute;
    bottom: 88px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    background: var(--groq-bg-window);
    border-radius: var(--groq-radius-window);
    box-shadow: var(--groq-shadow-window);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: groq-pop-in .3s cubic-bezier(.34,1.56,.64,1) both;
    border: 1px solid var(--groq-border);
}

@keyframes groq-pop-in {
    from { opacity: 0; transform: translateY(16px) scale(.96); }
    to   { opacity: 1; transform: translateY(0)    scale(1);   }
}

/* ══════════════════════════════════════════════════════════════════
   HEADER
══════════════════════════════════════════════════════════════════ */
#groq-chat-header {
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

/* Glossy overlay on header */
#groq-chat-header::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 50%;
    background: linear-gradient(rgba(255,255,255,.18), transparent);
    pointer-events: none;
}

#groq-header-left {
    display: flex;
    align-items: center;
    gap: 11px;
    position: relative;
    z-index: 1;
}

#groq-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: rgba(255,255,255,.22);
    backdrop-filter: blur(4px);
    border: 1.5px solid rgba(255,255,255,.35);
    box-shadow: 0 2px 8px rgba(0,0,0,.12);
}

#groq-avatar svg {
    width: 19px;
    height: 19px;
}

#groq-bot-name {
    color: #fff;
    font-weight: 600;
    font-size: 15px;
    line-height: 1.25;
    letter-spacing: -.01em;
    text-shadow: 0 1px 3px rgba(0,0,0,.15);
}

#groq-bot-status {
    color: rgba(255,255,255,.82);
    font-size: 11.5px;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
    font-weight: 400;
}

.groq-status-dot {
    width: 7px;
    height: 7px;
    background: #6ee7b7;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 0 2px rgba(110,231,183,.3);
    animation: groq-pulse 2.4s ease-in-out infinite;
}

@keyframes groq-pulse {
    0%, 100% { box-shadow: 0 0 0 2px rgba(110,231,183,.3); }
    50%       { box-shadow: 0 0 0 5px rgba(110,231,183,.1); }
}

#groq-header-close {
    background: rgba(255,255,255,.18) !important;
    border: none !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    width: 32px !important;
    height: 32px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    transition: background var(--groq-transition), transform var(--groq-transition) !important;
    flex-shrink: 0 !important;
    position: relative;
    z-index: 1;
}
#groq-header-close:hover {
    background: rgba(255,255,255,.3) !important;
    transform: rotate(90deg) !important;
}
#groq-header-close svg {
    width: 16px !important;
    height: 16px !important;
}

/* ══════════════════════════════════════════════════════════════════
   MESSAGES AREA
══════════════════════════════════════════════════════════════════ */
#groq-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px;
    max-height: 380px;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    background: var(--groq-bg-messages);
}

#groq-chat-messages::-webkit-scrollbar { width: 4px; }
#groq-chat-messages::-webkit-scrollbar-track { background: transparent; }
#groq-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,.12);
    border-radius: 2px;
}

/* ── Message bubbles ──────────────────────────── */
.groq-msg {
    max-width: 85%;
    line-height: 1.55;
    font-size: 14px;
    word-break: break-word;
    animation: groq-msg-in .2s cubic-bezier(.34,1.3,.64,1) both;
}

@keyframes groq-msg-in {
    from { opacity: 0; transform: translateY(8px) scale(.97); }
    to   { opacity: 1; transform: none; }
}

.groq-msg.bot  { align-self: flex-start; }
.groq-msg.user { align-self: flex-end; }

.groq-bubble {
    padding: 11px 15px;
    border-radius: var(--groq-radius-bubble);
    display: inline-block;
    width: 100%;
    font-family: var(--groq-font);
}

/* Bot bubble */
.groq-msg.bot .groq-bubble {
    background: var(--groq-bubble-bot-bg);
    color: var(--groq-bubble-bot-color);
    border-radius: 4px 18px 18px 18px;
    box-shadow: 0 2px 10px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
    border: 1px solid rgba(0,0,0,.05);
}

/* User bubble */
.groq-msg.user .groq-bubble {
    color: #fff;
    border-radius: 18px 4px 18px 18px;
    /* colour injected inline via JS, add a subtle inner glow */
    box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 2px 10px rgba(0,0,0,.15);
}

.groq-msg-meta {
    font-size: 10px;
    color: var(--groq-text-meta);
    margin-top: 5px;
    padding: 0 4px;
    font-family: var(--groq-font);
    letter-spacing: .01em;
}
.groq-msg.user .groq-msg-meta { text-align: right; }

/* Error bubble */
.groq-error-bubble {
    background: #fff5f5 !important;
    color: #c0392b !important;
    border: 1px solid #ffc9c9 !important;
    border-radius: 10px !important;
    box-shadow: none !important;
}

/* ══════════════════════════════════════════════════════════════════
   TYPING INDICATOR
══════════════════════════════════════════════════════════════════ */
#groq-typing {
    padding: 10px 16px;
    background: var(--groq-bg-messages);
}

#groq-typing-inner {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #fff;
    padding: 10px 15px;
    border-radius: 4px 18px 18px 18px;
    box-shadow: 0 2px 10px rgba(0,0,0,.07);
    border: 1px solid rgba(0,0,0,.05);
}

.groq-typing-dots span {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #c5cad4;
    animation: groq-dot-bounce .9s ease-in-out infinite;
}
.groq-typing-dots span:nth-child(2) { animation-delay: .16s; }
.groq-typing-dots span:nth-child(3) { animation-delay: .32s; }

@keyframes groq-dot-bounce {
    0%, 80%, 100% { transform: translateY(0); background: #c5cad4; }
    40%           { transform: translateY(-6px); background: #a0a7b5; }
}

/* ══════════════════════════════════════════════════════════════════
   INPUT AREA
══════════════════════════════════════════════════════════════════ */
#groq-chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px 14px;
    background: #fff;
    border-top: 1px solid rgba(0,0,0,.06);
}

#groq-chat-input {
    flex: 1 !important;
    border: 1.5px solid #e8eaf0 !important;
    border-radius: 14px !important;
    padding: 10px 14px !important;
    font-size: 14px !important;
    resize: none !important;
    outline: none !important;
    line-height: 1.45 !important;
    max-height: 120px !important;
    overflow-y: auto !important;
    transition: border-color var(--groq-transition), box-shadow var(--groq-transition) !important;
    font-family: var(--groq-font) !important;
    background: #f9fafb !important;
    color: #1a1a2e !important;
    box-shadow: none !important;
}
#groq-chat-input:focus {
    border-color: rgba(0,0,0,.25) !important;
    background: #fff !important;
    box-shadow: 0 0 0 3px rgba(0,0,0,.05) !important;
}
#groq-chat-input::placeholder { color: #b0b7c3 !important; }

/* Send button — div, immune to theme button overrides */
#groq-chatbot-wrapper #groq-send-btn {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    max-width: 44px !important;
    max-height: 44px !important;
    aspect-ratio: 1 / 1 !important;
    border-radius: 50% !important;
    border: none !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
    line-height: 1 !important;
    box-shadow: 0 3px 12px rgba(0,0,0,.22) !important;
    outline: none !important;
    transition: transform var(--groq-transition), box-shadow var(--groq-transition) !important;
    position: relative !important;
    overflow: hidden !important;
    float: none !important;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
#groq-chatbot-wrapper #groq-send-btn svg {
    width: 18px !important;
    height: 18px !important;
    flex-shrink: 0 !important;
}
#groq-chatbot-wrapper #groq-send-btn:hover {
    transform: scale(1.1) !important;
    box-shadow: 0 5px 18px rgba(0,0,0,.28) !important;
}
#groq-chatbot-wrapper #groq-send-btn:active {
    transform: scale(.93) !important;
}
#groq-chatbot-wrapper #groq-send-btn.groq-disabled {
    opacity: .45 !important;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
    pointer-events: none !important;
}

/* ══════════════════════════════════════════════════════════════════
   FOOTER
══════════════════════════════════════════════════════════════════ */
#groq-chat-footer {
    text-align: center;
    font-size: 10.5px;
    color: #b8beca;
    padding: 7px 12px 8px;
    background: #fff;
    border-top: 1px solid rgba(0,0,0,.04);
    letter-spacing: .02em;
    font-family: var(--groq-font);
}
#groq-chat-footer strong { color: #8a90a0; font-weight: 600; }

/* ══════════════════════════════════════════════════════════════════
   MARKDOWN IN BOT MESSAGES
══════════════════════════════════════════════════════════════════ */
.groq-bubble strong { font-weight: 600; }
.groq-bubble em     { font-style: italic; }
.groq-bubble code {
    background: #f0f2f5;
    padding: 1px 6px;
    border-radius: 5px;
    font-family: 'SFMono-Regular', 'Consolas', monospace;
    font-size: 12.5px;
    color: #374151;
}
.groq-bubble pre {
    background: #1e2130;
    color: #e2e8f0;
    padding: 12px 14px;
    border-radius: 10px;
    overflow-x: auto;
    font-size: 12px;
    margin: 8px 0 0;
    line-height: 1.6;
}
.groq-bubble ul, .groq-bubble ol {
    padding-left: 18px;
    margin: 6px 0;
}
.groq-bubble li { margin: 3px 0; }
.groq-bubble p  { margin: 0 0 7px; }
.groq-bubble p:last-child { margin-bottom: 0; }

/* ══════════════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    #groq-chatbot-wrapper {
        bottom: 20px;
        right: 20px;
    }
    /* Make button BIGGER on mobile for easier tapping */
    #groq-chatbot-wrapper #groq-chat-toggle {
        width: 72px !important;
        height: 72px !important;
        min-width: 72px !important;
        min-height: 72px !important;
        max-width: 72px !important;
        max-height: 72px !important;
        aspect-ratio: 1 / 1 !important;
        padding: 9px !important;
        box-shadow: 0 8px 28px rgba(0,0,0,.35), 0 3px 8px rgba(0,0,0,.18) !important;
    }
    #groq-chatbot-wrapper #groq-chat-toggle #groq-icon-open {
        width: 64px !important;
        height: 64px !important;
    }
    #groq-chat-window {
        width: calc(100vw - 32px);
        bottom: 92px;
        right: 0;
        border-radius: 16px;
    }
    #groq-chat-messages { max-height: 46vh; }
}

@media (max-width: 380px) {
    #groq-chatbot-wrapper {
        bottom: 16px;
        right: 16px;
    }
    #groq-chatbot-wrapper #groq-chat-toggle {
        width: 68px !important;
        height: 68px !important;
        min-width: 68px !important;
        min-height: 68px !important;
    }
    #groq-chat-window {
        width: calc(100vw - 28px);
    }
    #groq-chat-messages { max-height: 42vh; }
}
