:root {
    --smartai-header-bg: #232F3E;
    --smartai-header-text: #FFFFFF;
    --smartai-icon-color: #FFFFFF;
    --smartai-bot-bubble: #F0F2F2;
    --smartai-bot-text: #0F1111;
    --smartai-user-bubble: #E3F2FD;
    --smartai-user-text: #0F1111;
    --smartai-accent: #FF9900;
    --smartai-accent-hover: #E38900;
    --smartai-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* --- THE LAUNCHER --- */
#smartai-floating-launcher {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: var(--smartai-header-bg) !important;
    color: var(--smartai-header-text) !important;
    border: none;
    border-radius: 50px;
    padding: 12px 24px;
    font-size: 16px;
    font-family: var(--smartai-font);
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 9999;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

#smartai-floating-launcher:hover {
    transform: translateY(-2px);
}

#smartai-floating-launcher.smartai-hidden {
    display: none !important;
    opacity: 0;
}

/* --- THE WIDGET CONTAINER --- */
#smartai-widget-container {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 380px;
    height: 600px;
    max-height: 80vh;
    background: #fff !important;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10000;
    font-family: var(--smartai-font);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#smartai-widget-container.smartai-closed {
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
}

/* --- HEADER & NAVIGATION --- */
#smartai-chat-header {
    background-color: var(--smartai-header-bg) !important;
    color: var(--smartai-header-text) !important;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.smartai-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
}

.smartai-header-left .dashicons {
    color: var(--smartai-icon-color) !important;
}

.smartai-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.smartai-header-link {
    color: var(--smartai-icon-color) !important;
    text-decoration: none;
    font-size: 18px;
    line-height: 1;
    transition: opacity 0.2s;
}

.smartai-header-link:hover {
    opacity: 0.8;
}

#smartai-toggle-btn {
    background: none;
    border: none;
    color: var(--smartai-icon-color) !important;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

/* --- BODY & MESSAGES --- */
#smartai-chat-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #FFFFFF !important;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.smartai-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.agent-message {
    background-color: var(--smartai-bot-bubble) !important;
    color: var(--smartai-bot-text) !important;
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

.user-message {
    background-color: var(--smartai-user-bubble) !important;
    color: var(--smartai-user-text) !important;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

/* --- HORIZONTAL PRODUCT CAROUSEL --- */
.smartai-product-carousel {
    display: flex;
    flex-direction: row;
    gap: 12px;
    margin-top: 8px;
    width: 100%;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 10px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.smartai-product-carousel::-webkit-scrollbar {
    height: 6px;
}

.smartai-product-carousel::-webkit-scrollbar-thumb {
    background-color: #ccc;
    border-radius: 10px;
}

.smartai-product-card {
    flex: 0 0 82%;
    /* Leaves room for the next card to peek in */
    scroll-snap-align: center;
    display: flex;
    flex-direction: column;
    background: #fff !important;
    border: 1px solid #D5D9D9 !important;
    border-radius: 8px;
    padding: 12px;
    gap: 8px;
}

.smartai-card-top {
    display: flex;
    gap: 12px;
}

.smartai-product-card img {
    width: 70px;
    height: 70px;
    object-fit: cover;
    border-radius: 4px;
}

.smartai-card-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.smartai-card-info h4 {
    margin: 0 0 4px 0 !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    line-height: 1.2 !important;
}

.smartai-card-info h4 a {
    color: #007185 !important;
    text-decoration: none !important;
}

.smartai-card-info h4 a:hover {
    text-decoration: underline !important;
    color: #C45500 !important;
}

/* --- PRICE STYLING & FIXES --- */
.smartai-price {
    font-size: 16px !important;
    font-weight: 700 !important;
    color: #0F1111 !important;
}

/* Hide WooCommerce accessibility text */
.smartai-price .screen-reader-text {
    display: none !important;
}

/* Style Sale Prices like Amazon */
.smartai-price del {
    color: #565959 !important;
    font-size: 13px !important;
    font-weight: 400 !important;
    margin-right: 6px;
}

.smartai-price ins {
    text-decoration: none !important;
    color: #B12704 !important;
}

/* --- FIX: VIEW PRODUCT BUTTON --- */
.smartai-view-btn {
    background-color: var(--smartai-accent) !important;
    color: #111 !important;
    border: none !important;
    border-radius: 100px !important;
    padding: 6px 16px !important;
    /* Smaller padding */
    font-size: 12px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    box-shadow: 0 2px 5px rgba(213, 217, 217, 0.5) !important;
    transition: background-color 0.2s !important;
    text-align: center !important;
    text-decoration: none !important;
    display: inline-block !important;
    width: auto !important;
    /* FIX: Stops the button from stretching */
    align-self: flex-start !important;
    /* Keeps it pinned to the left */
    margin-top: 4px !important;
}

.smartai-view-btn:hover {
    background-color: var(--smartai-accent-hover) !important;
}

/* --- FOOTER INPUT --- */
#smartai-chat-footer {
    display: flex;
    padding: 12px;
    border-top: 1px solid #EAEDED !important;
    background: #F8F8F8 !important;
    gap: 8px;
    align-items: center;
}

/* FIX: Camera Button Contrast */
#smartai-upload-img-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--smartai-header-bg) !important;
    opacity: 0.8;
    transition: opacity 0.2s;
    padding: 0;
}

