/* Chatbot Widget Styles */
:root {
    --stx-bot-primary: #2563eb;
    --stx-bot-hover: #1d4ed8;
    --stx-bot-bg: rgba(15, 23, 42, 0.85); /* Dark slate glass */
    --stx-bot-board: rgba(30, 41, 59, 0.95);
    --stx-bot-border: rgba(255, 255, 255, 0.1);
    --stx-bot-text: #f8fafc;
    --stx-bot-muted: #94a3b8;
    --stx-user-bubble: #2563eb;
    --stx-ai-bubble: rgba(255, 255, 255, 0.05);
}

/* Floating Action Button */
.stx-chatbot-fab:not(.active) {
    background: transparent !important;
    box-shadow: none !important;
}

.stx-chatbot-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9999;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), background 0.3s ease, box-shadow 0.3s ease;
    animation: stxBotFloat 4s ease-in-out infinite;
}

.stx-chatbot-fab:hover {
    transform: scale(1.12) translateY(-4px);
    filter: drop-shadow(0 12px 25px rgba(37, 99, 235, 0.6));
}

@keyframes stxBotFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

/* 3D Bot Sphere Character Container */
.stx-3d-bot-face {
    width: 100%;
    height: 100%;
    position: relative;
    border-radius: 50%;
    transition: transform 0.3s ease, opacity 0.3s ease;
    animation: stx360LeftToRight 8s infinite cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Smooth 360° Left-to-Right Spin Animation */
@keyframes stx360LeftToRight {
    0%, 75%, 100% {
        transform: rotate(0deg) scale(1);
    }
    80% {
        transform: rotate(180deg) scale(1.16);
    }
    90% {
        transform: rotate(360deg) scale(1.05);
    }
    95% {
        transform: rotate(360deg) scale(1);
    }
}

.stx-bot-sphere {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    /* Exact Staurax Brand Palette: Crisp White, Electric Blue #2563eb & Dark Slate #0f172a Heading Text */
    background: radial-gradient(circle at 32% 22%, #ffffff 0%, #dbeafe 18%, #3b82f6 42%, #2563eb 70%, #0f172a 94%, #1e293b 100%);
    box-shadow: 
        inset -5px -7px 15px rgba(15, 23, 42, 0.85),
        inset 5px 7px 16px rgba(255, 255, 255, 0.9),
        0 12px 28px rgba(37, 99, 235, 0.45),
        0 0 22px rgba(37, 99, 235, 0.35);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: stxGlowPulse 4s infinite ease-in-out;
}

@keyframes stxGlowPulse {
    0%, 100% {
        box-shadow: 
            inset -5px -7px 15px rgba(15, 23, 42, 0.85),
            inset 5px 7px 16px rgba(255, 255, 255, 0.9),
            0 12px 28px rgba(37, 99, 235, 0.45),
            0 0 20px rgba(37, 99, 235, 0.3);
    }
    50% {
        box-shadow: 
            inset -5px -7px 15px rgba(15, 23, 42, 0.85),
            inset 5px 7px 16px rgba(255, 255, 255, 0.9),
            0 16px 36px rgba(37, 99, 235, 0.7),
            0 0 38px rgba(37, 99, 235, 0.75);
    }
}

/* 3D Specular Highlight */
.stx-bot-highlight {
    position: absolute;
    top: 6%;
    left: 16%;
    width: 36%;
    height: 25%;
    background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.98) 0%, rgba(255, 255, 255, 0) 80%);
    border-radius: 50%;
    transform: rotate(-25deg);
    pointer-events: none;
    animation: stxHighlightShift 8s infinite ease-in-out;
}

@keyframes stxHighlightShift {
    0%, 100% { transform: rotate(-25deg) translate(0, 0); }
    25%, 45% { transform: rotate(-25deg) translate(3px, 1px); }
    60%, 85% { transform: rotate(-25deg) translate(-3px, 1px); }
}

/* Bot Face Track Container for JS Mouse Attraction */
.stx-bot-face-track {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s ease-out;
    pointer-events: none;
    z-index: 2;
}

/* Bot Eyes - Cute Glowing White */
.stx-bot-eyes {
    display: flex;
    gap: 11px;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
    margin-top: 5px;
}

.stx-bot-eye {
    width: 13px;
    height: 16px;
    background: #ffffff;
    border-radius: 50%;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.95), 0 0 5px rgba(56, 189, 248, 0.8);
    animation: stxBlink 4s infinite ease-in-out;
}

.stx-bot-pupil {
    width: 6px;
    height: 8px;
    background: #0f172a;
    border-radius: 50%;
    position: absolute;
    top: 4px;
    left: 3.5px;
    transition: transform 0.08s ease-out;
}

.stx-bot-pupil::after {
    content: '';
    position: absolute;
    top: 1px;
    right: 1px;
    width: 2.5px;
    height: 2.5px;
    background: #ffffff;
    border-radius: 50%;
}

