/* ===================================================
   STOREFRONT AI CHAT & RAG ENGINE STYLES
   =================================================== */
[x-cloak] { display: none !important; }

:root {
    --ai-chat-primary: #4f46e5;
    --ai-chat-primary-hover: #4338ca;
    --ai-chat-bg: #ffffff;
    --ai-chat-dark-bg: #0f172a;
    --ai-chat-border: rgba(226, 232, 240, 0.8);
    --ai-chat-text: #1e293b;
    --ai-chat-muted: #64748b;
    --ai-chat-bubble-bot: #f8fafc;
    --ai-chat-bubble-user: #4f46e5;
    --ai-chat-shadow: 0 20px 40px -15px rgba(15, 23, 42, 0.25), 0 0 0 1px rgba(15, 23, 42, 0.05);
}

/* ===================================================
   ANORA STANDING ANIMATED CHARACTER MASCOT (STOREFRONT)
   =================================================== */
.webly-storefront-anora-fab {
    position: fixed;
    bottom: 14px;
    right: 20px;
    z-index: 99999;
    display: inline-flex;
    align-items: flex-end;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.webly-storefront-anora-fab:hover {
    transform: scale(1.03);
}

.webly-storefront-anora-fab:active {
    transform: scale(0.98);
}

/* Mascot Container */
.webly-storefront-anora-fab .anora-mascot-wrap {
    position: relative;
    display: inline-block;
    flex-shrink: 0;
    width: 78px;
    height: 118px;
    filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.45));
    transition: transform 0.25s ease;
}

@media (min-width: 640px) {
    .webly-storefront-anora-fab .anora-mascot-wrap {
        width: 86px;
        height: 130px;
    }
}

/* SVG Keyframe Animations */
.anora-bot-lively .anora-bot-strut,
.anora-bot-lively .anora-bot-tilt,
.anora-bot-lively .anora-bot-swing,
.anora-bot-lively .anora-bot-wave {
    transform-box: view-box;
}

.anora-bot-lively .anora-bot-strut {
    animation: 3.4s ease-in-out infinite anora-idle;
}

.anora-bot-lively .anora-bot-wave {
    transform-origin: 63px 70px;
    animation: 4.5s ease-in-out infinite anora-wave;
}

.anora-bot-lively .anora-bot-tilt {
    transform-origin: 48px 62px;
    animation: 3.6s ease-in-out infinite anora-tilt;
}

.anora-bot-lively .anora-bot-swing {
    transform-origin: 48px 65px;
    animation: 2.6s ease-in-out infinite anora-swing;
}

.anora-bot-lively .anora-bot-gem {
    animation: 1.8s ease-in-out infinite anora-gem;
}

.anora-bot-glint {
    opacity: 0;
}

.anora-bot-lively .anora-bot-glint {
    opacity: 1;
    animation: 4.2s ease-in-out infinite anora-glint;
}

.anora-bot-sparkle {
    opacity: 0;
}

.anora-bot-lively .anora-bot-sparkle {
    animation: 2.4s ease-in-out infinite anora-twinkle;
}

.anora-bot-lively .anora-bot-sparkle-2 {
    animation-delay: 0.8s;
}

.anora-bot-lively .anora-bot-sparkle-3 {
    animation-delay: 1.6s;
}

@keyframes anora-idle {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-2px); }
}

@keyframes anora-wave {
    0%, 50%, 100% { transform: rotate(0); }
    58% { transform: rotate(-18deg); }
    66% { transform: rotate(12deg); }
    74% { transform: rotate(-18deg); }
    82% { transform: rotate(12deg); }
    90% { transform: rotate(-6deg); }
}

@keyframes anora-tilt {
    0%, 100% { transform: rotate(-3.5deg); }
    50% { transform: rotate(3.5deg); }
}

@keyframes anora-swing {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

@keyframes anora-gem {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.7) drop-shadow(0 0 5px #38bdf8); }
}

@keyframes anora-glint {
    0%, 60% { transform: translate(0) skew(-20deg); }
    85%, 100% { transform: translate(70px) skew(-20deg); }
}

@keyframes anora-twinkle {
    0%, 100% { opacity: 0; transform: scale(0.6); }
    50% { opacity: 1; transform: scale(1.15); }
}

/* Storefront Speech Hint Bubble above Anora */
.webly-anora-speech-hint,
.webly-storefront-anora-fab .webly-anora-speech-hint {
    position: relative;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    color: #f1f5f9;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    padding: 7px 12px 7px 14px;
    border-radius: 9999px;
    border: 1px solid rgba(45, 212, 191, 0.55);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45), 0 0 16px rgba(45, 212, 191, 0.25);
    white-space: nowrap;
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    z-index: 10;
    margin-bottom: 0;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.webly-anora-speech-hint:hover,
.webly-storefront-anora-fab .webly-anora-speech-hint:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5), 0 0 20px rgba(45, 212, 191, 0.35);
}

