/* Smart Product Chatbot CSS */
:root {
    /* Fallback if inline variable fails */
    --spc-primary-color: #2563eb;
    --spc-primary-hover: #1d4ed8;
    --spc-bg-light: #ffffff;
    --spc-bg-chat: #f3f4f6;
    --spc-text-main: #1f2937;
    --spc-text-muted: #6b7280;
    --spc-border-color: #e5e7eb;
    --spc-shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --spc-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Widget Container */
.spc-widget-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* Launcher Button Wrapper */
.spc-launcher-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

/* Launcher Button */
.spc-launcher-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background-color: var(--spc-primary-color);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: var(--spc-shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), background-color 0.2s ease, box-shadow 0.3s ease;
    z-index: 2;
}

.spc-launcher-btn:hover {
    transform: scale(1.05);
}

.spc-launcher-btn svg {
    transition: opacity 0.2s, transform 0.3s;
}

/* Attention Bubble (The 5s Popup) */
.spc-attention-bubble {
    position: absolute;
    right: 80px;
    bottom: 10px;
    background-color: white;
    padding: 14px 18px;
    border-radius: 12px;
    border-bottom-right-radius: 2px;
    box-shadow: var(--spc-shadow-lg);
    width: max-content;
    max-width: 250px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.95);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    border: 1px solid var(--spc-border-color);
}

/* Animation classes applied by JS */
.spc-attention-bubble.spc-show-attention {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* The shake/glow effect applied after 5s to the button */
.spc-shake-glow {
    animation: spcPulseGlow 2s infinite;
}

.spc-shake-icon svg {
    animation: spcWiggle 1s ease-in-out infinite;
}

@keyframes spcPulseGlow {
    0% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.6); }
    70% { box-shadow: 0 0 0 20px rgba(37, 99, 235, 0); }
    100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}

@keyframes spcWiggle {
    0%, 100% { transform: rotate(0deg); }
    20% { transform: rotate(-15deg); }
    40% { transform: rotate(15deg); }
    60% { transform: rotate(-10deg); }
    80% { transform: rotate(10deg); }
}

.spc-attention-content {
    flex-grow: 1;
}

.spc-attention-text {
    font-size: 15px;
    color: var(--spc-text-main);
    line-height: 1.4;
    font-weight: 600;
}

#spc-attention-close {
    background: none;
    border: none;
    color: var(--spc-text-muted);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    padding: 0;
    margin-top: -4px;
    margin-right: -4px;
}

#spc-attention-close:hover {
    color: var(--spc-text-main);
}

/* Chat Window */
.spc-chat-window {
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background-color: var(--spc-bg-light);
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 20px;
    transform-origin: bottom right;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid var(--spc-border-color);
}

/* Hidden state */
.spc-closed .spc-chat-window {
    opacity: 0;
    visibility: hidden;
    transform: scale(0.5) translateY(50px);
    pointer-events: none;
}

.spc-closed .spc-icon-close { display: none !important; }
.spc-closed .spc-icon-chat { display: block !important; }

/* Open state */
.spc-open .spc-chat-window {
    opacity: 1;
    visibility: visible;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}

.spc-open .spc-icon-chat { display: none !important; }
.spc-open .spc-icon-close { display: block !important; }
.spc-open .spc-attention-bubble { display: none !important; } /* Hide bubble when open */

/* Header */
.spc-chat-header {
    background-color: var(--spc-primary-color);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.spc-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.spc-avatar {
    width: 36px;
    height: 36px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spc-bot-name {
    font-weight: 600;
    font-size: 16px;
}

.spc-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
    line-height: 1;
}

.spc-close-btn:hover {
    opacity: 1;
}

/* Chat Body */
.spc-chat-body {
    flex-grow: 1;
    padding: 20px;
    background-color: var(--spc-bg-chat);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Scrollbar for chat body */
.spc-chat-body::-webkit-scrollbar { width: 6px; }
.spc-chat-body::-webkit-scrollbar-track { background: transparent; }
.spc-chat-body::-webkit-scrollbar-thumb { background-color: rgba(0,0,0,0.1); border-radius: 10px; }

/* Messages */
.spc-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: spcFadeInUp 0.3s ease forwards;
}

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

.spc-bot-message {
    align-self: flex-start;
}

.spc-user-message {
    align-self: flex-end;
}

.spc-message-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    box-shadow: var(--spc-shadow-sm);
}

