/* assets/css/chat-widget.css */
:root {
    --sai-primary: #1A1A1A; /* dark gray/black */
    --sai-primary-hover: #333333;
    --sai-bg: #f9f9f9;
    --sai-window-bg: #f5f5f5; /* matches the slight gray background of the window */
    --sai-text: #1a1a1a;
    --sai-text-muted: #888888;
    --sai-border: #e0e0e0;
    --sai-bot-bg: #ffffff;
    --sai-user-bg: #1a1a1a;
    --sai-user-text: #ffffff;
    --sai-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.sai-chat-widget-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9990;
    font-family: var(--sai-font);
}

.sai-chat-trigger {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--sai-primary);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.sai-chat-trigger:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

.sai-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 420px;
    height: 650px;
    max-height: calc(100vh - 120px);
    background: var(--sai-window-bg);
    border-radius: 24px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    
    /* Visibility logic using classes */
    opacity: 0;
    pointer-events: none;
    transform: scale(0.9) translateY(10px);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

.sai-chat-window.active {
    opacity: 1;
    pointer-events: all;
    transform: scale(1) translateY(0);
}

.sai-chat-header {
    padding: 24px 24px 16px 24px;
    background: transparent;
    color: var(--sai-text);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.sai-logo-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sai-logo-icon svg {
    width: 100%;
    height: 100%;
}

.sai-header-info h3, .sai-header-left h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--sai-text);
    line-height: 1.2;
}

.sai-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sai-icon-btn {
    background: none;
    border: none;
    color: var(--sai-text);
    cursor: pointer;
    opacity: 0.7;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.sai-icon-btn:hover { 
    opacity: 1; 
    background: rgba(0,0,0,0.05);
}

/* Chat Body */
.sai-chat-body {
    flex: 1;
    padding: 10px 24px 20px 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Welcome UI */
.sai-welcome-wrapper {
    display: flex;
    flex-direction: column;
    margin-top: 10px;
}

.sai-welcome-title {
    font-size: 26px;
    font-weight: 700;
    color: var(--sai-text);
    margin: 0 0 8px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.wave-emoji {
    font-size: 24px;
}

.sai-welcome-subtitle {
    font-size: 16px;
    color: var(--sai-text-muted);
    margin: 0 0 24px 0;
}

.sai-welcome-cards {
    display: flex;
    gap: 12px;
    justify-content: space-between;
}

.sai-welcome-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.sai-welcome-card:hover {
    transform: translateY(-2px);
}

.sai-card-img {
    width: 100%;
    aspect-ratio: 1;
    background: white;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}

.sai-card-img img {
    width: 80%;
    height: 80%;
    object-fit: contain;
}

.sai-card-text {
    font-size: 12px;
    color: var(--sai-text);
    text-align: center;
    line-height: 1.3;
}

.sai-badge-sale {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #ff4d4f;
    color: white;
    font-size: 10px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Message Bubbles */
.sai-msg {
    max-width: 85%;
    display: flex;
    flex-direction: column;
}

.sai-msg-bot:not(.sai-welcome-wrapper) { 
    align-self: flex-start; 
}

.sai-msg-user { 
    align-self: flex-end; 
}

.sai-msg-content {
    font-size: 14px;
    line-height: 1.5;
    color: var(--sai-text);
    word-wrap: break-word;
}

.sai-msg-bot:not(.sai-welcome-wrapper) .sai-msg-content {
    background: var(--sai-bot-bg);
    padding: 12px 16px;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}

.sai-msg-user .sai-msg-content {
    background: var(--sai-user-bg);
    color: var(--sai-user-text);
    padding: 12px 16px;
    border-radius: 16px;
    border-bottom-right-radius: 4px;
}

/* Footer & Input */
.sai-chat-footer {
    padding: 16px 24px 20px 24px;
    background: transparent;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sai-input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
    border-radius: 30px; /* Pill shape */
    padding: 8px 12px 8px 20px;
    border: 1px solid var(--sai-border);
    transition: border-color 0.3s, box-shadow 0.3s;
}

.sai-input-wrapper:focus-within {
    border-color: #ccc;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

#sai-chat-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    color: var(--sai-text);
    padding: 6px 0;
    max-height: 100px;
    line-height: 1.5;
}

#sai-chat-input::placeholder {
    color: #b0b0b0;
}

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

#sai-chat-send:hover {
    transform: scale(1.05);
    background: var(--sai-primary-hover);
}

.sai-disclaimer {
    text-align: center;
    font-size: 11px;
    color: var(--sai-text-muted);
}

/* Thinking Indicator */
.sai-thinking {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 24px 16px 24px;
}

.sai-thinking-text { font-size: 12px; color: var(--sai-text-muted); }
.sai-thinking-dots span {
    display: inline-block;
    width: 4px;
    height: 4px;
    background: var(--sai-text-muted);
    border-radius: 50%;
    margin-right: 3px;
    animation: sai-pulse 1s infinite;
}
.sai-thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.sai-thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes sai-pulse {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.5); opacity: 1; }
}

@media (max-width: 768px) {
    .sai-chat-widget-container {
        bottom: 80px !important;
        right: 16px !important;
    }
    .sai-chat-window {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100vw;
        height: 85dvh;
        max-height: 100dvh;
        border-radius: 24px 24px 0 0;
        transform-origin: bottom center;
        
        transform: translateY(100%);
    }
    .sai-chat-window.active {
        transform: translateY(0);
    }
    .sai-welcome-cards {
        gap: 8px;
    }
}