#smartai-upload-img-btn:hover {
    opacity: 1;
}

#smartai-chat-input {
    flex: 1;
    padding: 10px 12px !important;
    border: 1px solid #888C8C !important;
    border-radius: 4px !important;
    font-size: 14px !important;
    outline: none;
    background: #fff !important;
    color: #111 !important;
}

#smartai-chat-input:focus {
    border-color: var(--smartai-accent) !important;
    box-shadow: 0 0 0 2px rgba(255, 153, 0, 0.3) !important;
}

#smartai-send-btn {
    background-color: var(--smartai-header-bg) !important;
    color: var(--smartai-header-text) !important;
    border: none !important;
    border-radius: 4px !important;
    padding: 0 16px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    height: 38px;
}

/* --- VOICE SEARCH STYLES --- */
#smartai-voice-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--smartai-header-bg) !important;
    opacity: 0.8;
    transition: opacity 0.2s;
    padding: 0;
}

#smartai-voice-btn:hover {
    opacity: 1;
}

#smartai-voice-btn.smartai-recording {
    color: #d63638 !important;
    animation: smartai-pulse 1.5s infinite;
}

@keyframes smartai-pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.7;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* --- UI THROTTLING STYLES --- */
#smartai-chat-footer button:disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
}

#smartai-chat-input:disabled {
    background-color: #f1f1f1 !important;
    color: #888 !important;
}

@media (max-width: 480px) {
    #smartai-widget-container {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }

    #smartai-floating-launcher {
        bottom: 15px;
        right: 15px;
    }
}

/* --- IMAGE PREVIEW STYLES (Armored) --- */
#smartai-image-preview-container {
    display: none;
    padding: 8px 16px;
    background: #F8F8F8;
    border-top: 1px solid #EAEDED;
}

.smartai-preview-wrapper {
    position: relative;
    display: inline-block;
    margin-top: 5px;
}

.smartai-preview-wrapper img {
    height: 45px;
    width: 45px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #D5D9D9;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: block;
}

/* FIX: Theme-proof close button */
.smartai-preview-remove {
    position: absolute !important;
    top: -8px !important;
    right: -8px !important;
    background: rgba(0, 0, 0, 0.6) !important;
    /* Semi-transparent black */
    color: #fff !important;
    border: 2px solid #fff !important;
    border-radius: 50% !important;
    width: 22px !important;
    height: 22px !important;
    padding: 0 !important;
    margin: 0 !important;
    font-size: 14px !important;
    font-weight: bold !important;
    line-height: 18px !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
    z-index: 10 !important;
    box-sizing: border-box !important;
    min-height: 0 !important;
    min-width: 0 !important;
}

.smartai-preview-remove:hover {
    background: rgba(214, 54, 56, 0.9) !important;
    /* Turns red on hover */
}