:root {
    --ai-bg: #ffffff;
    --ai-bottom-offset: 20px;
    --ai-right-offset: 20px;
    --ai-toggle-size: 56px;
    --ai-surface: rgba(255, 255, 255, 0.92);
    --ai-border: rgba(15, 23, 42, 0.12);
    --ai-shadow: 0 24px 64px rgba(15, 23, 42, 0.16);
    --ai-primary: #1045b9;
    --ai-primary-strong: #054496;
    --ai-secondary: #0f172a;
    --ai-text: #111827;
    --ai-muted: #6b7280;
    --ai-user: #f0fdf4;
    --ai-assistant: #eef2ff;
    --ai-danger: #ef4444;
}

/* DARK MODE */
@media (prefers-color-scheme: dark) {
    :root {
        --ai-bg: #0f172a;
        --ai-surface: rgba(15, 23, 42, 0.95);
        --ai-border: rgba(148, 163, 184, 0.18);
        --ai-shadow: 0 24px 64px rgba(15, 23, 42, 0.4);
        --ai-primary: #34d399;
        --ai-primary-strong: #22c55e;
        --ai-secondary: #f8fafc;
        --ai-text: #f8fafc;
        --ai-muted: #94a3b8;
        --ai-user: #1e293b;
        --ai-assistant: #111827;
    }
}

/* WIDGET CONTAINER */
.ai-support-widget {
    position: fixed;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    right: 20px;
    z-index: 99999;

    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.75rem;

    font-family: 'Inter', sans-serif;

    pointer-events: auto;
}

/* TOGGLE BUTTON */
.ai-support-toggle {
    pointer-events: auto;
    width: var(--ai-toggle-size);
    height: var(--ai-toggle-size);

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;
    border: none;

    background: linear-gradient(135deg, var(--ai-primary), var(--ai-primary-strong));
    color: white;

    cursor: pointer;

    box-shadow: 0 18px 40px rgba(0,0,0,0.18);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ai-support-toggle:hover {
    transform: translateY(-3px);
}

/* PANEL */
.ai-support-panel {
    position: absolute;
    right: 0;
    bottom: calc(var(--ai-toggle-size) + 12px);

    width: min(420px, calc(100vw - 1.5rem));
    max-height: 580px;

    border-radius: 20px;

    background: var(--ai-surface);
    backdrop-filter: blur(14px);

    border: 1px solid var(--ai-border);
    box-shadow: var(--ai-shadow);

    transform: translateY(10px) scale(0.98);
    opacity: 0;
    pointer-events: none;

    transition: 0.25s ease;

    overflow: hidden;
}

.ai-support-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* HEADER */
.ai-support-header {
    display: flex;
    justify-content: space-between;
    align-items: center;

    padding: 1rem 1.2rem;

    border-bottom: 1px solid rgba(0,0,0,0.08);
}

.ai-support-title {
    font-weight: 800;
}

.ai-support-subtitle {
    font-size: 0.85rem;
    color: var(--ai-muted);
}

/* CLOSE */
.ai-support-close {
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    background: rgba(0,0,0,0.06);
}

/* BODY */
.ai-support-body {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    gap: 0.8rem;
}

/* MESSAGES */
.ai-support-messages {
    overflow-y: auto;
    max-height: 320px;

    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.ai-support-message {
    max-width: 85%;
    padding: 0.9rem 1rem;
    border-radius: 18px;
    word-break: break-word;
}

.ai-support-message.user {
    align-self: flex-end;
    background: var(--ai-user);
}

.ai-support-message.assistant {
    align-self: flex-start;
    background: var(--ai-assistant);
}

/* INPUT */
.ai-support-input-group {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.6rem;
}

.ai-support-input {
    border: 1px solid rgba(0,0,0,0.15);
    border-radius: 14px;
    padding: 0.9rem;
    outline: none;
}

.ai-support-input:focus {
    border-color: var(--ai-primary);
}

/* SEND */
.ai-support-send {
    border: none;
    border-radius: 14px;
    width: 54px;

    background: linear-gradient(135deg, var(--ai-primary), var(--ai-primary-strong));
    color: white;

    cursor: pointer;
}

/* QUICK QUESTIONS */
.ai-support-quick-questions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
}

.quick-question {
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 999px;
    padding: 0.6rem;
    font-size: 0.8rem;
    cursor: pointer;
}

/* MOBILE FIX */
@media (max-width: 640px) {
    .ai-support-widget {
        left: 0.85rem;
        right: 0.85rem;
        bottom: 0.85rem;
        align-items: center;
    }

    .ai-support-panel {
        width: 100%;
        border-radius: 20px;
    }

    .ai-support-quick-questions {
        grid-template-columns: 1fr;
    }
}