:root {
    --spx-primary: #7F4BE3;
    --spx-accent:  #F5A623;
    --spx-dark:    #1E0A3C;
    --spx-white:   #ffffff;
    --spx-muted:   #b8a9d4;
    --spx-border:  rgba(255, 255, 255, 0.10);
    --spx-card:    rgba(18, 6, 40, 0.97);
    --spx-shadow:  0 28px 80px rgba(0, 0, 0, 0.60);
}

.spx-chatbot-wrapper,
.spx-chatbot-wrapper * {
    box-sizing: border-box;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ─────────────────────────────────────────
   FLOATING TOGGLE BUTTON
───────────────────────────────────────── */
.spx-chatbot-wrapper {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 999999;
}

.spx-chatbot-toggle {
    position: relative;
    width: 62px;
    height: 62px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    color: var(--spx-white);
    background: linear-gradient(145deg, #9B6EF0, var(--spx-primary), #5B21B6);
    box-shadow: 0 12px 40px rgba(127, 75, 227, 0.50), 0 0 0 1px rgba(255,255,255,0.10) inset;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.spx-chatbot-toggle:hover {
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 18px 55px rgba(127, 75, 227, 0.60);
}

.spx-toggle-glow {
    position: absolute;
    inset: -10px;
    border-radius: 28px;
    background: linear-gradient(135deg, var(--spx-primary), #9B6EF0);
    opacity: 0.20;
    filter: blur(16px);
    animation: spxPulse 2.4s ease-in-out infinite;
    pointer-events: none;
}

.spx-toggle-icon {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

/* ─────────────────────────────────────────
   PANEL
───────────────────────────────────────── */
.spx-chatbot-panel {
    position: absolute;
    right: 0;
    bottom: 78px;
    width: min(390px, calc(100vw - 28px));
    height: min(620px, calc(100vh - 120px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 26px;
    color: var(--spx-white);
    background: var(--spx-card);
    border: 1px solid rgba(127, 75, 227, 0.25);
    box-shadow: var(--spx-shadow);
    backdrop-filter: blur(24px);
    opacity: 0;
    transform: translateY(16px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.spx-open .spx-chatbot-panel {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ─────────────────────────────────────────
   HEADER
───────────────────────────────────────── */
.spx-chatbot-header {
    flex-shrink: 0;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, rgba(127, 75, 227, 0.45) 0%, rgba(30, 10, 60, 0.60) 100%);
    border-bottom: 1px solid rgba(127, 75, 227, 0.22);
    min-height: 64px;
}

.spx-brand {
    display: flex;
    align-items: center;
    gap: 11px;
}

.spx-brand-mark {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 12px;
    letter-spacing: -0.02em;
    color: var(--spx-white);
    background: linear-gradient(135deg, var(--spx-primary), #5B21B6);
    box-shadow: 0 6px 20px rgba(127, 75, 227, 0.40);
}

.spx-brand-name {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--spx-white);
    line-height: 1.2;
}

.spx-brand-status {
    margin-top: 3px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--spx-muted);
}

.spx-brand-status span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #36ff9f;
    box-shadow: 0 0 0 3px rgba(54, 255, 159, 0.18);
}

/* Close button — perfectly centered */
.spx-close-btn {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border: 1px solid rgba(127, 75, 227, 0.35);
    border-radius: 10px;
    background: rgba(127, 75, 227, 0.18);
    color: var(--spx-white);
    font-size: 18px;
    font-weight: 400;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s, transform 0.2s;
}

.spx-close-btn:hover {
    background: rgba(127, 75, 227, 0.38);
    transform: rotate(8deg);
}

/* ─────────────────────────────────────────
   LANGUAGE BAR
───────────────────────────────────────── */
.spx-lang-bar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 14px;
    background: rgba(127, 75, 227, 0.08);
    border-bottom: 1px solid rgba(127, 75, 227, 0.15);
}

.spx-lang-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--spx-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-right: 2px;
}

.spx-lang-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 26px;
    min-width: 34px;
    padding: 0 8px;
    border: 1px solid rgba(127, 75, 227, 0.30);
    border-radius: 6px;
    background: rgba(127, 75, 227, 0.12);
    color: var(--spx-muted);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.18s, color 0.18s, border-color 0.18s;
    white-space: nowrap;
}

.spx-lang-btn:hover {
    background: rgba(127, 75, 227, 0.28);
    color: var(--spx-white);
    border-color: rgba(127, 75, 227, 0.55);
}

.spx-lang-btn.spx-lang-active {
    background: var(--spx-primary);
    color: var(--spx-white);
    border-color: var(--spx-primary);
    box-shadow: 0 3px 12px rgba(127, 75, 227, 0.38);
}

/* ─────────────────────────────────────────
   MESSAGES
───────────────────────────────────────── */
.spx-chatbot-messages {
    flex: 1;
    min-height: 0;
    padding: 16px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.spx-chatbot-messages::-webkit-scrollbar { width: 5px; }
.spx-chatbot-messages::-webkit-scrollbar-track { background: transparent; }
.spx-chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(127, 75, 227, 0.30);
    border-radius: 99px;
}

.spx-message {
    display: flex;
    gap: 9px;
    margin-bottom: 13px;
    animation: spxMessageIn 0.22s ease both;
}

.spx-message-user { flex-direction: row-reverse; }

.spx-avatar {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 800;
    color: var(--spx-white);
    background: rgba(127, 75, 227, 0.25);
    border: 1px solid rgba(127, 75, 227, 0.30);
}

.spx-message-user .spx-avatar {
    background: linear-gradient(135deg, var(--spx-accent), #d4880e);
    color: #1E0A3C;
    border-color: transparent;
}

.spx-bubble {
    max-width: 78%;
    padding: 11px 13px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.92);
    background: rgba(127, 75, 227, 0.14);
    border: 1px solid rgba(127, 75, 227, 0.20);
}

.spx-message-user .spx-bubble {
    background: linear-gradient(135deg, var(--spx-primary), #5B21B6);
    border-color: transparent;
    color: #fff;
}

/* Calendly CTA button inside bubble */
.spx-calendly-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 10px;
    padding: 9px 16px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--spx-accent), #d4880e);
    color: #1E0A3C !important;
    font-size: 13px;
    font-weight: 800;
    text-decoration: none !important;
    box-shadow: 0 6px 20px rgba(245, 166, 35, 0.35);
    transition: transform 0.2s, box-shadow 0.2s;
}

.spx-calendly-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(245, 166, 35, 0.48);
}

/* ─────────────────────────────────────────
   SUGGESTION CHIPS
───────────────────────────────────────── */
.spx-suggestions {
    flex-shrink: 0;
    display: flex;
    gap: 7px;
    padding: 0 14px 12px;
    overflow-x: auto;
}

.spx-suggestions::-webkit-scrollbar { display: none; }

.spx-suggestion-chip {
    flex-shrink: 0;
    height: 28px;
    padding: 0 12px;
    border: 1px solid rgba(127, 75, 227, 0.32);
    border-radius: 999px;
    background: rgba(127, 75, 227, 0.10);
    color: rgba(255, 255, 255, 0.85);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.18s, transform 0.18s;
}

.spx-suggestion-chip:hover {
    background: rgba(127, 75, 227, 0.28);
    transform: translateY(-1px);
}

/* ─────────────────────────────────────────
   INPUT FORM
───────────────────────────────────────── */
.spx-chatbot-form {
    flex-shrink: 0;
    padding: 12px 14px;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    border-top: 1px solid rgba(127, 75, 227, 0.18);
    background: rgba(10, 3, 25, 0.50);
}

.spx-chatbot-input {
    flex: 1;
    min-height: 44px;
    max-height: 110px;
    resize: none;
    border: 1px solid rgba(127, 75, 227, 0.30);
    border-radius: 14px;
    padding: 11px 13px;
    color: var(--spx-white);
    background: rgba(127, 75, 227, 0.10);
    outline: none;
    font-size: 13.5px;
    line-height: 1.45;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.spx-chatbot-input::placeholder { color: rgba(255,255,255,0.35); }

.spx-chatbot-input:focus {
    border-color: var(--spx-primary);
    box-shadow: 0 0 0 3px rgba(127, 75, 227, 0.18);
}

/* Voice button */
.spx-voice-btn {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border: 1px solid rgba(127, 75, 227, 0.32);
    border-radius: 14px;
    background: rgba(127, 75, 227, 0.12);
    color: var(--spx-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, box-shadow 0.2s;
    padding: 0;
}

.spx-voice-btn:hover {
    background: rgba(127, 75, 227, 0.28);
    color: var(--spx-white);
}

.spx-voice-btn.spx-recording {
    background: rgba(255, 60, 80, 0.22);
    border-color: rgba(255, 60, 80, 0.55);
    color: #ff4d5f;
    box-shadow: 0 0 0 4px rgba(255, 60, 80, 0.14);
    animation: spxRecordingPulse 1s ease-in-out infinite;
}

/* Send button */
.spx-send-btn {
    flex-shrink: 0;
    height: 44px;
    padding: 0 16px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--spx-primary), #5B21B6);
    color: var(--spx-white);
    font-size: 13.5px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    box-shadow: 0 6px 22px rgba(127, 75, 227, 0.38);
    transition: transform 0.2s, box-shadow 0.2s;
}

.spx-send-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 30px rgba(127, 75, 227, 0.50);
}

.spx-send-btn:disabled,
.spx-chatbot-input:disabled,
.spx-voice-btn:disabled {
    opacity: 0.50;
    cursor: not-allowed;
}

/* ─────────────────────────────────────────
   TYPING DOTS
───────────────────────────────────────── */
.spx-typing {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.spx-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(127, 75, 227, 0.80);
    animation: spxTyping 1s infinite ease-in-out;
}

.spx-typing span:nth-child(2) { animation-delay: 0.15s; }
.spx-typing span:nth-child(3) { animation-delay: 0.30s; }

/* ─────────────────────────────────────────
   KEYFRAMES
───────────────────────────────────────── */
@keyframes spxTyping {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
    40%           { transform: translateY(-5px); opacity: 1; }
}

@keyframes spxPulse {
    0%, 100% { opacity: 0.14; transform: scale(0.97); }
    50%      { opacity: 0.28; transform: scale(1.04); }
}

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

@keyframes spxRecordingPulse {
    0%, 100% { box-shadow: 0 0 0 4px rgba(255,60,80,0.14); }
    50%      { box-shadow: 0 0 0 8px rgba(255,60,80,0.06); }
}

/* ─────────────────────────────────────────
   MOBILE
───────────────────────────────────────── */
@media (max-width: 520px) {
    .spx-chatbot-wrapper { right: 14px; bottom: 14px; }

    .spx-chatbot-panel {
        width: calc(100vw - 28px);
        height: min(640px, calc(100vh - 100px));
        right: 0;
        bottom: 76px;
        border-radius: 22px;
    }

    .spx-bubble { max-width: 85%; }
    .spx-send-btn span { display: none; }
    .spx-send-btn { padding: 0 14px; }
}