/* Eye Blinking Animation */
@keyframes stxBlink {
    0%, 47%, 53%, 100% {
        transform: scaleY(1);
    }
    50% {
        transform: scaleY(0.1);
    }
}

/* Bot Mouth */
.stx-bot-mouth {
    width: 14px;
    height: 7px;
    border-bottom: 2.5px solid #ffffff;
    border-radius: 0 0 10px 10px;
    margin-top: 2px;
    position: relative;
    z-index: 2;
    transition: transform 0.2s ease, width 0.2s ease;
    filter: drop-shadow(0 2px 3px rgba(15, 23, 42, 0.6));
}

.stx-chatbot-fab:hover .stx-bot-mouth {
    transform: scale(1.18);
    width: 16px;
}

/* Bot Cheeks */
.stx-bot-cheeks {
    position: absolute;
    top: 55%;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 9px;
    box-sizing: border-box;
    pointer-events: none;
}

.stx-bot-cheek {
    width: 9px;
    height: 5px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    filter: blur(1.5px);
}

.stx-bot-cheek {
    width: 9px;
    height: 5px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    filter: blur(1.5px);
}

/* Mini Avatar inside Header */
.stx-mini-avatar {
    width: 38px;
    height: 38px;
}
.stx-mini-avatar .stx-bot-eyes {
    gap: 7px;
    margin-top: 3px;
}
.stx-mini-avatar .stx-bot-eye {
    width: 8px;
    height: 10px;
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.9);
}
.stx-mini-avatar .stx-bot-pupil {
    width: 4px;
    height: 5px;
    top: 2.5px;
    left: 2px;
}
.stx-mini-avatar .stx-bot-mouth {
    width: 9px;
    height: 5px;
    border-bottom-width: 2px;
    margin-top: 1px;
}

.stx-chatbot-fab.active {
    background: var(--stx-bot-primary);
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.5);
    animation: none;
}

.stx-chatbot-fab svg {
    width: 28px;
    height: 28px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.stx-chatbot-fab.active .fab-icon-chat {
    opacity: 0;
    transform: rotate(90deg) scale(0);
    position: absolute;
}
.stx-chatbot-fab.active .fab-icon-close {
    opacity: 1;
    transform: rotate(0) scale(1);
    color: white;
}
.stx-chatbot-fab:not(.active) .fab-icon-close {
    opacity: 0;
    transform: rotate(-90deg) scale(0);
    position: absolute;
}

/* Chat Window Container */
.stx-chatbot-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--stx-bot-board);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--stx-bot-border);
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255,255,255,0.05) inset;
    display: flex;
    flex-direction: column;
    z-index: 9998;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.1);
    overflow: hidden;
}

.stx-chatbot-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Chat Header */
.stx-chatbot-header {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    background: rgba(15, 23, 42, 0.5);
    border-bottom: 1px solid var(--stx-bot-border);
    gap: 12px;
}

/* Title takes available space so close btn goes to far right */
.stx-chatbot-title {
    flex: 1;
}

/* In-header close button — hidden on desktop, gray, mobile only */
.stx-header-close {
    display: none;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(148, 163, 184, 0.2);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}
.stx-header-close:hover {
    background: rgba(148, 163, 184, 0.4);
    color: #fff;
    transform: scale(1.08);
}
.stx-header-close svg {
    width: 16px;
    height: 16px;
    stroke-width: 2.5;
}

.stx-chatbot-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #2563eb, #8b5cf6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
}

.stx-chatbot-avatar svg {
    width: 20px;
    height: 20px;
    color: white;
}

.stx-chatbot-title h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--stx-bot-text);
    font-family: 'Outfit', sans-serif;
}

.stx-chatbot-title span {
    font-size: 0.8rem;
    color: #10b981; /* Online green */
    display: flex;
    align-items: center;
    gap: 4px;
}

.stx-chatbot-title span::before {
    content: '';
    display: block;
    width: 6px;
    height: 6px;
    background: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 8px #10b981;
}

/* Chat Body (Messages) */
.stx-chatbot-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

/* Scrollbar formatting */
.stx-chatbot-body::-webkit-scrollbar {
    width: 6px;
}
.stx-chatbot-body::-webkit-scrollbar-track {
    background: transparent;
}
.stx-chatbot-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

/* Chat Bubbles */
.stx-message {
    max-width: 85%;
    display: inline-block;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.5;
    word-wrap: break-word;
    animation: stxPopIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    transform-origin: bottom center;
}