/* Product Card UI */
.sai-msg-has-product {
    max-width: 95%;
    width: 100%;
}
.sai-msg-has-product .sai-msg-content {
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
    width: 100%;
}

.sai-product-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.sai-product-card {
    background: #ffffff;
    border: 1px solid #E5E7EB;
    border-radius: 32px;
    padding: 16px;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 16px;
}

.sai-product-img-wrapper {
    width: 120px;
    height: 140px;
    background: #F3F4F6;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
}

.sai-product-img-wrapper img {
    width: 85%;
    height: 85%;
    object-fit: contain;
}

.sai-product-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 140px;
}

.sai-product-info-top {
    /* container for title and price */
}

.sai-product-name {
    margin: 0 0 6px 0;
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    color: #111827;
    letter-spacing: -0.3px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.sai-product-name a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
    border-bottom: none;
    padding-bottom: 0;
}

.sai-product-price-row {
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.sai-price-current {
    font-size: 16px;
    font-weight: 800;
    color: #16A34A;
}

.sai-price-regular {
    font-size: 13px;
    color: #9CA3AF;
    text-decoration: line-through;
}

.sai-price-discount {
    font-size: 13px;
    color: #6B7280;
}

.sai-product-info-bottom {
    margin-top: auto;
}

.sai-product-add {
    background: #262626;
    color: #ffffff;
    border: none;
    border-radius: 9999px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    width: 100%;
    transition: background 0.2s;
    white-space: nowrap;
}

.sai-product-card a.added_to_cart {
    display: none !important;
}

.sai-product-add:hover {
    background: #000000;
}

/* Stepper UI */
.sai-stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    border-radius: 9999px;
    padding: 4px;
    width: 100%;
}

.sai-stepper button {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: #ffffff;
    color: #111827;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.sai-stepper button:hover {
    background: #f9fafb;
}

.sai-stepper input {
    width: 40px;
    text-align: center;
    border: none;
    background: transparent;
    font-size: 14px;
    font-weight: 700;
    color: #111827;
    padding: 0;
}

.sai-stepper input::-webkit-outer-spin-button,
.sai-stepper input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.sai-stepper input[type=number] {
    -moz-appearance: textfield;
}

/* Variation Rows */
.sai-variation-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
    border-top: 1px solid #e5e7eb;
    padding-top: 12px;
}

.sai-variation-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
}

.sai-variation-info {
    display: flex;
    flex-direction: column;
}

.sai-variation-name {
    color: #374151;
    font-weight: 600;
}

.sai-variation-price {
    color: #16a34a;
    font-weight: 700;
}

.sai-variation-row .sai-stepper {
    width: auto;
    background: transparent;
    padding: 0;
}
.sai-variation-row .sai-stepper button {
    background: #f3f4f6;
    box-shadow: none;
}
.sai-variation-row .sai-stepper input {
    width: 32px;
}

/* Batch Add Button */
.sai-batch-add-btn {
    background: #16a34a;
    color: #ffffff;
    border: none;
    border-radius: 12px;
    padding: 14px;
    font-size: 15px;
    font-weight: 800;
    text-align: center;
    width: 100%;
    margin-top: 16px;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(22, 163, 74, 0.2);
    transition: background 0.2s, transform 0.1s;
}

.sai-batch-add-btn:active {
    transform: scale(0.98);
}

/* Variant UI */
.sai-variations-wrapper {
    margin-bottom: 8px;
    display: none;
}

.sai-variations-wrapper.active {
    display: block;
}

.sai-variant-select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 12px;
    margin-bottom: 6px;
    outline: none;
    background: #fff;
}

.sai-cart-row {
    display: flex;
    gap: 8px;
}

.sai-qty-input {
    width: 60px;
    padding: 6px;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    text-align: center;
    font-size: 13px;
    outline: none;
}

/* Load More Button */
.sai-load-more {
    background: transparent;
    color: #db2777;
    border: 1px solid #db2777;
    border-radius: 9999px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    margin: 10px auto;
    display: block;
    transition: all 0.2s;
}
.sai-load-more:hover {
    background: #fdf2f8;
}
.sai-load-more:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sai-cart-badge { position:absolute;top:-4px;right:-6px;background:#ef4444;color:white;font-size:10px;font-weight:bold;border-radius:10px;min-width:16px;height:16px;padding:0 4px;display:none;align-items:center;justify-content:center;line-height:1;box-sizing:border-box; }
.sai-cart-badge.has-items { display:flex; }

/* Preset Questions */
.sai-preset-questions {
    display: flex;
    align-items: center;
    position: relative;
    padding: 0;
    margin-bottom: 10px;
    overflow: hidden;
}

.sai-preset-questions-inner {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none;  /* Internet Explorer 10+ */
    scroll-behavior: smooth;
    padding-right: 30px; /* Space for arrow */
}
.sai-preset-questions-inner::-webkit-scrollbar {
    display: none; /* WebKit */
}

.sai-preset-pill {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 9999px;
    padding: 6px 12px;
    font-size: 13px;
    color: #4b5563;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
}

.sai-preset-pill:hover {
    background: #f9fafb;
    border-color: #d1d5db;
    color: #111827;
}

.sai-preset-scroll-right,
.sai-preset-scroll-left {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #6b7280;
    z-index: 2;
}

.sai-preset-scroll-right {
    right: 5px;
    box-shadow: -4px 0 8px rgba(255,255,255,0.8);
}

.sai-preset-scroll-left {
    left: 5px;
    box-shadow: 4px 0 8px rgba(255,255,255,0.8);
}
