/* ==========================================================================
   RESULT STUDIO - Chatbot Widget
   All styles scoped under .rs-chatbot to avoid conflicts
   ========================================================================== */

/* --- Toggle Button --- */
.rs-chatbot-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 960;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--color-accent, #7400ce);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(116, 0, 206, 0.4);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.rs-chatbot-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(116, 0, 206, 0.55);
}

.rs-chatbot-toggle svg {
    width: 26px;
    height: 26px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.rs-chatbot-toggle.rs-chatbot-open svg {
    transform: rotate(90deg) scale(0.85);
}

/* Notification dot */
.rs-chatbot-dot {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    background: var(--color-success, #22c55e);
    border-radius: 50%;
    border: 2px solid var(--color-bg, #0a0a14);
    animation: rs-chatbot-pulse 2s ease-in-out infinite;
}

.rs-chatbot-toggle.rs-chatbot-open .rs-chatbot-dot,
.rs-chatbot-dot.rs-chatbot-hidden {
    display: none;
}

@keyframes rs-chatbot-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.7; }
}

/* Entrance animation for the button */
.rs-chatbot-toggle.rs-chatbot-entrance {
    animation: rs-chatbot-bounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes rs-chatbot-bounce {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* --- Chat Window --- */
.rs-chatbot-window {
    position: fixed;
    bottom: 92px;
    right: 24px;
    z-index: 961;
    width: 380px;
    max-height: 520px;
    background: var(--color-bg-card, #16162a);
    border: 1px solid var(--color-border, rgba(255, 255, 255, 0.08));
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.rs-chatbot-window.rs-chatbot-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* --- Chat Header --- */
.rs-chatbot-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--color-accent, #7400ce);
    color: #fff;
    flex-shrink: 0;
}

.rs-chatbot-header-avatar {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.rs-chatbot-header-avatar svg {
    width: 18px;
    height: 18px;
}

.rs-chatbot-avatar-initials {
    font-family: var(--font-heading, 'Space Grotesk', sans-serif);
    font-weight: 700;
    font-size: 0.8rem;
    line-height: 1;
    letter-spacing: 0.02em;
}

.rs-chatbot-status-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    background: #22c55e;
    border-radius: 50%;
    margin-right: 2px;
    vertical-align: middle;
    position: relative;
    top: -1px;
}

.rs-chatbot-header-info {
    flex: 1;
    min-width: 0;
}

.rs-chatbot-header-name {
    font-family: var(--font-heading, 'Space Grotesk', sans-serif);
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.2;
}

.rs-chatbot-header-status {
    font-size: 0.75rem;
    opacity: 0.85;
    line-height: 1.2;
}

.rs-chatbot-close {
    width: 30px;
    height: 30px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.rs-chatbot-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.rs-chatbot-close svg {
    width: 14px;
    height: 14px;
}

/* --- Messages Area --- */
.rs-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 200px;
    max-height: 340px;
    scroll-behavior: smooth;
}

/* Scrollbar styling */
.rs-chatbot-messages::-webkit-scrollbar {
    width: 4px;
}

.rs-chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.rs-chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--color-border, rgba(255, 255, 255, 0.08));
    border-radius: 4px;
}

/* --- Message Bubbles --- */
.rs-chatbot-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-family: var(--font-body, 'DM Sans', sans-serif);
    font-size: 0.9rem;
    line-height: 1.5;
    animation: rs-chatbot-msgIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    opacity: 0;
}

@keyframes rs-chatbot-msgIn {
    0% { opacity: 0; transform: translateY(8px); }
    100% { opacity: 1; transform: translateY(0); }
}

.rs-chatbot-msg-bot {
    align-self: flex-start;
    background: var(--color-surface, #1a1a2e);
    color: var(--color-text, #e4e4f0);
    border-bottom-left-radius: 4px;
}

.rs-chatbot-msg-user {
    align-self: flex-end;
    background: var(--color-accent, #7400ce);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* --- Typing Indicator --- */
.rs-chatbot-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 12px 18px;
    background: var(--color-surface, #1a1a2e);
    border-radius: 12px;
    border-bottom-left-radius: 4px;
}

.rs-chatbot-typing-dot {
    width: 7px;
    height: 7px;
    background: var(--color-text-muted, #9595b0);
    border-radius: 50%;
    animation: rs-chatbot-typingBounce 1.4s ease-in-out infinite;
}

.rs-chatbot-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.rs-chatbot-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes rs-chatbot-typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* --- Quick Reply Buttons --- */
.rs-chatbot-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0;
    animation: rs-chatbot-msgIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    opacity: 0;
    animation-delay: 0.1s;
}

.rs-chatbot-quick-btn {
    padding: 8px 16px;
    border: 1px solid var(--color-accent, #7400ce);
    border-radius: 20px;
    background: transparent;
    color: var(--color-accent-light, #9333ea);
    font-family: var(--font-body, 'DM Sans', sans-serif);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.15s;
    white-space: nowrap;
}

.rs-chatbot-quick-btn:hover {
    background: var(--color-accent, #7400ce);
    color: #fff;
    transform: translateY(-1px);
}

.rs-chatbot-quick-btn:active {
    transform: translateY(0);
}

/* --- Input Area --- */
.rs-chatbot-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--color-border, rgba(255, 255, 255, 0.08));
    flex-shrink: 0;
    background: var(--color-bg-card, #16162a);
}

.rs-chatbot-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.rs-chatbot-input {
    flex: 1;
    padding: 10px 14px;
    background: var(--color-bg, #0a0a14);
    border: 1px solid var(--color-border, rgba(255, 255, 255, 0.08));
    border-radius: 8px;
    color: var(--color-text, #e4e4f0);
    font-family: var(--font-body, 'DM Sans', sans-serif);
    font-size: 1rem;
    transition: border-color 0.2s;
    outline: none;
}

.rs-chatbot-input::placeholder {
    color: var(--color-text-muted, #9595b0);
}

.rs-chatbot-input:focus {
    border-color: var(--color-accent, #7400ce);
}

.rs-chatbot-input.rs-chatbot-error {
    border-color: var(--color-error, #ef4444);
}

.rs-chatbot-send-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--color-accent, #7400ce);
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.15s;
    flex-shrink: 0;
}

.rs-chatbot-send-btn:hover {
    background: var(--color-accent-light, #9333ea);
    transform: translateY(-1px);
}

.rs-chatbot-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.rs-chatbot-send-btn svg {
    width: 18px;
    height: 18px;
}

/* --- Contact Form (phone + email step) --- */
.rs-chatbot-contact-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rs-chatbot-contact-form .rs-chatbot-input {
    width: 100%;
}

.rs-chatbot-submit-btn {
    width: 100%;
    padding: 10px 16px;
    background: var(--color-accent, #7400ce);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-family: var(--font-heading, 'Space Grotesk', sans-serif);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    margin-top: 4px;
}

.rs-chatbot-submit-btn:hover {
    background: var(--color-accent-light, #9333ea);
    transform: translateY(-1px);
}

.rs-chatbot-submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* --- Trade Select Dropdown --- */
.rs-chatbot-select {
    width: 100%;
    padding: 10px 14px;
    background: var(--color-bg, #0a0a14);
    border: 1px solid var(--color-border, rgba(255, 255, 255, 0.08));
    border-radius: 8px;
    color: var(--color-text, #e4e4f0);
    font-family: var(--font-body, 'DM Sans', sans-serif);
    font-size: 1rem;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%239595b0' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

.rs-chatbot-select:focus {
    border-color: var(--color-accent, #7400ce);
}

.rs-chatbot-select option {
    background: var(--color-bg, #0a0a14);
    color: var(--color-text, #e4e4f0);
}

/* --- Error Message --- */
.rs-chatbot-error-msg {
    font-size: 0.78rem;
    color: var(--color-error, #ef4444);
    padding: 2px 0 0;
}

/* --- Success State --- */
.rs-chatbot-success-icon {
    width: 48px;
    height: 48px;
    margin: 8px auto 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(34, 197, 94, 0.15);
    border-radius: 50%;
    animation: rs-chatbot-msgIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    opacity: 0;
}

.rs-chatbot-success-icon svg {
    width: 24px;
    height: 24px;
    color: var(--color-success, #22c55e);
}

/* --- Mobile Responsive --- */
@media (max-width: 480px) {
    .rs-chatbot-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-height: calc(100vh - 60px);
        border-radius: 16px 16px 0 0;
        border-bottom: none;
    }

    .rs-chatbot-messages {
        max-height: none;
        flex: 1;
    }
}

/* Mobile: push toggle button above sticky CTA */
@media (max-width: 1023px) {
    .rs-chatbot-toggle {
        bottom: 90px;
    }

    .rs-chatbot-window {
        bottom: 158px;
    }
}

@media (max-width: 480px) and (max-width: 1023px) {
    .rs-chatbot-window {
        bottom: 0;
    }
}

/* --- No-Spam Reassurance --- */
.rs-chatbot-reassurance {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    color: var(--color-text-muted, #9595b0);
    padding: 4px 0 0;
    line-height: 1.4;
}

.rs-chatbot-reassurance svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    color: var(--color-success, #22c55e);
}

/* --- Hidden utility --- */
.rs-chatbot-hidden {
    display: none !important;
}