.webly-anora-speech-hint::after,
.webly-storefront-anora-fab .webly-anora-speech-hint::after {
    content: '';
    position: absolute;
    bottom: -5px;
    right: 24px;
    width: 8px;
    height: 8px;
    background: rgba(15, 23, 42, 0.95);
    border-right: 1px solid rgba(45, 212, 191, 0.55);
    border-bottom: 1px solid rgba(45, 212, 191, 0.55);
    transform: rotate(45deg);
}

.webly-anora-speech-text,
.webly-storefront-anora-fab .webly-anora-speech-text {
    user-select: none;
    color: #f1f5f9;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: -0.01em;
    transition: color 0.15s ease;
}

.webly-anora-speech-text:hover,
.webly-storefront-anora-fab .webly-anora-speech-text:hover {
    color: #2dd4bf;
}

.webly-hint-close-btn,
.webly-storefront-anora-fab .webly-hint-close-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    outline: none;
    color: #cbd5e1;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.webly-hint-close-btn:hover,
.webly-storefront-anora-fab .webly-hint-close-btn:hover {
    color: #ffffff;
    background: rgba(239, 68, 68, 0.85);
    transform: scale(1.1);
}

/* Legacy Floating Launcher Button (Fallback) */
.webly-ai-chat-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    padding: 2px;
    background: linear-gradient(135deg, #1f5e52 0%, #10b981 100%);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    box-shadow: 0 10px 25px -4px rgba(31, 94, 82, 0.5), 0 0 18px rgba(45, 212, 191, 0.35);
    cursor: pointer;
    transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    outline: none;
}

.webly-ai-chat-launcher:hover {
    transform: translateY(-4px) scale(1.06);
    box-shadow: 0 16px 32px -4px rgba(31, 94, 82, 0.65), 0 0 24px rgba(45, 212, 191, 0.5);
    border-color: rgba(255, 255, 255, 0.8);
}

.webly-ai-chat-launcher:active {
    transform: translateY(0) scale(0.96);
}

.webly-ai-launcher-avatar-wrap {
    width: 100%;
    height: 100%;
    position: relative;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.webly-ai-launcher-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.webly-ai-pulse-dot {
    position: absolute;
    top: 0;
    right: 0;
    width: 11px;
    height: 11px;
    background: #10b981;
    border: 2px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.8);
    animation: webly-pulse 2s infinite;
    z-index: 2;
}

@keyframes webly-pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Chat Window Container */
.webly-ai-chat-window {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 48px);
    background: #ffffff;
    border-radius: 20px;
    box-shadow: var(--ai-chat-shadow);
    border: 1px solid rgba(226, 232, 240, 0.9);
    display: flex;
    flex-direction: column;
    z-index: 99999;
    overflow: hidden;
    animation: webly-slide-up 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@keyframes webly-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Chat Header */