@keyframes stxPopIn {
    from { opacity: 0; transform: scale(0.9) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.stx-message p { margin: 0 0 8px 0; }
.stx-message p:last-child { margin: 0; }

.stx-message ul, .stx-message ol {
    margin: 8px 0;
    padding-left: 20px;
}

.stx-message strong {
    font-weight: 600;
    color: #fff;
}

/* User Message */
.stx-message-user {
    align-self: flex-end;
    background: var(--stx-user-bubble);
    color: white;
    border-bottom-right-radius: 4px;
    transform-origin: bottom right;
}

/* AI Message */
.stx-message-ai {
    align-self: flex-start;
    background: var(--stx-ai-bubble);
    color: var(--stx-bot-text);
    border: 1px solid var(--stx-bot-border);
    border-bottom-left-radius: 4px;
    transform-origin: bottom left;
}
.stx-message-ai strong { color: #60a5fa; }

/* Chat Links */
.stx-chat-link {
    color: #60a5fa;
    text-decoration: none;
    font-weight: 600;
    border-bottom: 1.5px solid rgba(96, 165, 250, 0.3);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.stx-chat-link:hover {
    color: #93c5fd;
    border-bottom-color: #93c5fd;
    transform: translateY(-1px);
}

.stx-chat-link::after {
    content: '→';
    font-size: 0.8rem;
    transition: transform 0.2s ease;
}

.stx-chat-link:hover::after {
    transform: translateX(2px);
}

/* Typing Indicator */
.stx-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 14px 18px;
    background: var(--stx-ai-bubble);
    border: 1px solid var(--stx-bot-border);
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    width: max-content;
    align-self: flex-start;
}
.stx-typing span {
    width: 6px;
    height: 6px;
    background: var(--stx-bot-muted);
    border-radius: 50%;
    animation: stxTypeBounce 1.4s infinite ease-in-out both;
}
.stx-typing span:nth-child(1) { animation-delay: -0.32s; }
.stx-typing span:nth-child(2) { animation-delay: -0.16s; }
@keyframes stxTypeBounce {
    0%, 80%, 100% { transform: scale(0); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Chat Input Area */
.stx-chatbot-footer {
    padding: 16px;
    background: rgba(15, 23, 42, 0.5);
    border-top: 1px solid var(--stx-bot-border);
}

.stx-chatbot-input-wrapper {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--stx-bot-border);
    border-radius: 24px;
    padding: 4px 4px 4px 16px;
    transition: border-color 0.2s;
}

.stx-chatbot-input-wrapper:focus-within {
    border-color: rgba(37, 99, 235, 0.5);
    background: rgba(255, 255, 255, 0.08);
}

.stx-chatbot-input-wrapper input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--stx-bot-text);
    font-size: 0.95rem;
    outline: none;
    font-family: 'Inter', sans-serif;
}
.stx-chatbot-input-wrapper input::placeholder {
    color: var(--stx-bot-muted);
}

.stx-chatbot-send {
    background: var(--stx-bot-primary);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}

.stx-chatbot-send:hover {
    background: var(--stx-bot-hover);
    transform: scale(1.05);
}
.stx-chatbot-send:disabled {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.3);
    cursor: not-allowed;
    transform: none;
}
.stx-chatbot-send svg {
    width: 16px;
    height: 16px;
    position: relative;
    right: -1px; /* visual center for send icons */
}

/* ===== Mobile Responsive ===== */
@media (max-width: 480px) {

    /* Chat window: pinned top-to-bottom, avoids Android Chrome 100vh bug */
    .stx-chatbot-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: auto;           /* let top+bottom pins define height */
        max-width: 100vw;
        max-height: none;
        border-radius: 0;
        padding-bottom: 0;
        display: flex;
        flex-direction: column;
        z-index: 9998;
    }

    /* Header: full width, close btn inside */
    .stx-chatbot-header {
        flex-shrink: 0;
        padding-right: 20px;
        background: rgba(15, 23, 42, 0.98);
    }

    /* Show close button only on mobile */
    .stx-header-close {
        display: flex;
    }

    /* Body: scrollable, fills all space between header and footer */
    .stx-chatbot-body {
        flex: 1;
        overflow-y: auto;
        min-height: 0;
    }

    /* Footer: sits flush at bottom */
    .stx-chatbot-footer {
        flex-shrink: 0;
        position: relative;
        padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
        background: rgba(15, 23, 42, 0.98);
        border-top: 1px solid rgba(255,255,255,0.08);
        z-index: 10;
    }

    /* FAB — always bottom-right, hidden when chat is open */
    .stx-chatbot-fab {
        bottom: 16px;
        right: 16px;
        z-index: 9999;
    }

    /* Hide the FAB completely when chat is open on mobile */
    .stx-chatbot-fab.active {
        opacity: 0;
        pointer-events: none;
        transform: scale(0);
    }

    /* Welcome Tooltip Responsive Fix for Mobile Screens */
    .stx-chatbot-tooltip {
        white-space: normal !important;
        max-width: calc(100vw - 40px) !important;
        width: max-content;
        font-size: 0.82rem !important;
        padding: 10px 14px !important;
        right: 0 !important;
        bottom: calc(100% + 12px) !important;
        line-height: 1.4 !important;
        box-sizing: border-box;
    }
}
