:root {
    --groq-blue: #1C39BB;
    --groq-blue-light: #3d56d4;
    --groq-blue-glow: rgba(28, 57, 187, 0.35);
    --groq-black: #050505;
    --groq-surface: #0f0f12;
    --groq-border: rgba(255, 255, 255, 0.08);
    --groq-text: #f4f4f5;
    --groq-muted: #a1a1aa;
}

.groq-chat-shell,
.groq-chat-shell *,
.groq-chat-shell *::before,
.groq-chat-shell *::after {
    box-sizing: border-box;
}

#groq-chatbot-widget {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 999999;
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
    direction: rtl;
    text-align: right;
    line-height: 1.5;
}

#groq-chatbot-widget button,
#groq-chatbot-widget textarea {
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
}

#groq-chat-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 50%;
    background: var(--groq-blue);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 8px 24px var(--groq-blue-glow);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

#groq-chat-toggle:hover {
    transform: scale(1.05);
    background: var(--groq-blue-light);
    box-shadow: 0 10px 28px rgba(28, 57, 187, 0.5);
}

#groq-chat-toggle:focus-visible {
    outline: 2px solid rgba(61, 86, 212, 0.8);
    outline-offset: 2px;
}

#groq-chat-panel {
    position: absolute;
    bottom: calc(100% + 12px);
    left: 0;
    display: flex;
    flex-direction: column;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: min(520px, calc(100vh - 120px));
    max-height: calc(100vh - 120px);
    background: var(--groq-surface);
    border: 1px solid var(--groq-border);
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
    overflow: hidden;
}

#groq-chat-panel.groq-chat-closed {
    display: none !important;
}

#groq-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-shrink: 0;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--groq-blue), #152d94);
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.04em;
    text-transform: lowercase;
}

#groq-chat-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease;
}

#groq-chat-close:hover {
    background: rgba(255, 255, 255, 0.15);
}

.groq-chat-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--groq-black);
    -webkit-overflow-scrolling: touch;
}

.groq-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.groq-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 999px;
}

.groq-msg {
    max-width: 88%;
    padding: 11px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.75;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.groq-msg.user {
    align-self: flex-start;
    background: var(--groq-blue);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.groq-msg.bot {
    align-self: flex-end;
    background: rgba(255, 255, 255, 0.04);
    color: var(--groq-text);
    border: 1px solid var(--groq-border);
    border-bottom-left-radius: 4px;
}

.groq-msg.loading {
    align-self: flex-end;
    background: rgba(28, 57, 187, 0.12);
    color: var(--groq-muted);
    font-style: italic;
    border: 1px dashed rgba(28, 57, 187, 0.35);
}

.groq-chat-form {
    flex-shrink: 0;
    margin: 0;
}

.groq-chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--groq-border);
    background: var(--groq-surface);
}

#groq-chat-input,
.groq-chat-input-area textarea {
    flex: 1 1 auto;
    min-width: 0;
    max-height: 120px;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--groq-text);
    resize: none;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#groq-chat-input:focus,
.groq-chat-input-area textarea:focus {
    border-color: var(--groq-blue);
    box-shadow: 0 0 0 3px var(--groq-blue-glow);
}

#groq-chat-input:disabled,
.groq-chat-input-area textarea:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#groq-chat-input::placeholder,
.groq-chat-input-area textarea::placeholder {
    color: var(--groq-muted);
}

.groq-chat-send,
#groq-chat-send {
    flex-shrink: 0;
    padding: 10px 16px;
    border: none;
    border-radius: 12px;
    background: var(--groq-blue);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, opacity 0.15s ease;
}

.groq-chat-send:hover:not(:disabled),
#groq-chat-send:hover:not(:disabled) {
    background: var(--groq-blue-light);
}

.groq-chat-send:disabled,
#groq-chat-send:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.groq-chat-send:focus-visible,
#groq-chat-send:focus-visible {
    outline: 2px solid rgba(61, 86, 212, 0.8);
    outline-offset: 2px;
}

.groq-chat-notice {
    padding: 16px;
    border: 1px solid var(--groq-border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--groq-muted);
    text-align: center;
}

@media (max-width: 480px) {
    #groq-chatbot-widget {
        bottom: 16px;
        left: 16px;
        right: 16px;
    }

    #groq-chat-panel {
        left: 0;
        right: 0;
        width: auto;
        max-width: none;
        height: min(460px, calc(100vh - 100px));
    }

    #groq-chat-toggle {
        width: 52px;
        height: 52px;
    }
}