.webly-ai-header {
    background: linear-gradient(135deg, #0f172a 0%, #163f37 60%, #0f172a 100%);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #ffffff;
    border-bottom: 1px solid rgba(45, 212, 191, 0.2);
}

.webly-ai-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.webly-ai-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.webly-ai-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.webly-ai-avatar-online {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 10px;
    height: 10px;
    background: #10b981;
    border: 2px solid #0f172a;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.8);
    z-index: 2;
}

.webly-ai-title {
    font-size: 14px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.2;
}

.webly-ai-subtitle {
    font-size: 11px;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}

.webly-ai-whatsapp-btn {
    background: rgba(37, 211, 102, 0.12);
    border: 1px solid rgba(37, 211, 102, 0.3);
    color: #25d366;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

.webly-ai-whatsapp-btn:hover {
    background: #25d366;
    color: #ffffff;
    box-shadow: 0 0 10px rgba(37, 211, 102, 0.45);
    transform: translateY(-1px);
}

.webly-ai-close-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #cbd5e1;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.webly-ai-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

/* Quick Suggestion Chips */
.webly-ai-chips-bar {
    padding: 10px 14px;
    background: #f8fafc;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.webly-ai-chips-bar::-webkit-scrollbar {
    display: none;
}

.webly-ai-chip {
    white-space: nowrap;
    font-size: 11px;
    font-weight: 600;
    padding: 5px 10px;
    background: #ffffff;
    color: #334155;
    border: 1px solid #e2e8f0;
    border-radius: 9999px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.webly-ai-chip:hover {
    background: #4f46e5;
    color: #ffffff;
    border-color: #4f46e5;
}

.webly-ai-chip:disabled,
.webly-ai-chip.webly-disabled {
    opacity: 0.45;
    cursor: not-allowed !important;
    pointer-events: none !important;
}

.webly-ai-send-btn:disabled,
.webly-ai-send-btn.webly-disabled {
    opacity: 0.45;
    cursor: not-allowed !important;
    pointer-events: none !important;
}

.webly-ai-input:disabled {
    background: #f8fafc;
    color: #94a3b8;
    cursor: not-allowed;
}

/* Chat Messages Scroll Container */
.webly-ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #ffffff;
    scroll-behavior: smooth;
}

.webly-ai-msg-row {
    display: flex;
    flex-direction: column;
    max-width: 86%;
}

.webly-ai-msg-row.user {
    align-self: flex-end;
    align-items: flex-end;
}

.webly-ai-msg-row.assistant {
    align-self: flex-start;
    align-items: flex-start;
}

.webly-ai-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
}

.webly-ai-msg-row.user .webly-ai-bubble {
    background: #4f46e5;
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.webly-ai-msg-row.assistant .webly-ai-bubble {
    background: #f1f5f9;
    color: #1e293b;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(226, 232, 240, 0.7);
}

.webly-ai-msg-time {
    font-size: 10px;
    color: #94a3b8;
    margin-top: 3px;
    padding: 0 4px;
}

/* Interactive Product Cards inside Chat */
.webly-ai-product-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
    width: 100%;
}

.webly-ai-product-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
}

.webly-ai-product-card:hover {
    border-color: #6366f1;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.15);
}

.webly-ai-product-img {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    object-fit: cover;
    background: #f1f5f9;
    flex-shrink: 0;
}

.webly-ai-product-info {
    flex: 1;
    min-width: 0;
}

.webly-ai-product-title {
    font-size: 12px;
    font-weight: 600;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.webly-ai-product-cat {
    font-size: 10px;
    color: #64748b;
}

.webly-ai-product-actions {
    display: flex;
    gap: 4px;
}

.webly-ai-btn-sm {
    font-size: 10px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.webly-ai-btn-view {
    background: #f1f5f9;
    color: #334155;
}

.webly-ai-btn-inquire {
    background: #4f46e5;
    color: #ffffff;
}

/* Fallback Action Buttons */
.webly-ai-fallback-box {
    margin-top: 10px;
    padding: 10px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.webly-ai-wa-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    background: #25d366;
    color: #ffffff;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    transition: background 0.15s ease;
}

.webly-ai-wa-btn:hover {
    background: #20ba5a;
}

.webly-ai-rfq-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    background: #4f46e5;
    color: #ffffff;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    border: none;
    cursor: pointer;
}

/* Typing Indicator */
.webly-ai-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: #f1f5f9;
    border-radius: 14px;
    width: fit-content;
}

.webly-ai-typing-dot {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: webly-typing 1.2s infinite ease-in-out;
}

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

@keyframes webly-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* Input Area */
.webly-ai-input-area {
    padding: 12px 14px;
    background: #ffffff;
    border-top: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    gap: 8px;
}

.webly-ai-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 9px 12px;
    font-size: 13px;
    color: #0f172a;
    outline: none;
    transition: border-color 0.15s ease;
}

.webly-ai-input:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

.webly-ai-send-btn {
    width: 36px;
    height: 36px;
    background: #4f46e5;
    color: #ffffff;
    border: none;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.webly-ai-send-btn:hover {
    background: #4338ca;
}

/* Quick RFQ Lead Modal inside chat */
.webly-ai-lead-modal {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 10;
}

.webly-ai-lead-card {
    background: #ffffff;
    border-radius: 16px;
    padding: 20px;
    width: 100%;
    max-width: 320px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
}

.webly-ai-lead-title {
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 4px;
}

.webly-ai-lead-desc {
    font-size: 11px;
    color: #64748b;
    margin-bottom: 14px;
    line-height: 1.4;
}

.webly-ai-form-group {
    margin-bottom: 10px;
}

.webly-ai-form-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 4px;
}

.webly-ai-form-input {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 12px;
    box-sizing: border-box;
}

.webly-ai-form-input:focus {
    outline: none;
    border-color: #4f46e5;
}

.webly-ai-form-actions {
    display: flex;
    gap: 8px;
    margin-top: 14px;
}

@media (max-width: 480px) {
    .webly-ai-chat-window {
        bottom: 0;
        right: 0;
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
}