.spc-bot-message .spc-message-bubble {
    background-color: var(--spc-bg-light);
    color: var(--spc-text-main);
    border-bottom-left-radius: 4px;
}

.spc-user-message .spc-message-bubble {
    background-color: var(--spc-primary-color);
    color: white;
    border-bottom-right-radius: 4px;
}

/* Quick Actions */
.spc-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: -8px;
}

.spc-quick-btn {
    background-color: var(--spc-bg-light);
    border: 1px solid var(--spc-border-color);
    color: var(--spc-primary-color);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.spc-quick-btn:hover {
    background-color: var(--spc-primary-color);
    color: white;
    border-color: var(--spc-primary-color);
}

/* Vertical Product List */
.spc-product-list-vertical {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 8px;
}

.spc-product-item-link {
    text-decoration: none;
    display: block;
}

.spc-product-item {
    display: flex;
    align-items: center;
    background-color: white;
    border: 1px solid var(--spc-border-color);
    border-radius: 12px;
    padding: 8px 10px;
    gap: 12px;
    box-shadow: var(--spc-shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.spc-product-item-link:hover .spc-product-item {
    transform: translateY(-2px);
    box-shadow: var(--spc-shadow-lg);
    border-color: var(--spc-primary-color);
}

.spc-product-item-img {
    width: 52px;
    height: 52px;
    border-radius: 8px;
    object-fit: cover;
    background-color: #f9fafb;
    flex-shrink: 0;
}

.spc-product-item-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
}

.spc-product-item-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--spc-text-main);
    margin: 0 0 4px 0;
    line-height: 1.3;
    /* Truncate to 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.spc-product-item-price {
    font-size: 14px;
    font-weight: 700;
    color: var(--spc-primary-color);
}

.spc-product-item-price del {
    font-size: 11px;
    color: var(--spc-text-muted);
    font-weight: normal;
    margin-right: 4px;
}

.spc-product-item-price ins {
    text-decoration: none;
}

.spc-product-item-arrow {
    color: var(--spc-primary-color);
    display: flex;
    align-items: center;
    padding-right: 4px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.spc-product-item-link:hover .spc-product-item-arrow {
    opacity: 1;
}

/* Typing Indicator */
.spc-typing {
    display: flex;
    gap: 4px;
    padding: 16px 18px;
    background-color: var(--spc-bg-light);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    width: max-content;
    box-shadow: var(--spc-shadow-sm);
}

.spc-dot {
    width: 8px;
    height: 8px;
    background-color: var(--spc-text-muted);
    border-radius: 50%;
    animation: spcTyping 1.4s infinite ease-in-out both;
}

.spc-dot:nth-child(1) { animation-delay: -0.32s; }
.spc-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes spcTyping {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Footer (Input area) */
.spc-chat-footer {
    padding: 16px;
    background-color: white;
    border-top: 1px solid var(--spc-border-color);
}

.spc-chat-form {
    display: flex;
    gap: 10px;
    background-color: var(--spc-bg-chat);
    border-radius: 24px;
    padding: 6px 6px 6px 16px;
    border: 1px solid transparent;
    transition: border-color 0.2s;
}

.spc-chat-form:focus-within {
    border-color: var(--spc-primary-color);
}

#spc-chat-input {
    flex-grow: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 14px;
    color: var(--spc-text-main);
    padding: 0;
    box-shadow: none !important;
}

#spc-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--spc-primary-color);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

#spc-send-btn:hover {
    transform: scale(1.05);
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .spc-widget-container {
        bottom: 16px;
        right: 16px;
    }
    
    .spc-chat-window {
        width: calc(100vw - 32px);
        height: calc(100vh - 100px);
        max-height: 600px;
    }

    .spc-attention-bubble {
        right: 75px;
        max-width: 220px;
    }
}
