/* =========================================================
   Chatbot AI Frontend Styles
   Modern Chat UI (ChatGPT Inspired)
========================================================= */

/* Root Variables */
:root {
    --cb-primary: #0a84ff;
    --cb-bg: #ffffff;
    --cb-dark: #111827;
    --cb-light: #f3f4f6;
    --cb-border: #e5e7eb;
    --cb-text: #1f2937;
    --cb-muted: #6b7280;
}

/* Reset */
#chatbot-ai * {
    box-sizing: border-box;
    font-family: Arial, sans-serif;
}

/* =========================================================
   Floating Button
========================================================= */

.chatbot-ai-open {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: var(--cb-primary);
    color: #fff;
    font-size: 26px;
    cursor: pointer;
    z-index: 999999;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}

.chatbot-ai-open:hover {
    transform: scale(1.1);
}

/* =========================================================
   Chat Window (Popup)
========================================================= */

.chatbot-ai-window {
    position: fixed;

    top: 20px;
    left: 75px;
    right: 75px;
    bottom: 35px;

    width: auto;
    height: auto;

    border-radius: 20px;
    overflow: hidden;
    background: #fff;

    display: none;

    flex-direction: column;

    z-index: 999999;
}

/* Open state */
.chatbot-ai-window.active {
    display: flex;
}

/* Fullscreen on mobile */
@media (max-width: 768px) {
    .chatbot-ai-window {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }
}

/* =========================================================
   Header
========================================================= */

.chatbot-ai-header {
    flex-shrink: 0;
    background: var(--cb-dark);
    color: #fff;
    padding: 7px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.chatbot-ai-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chatbot-ai-avatar {
    width: 38px;
    height: 38px;
    background: var(--cb-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    padding-top: 7px;
}

.chatbot-ai-title span {
    font-size: 12px;
    color: #9ca3af;
    display: block;
}

.chatbot-ai-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
}

/* =========================================================
   Messages Area
========================================================= */

.chatbot-ai-messages {
    flex: 1;
    min-height: 0;
    padding: 15px 30px 8px;
    overflow-y: auto;
    background: #fff;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

/* Scrollbar */
.chatbot-ai-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-ai-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

/* =========================================================
   Message Bubbles
========================================================= */

.chatbot-ai-message {
    margin-bottom: 12px;
    max-width: 80%;
    line-height: 1.4;
    font-size: 14px;
    word-wrap: break-word;
}

.chatbot-ai-message-text {
    padding: 10px 14px;
    border-radius: 12px;
    line-height: 1.4;
    font-size: 14px;
    word-wrap: break-word;
}

/* Bot message */
.chatbot-ai-message.bot {
    align-self: flex-start;
    max-width: 100%;
    width: fit-content;
}

.chatbot-ai-message.bot .chatbot-ai-message-text {
    background: #e5e7eb;
    color: var(--cb-text);
    border-radius: 14px 14px 14px 4px;
}

/* Product reply: outer wrapper is layout-only */
.chatbot-ai-message.bot.has-products {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    width: 100%;
    max-width: 100%;
    background: transparent;
    padding: 0;
}

.chatbot-ai-message.bot.has-products .chatbot-ai-message-text,
.chatbot-ai-message.bot .product-summary {
    background: #e5e7eb;
    border: 1px solid #e5e7eb;
    border-radius: 14px 14px 14px 4px;
    padding: 14px 16px;
    margin-bottom: 0;
    color: var(--cb-text);
    line-height: 1.5;
    font-size: 14px;
    max-width: 60%;
    width: fit-content;
}

/* User message */
.chatbot-ai-message.user {
    margin-left: auto;
    max-width: 70%;
    width: fit-content;
}

.chatbot-ai-message.user .chatbot-ai-message-text {
    background: #111827;
    color: #fff;
    border-radius: 14px 14px 4px 14px;
    font-size: 14px;
}

.chatbot-ai-suggestions {
    margin: 0 0 12px 0;
    padding: 12px 14px;
    border-radius: 12px;
    /* max-width: 80%; */
    /* background: #ffffff; */
    color: var(--cb-text);
    align-self: flex-start;
    width: fit-content;
    /* border: 1px solid var(--cb-border); */
    /* box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04); */
}

.chatbot-ai-suggestions-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 10px;
}

.chatbot-ai-suggestions-list {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.chatbot-ai-suggestion {
    border: none;
    background: #fff;
    color: #1f2937;
    padding: 3px 0px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    line-height: 1.4;
    text-align: left;
    transition: 0.2s ease;
}

.chatbot-ai-suggestion:hover {
    background: #eff6ff;
    border-color: #93c5fd;
}

.chatbot-ai-related-products {
    margin: 0 0 12px 0;
    padding: 12px 14px;
    border-radius: 12px;
    max-width: 100%;
    /* background: #ffffff;
    border: 1px solid var(--cb-border);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04); */
}

.chatbot-ai-related-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 10px;
}

.chatbot-ai-related-products .products-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    width: 100%;
    margin-top: 0;
}

.chatbot-ai-related-products .product-card-grid {
    width: 100%;
    max-width: none;
    min-height: 360px;
}

@media (max-width: 1024px) {
    .chatbot-ai-related-products .products-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .chatbot-ai-related-products .products-grid {
        grid-template-columns: 1fr;
    }
}

/* =========================================================
   Footer
========================================================= */

.chatbot-ai-footer {
    flex-shrink: 0;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    margin: 0 auto 20px;
    padding: 12px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    position: relative;
    z-index: 2;
    width: calc(100% - 60px);
}

.chatbot-ai-composer {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 10px;
}

/* Textarea */
#chatbot-ai-input {
    width: 100%;
    resize: none;
    border: none;
    border-radius: 0;
    padding: 0;
    font-size: 14px;
    line-height: 1.4;
    color: #1f2937;
    outline: none;
    max-height: 120px;
    background: transparent;
    box-shadow: none;
}

#chatbot-ai-input::placeholder {
    color: #9ca3af;
}

/* Icon buttons */
.chatbot-ai-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: #f3f4f6;
    color: #111827;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.chatbot-ai-icon:hover {
    background: #e5e7eb;
}

#chatbot-ai-voice {
    border-radius: 50%;
}

#chatbot-ai-voice.is-listening {
    background: #fee2e2;
    color: #dc2626;
    animation: chatbotVoicePulse 1s ease-in-out infinite;
}

@keyframes chatbotVoicePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

/* Send button */
.chatbot-ai-send {
    flex-shrink: 0;
    background: #f3f4f6;
    color: #111827;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.chatbot-ai-send:hover {
    background: #e5e7eb;
}

.chatbot-ai-send svg {
    display: block;
}

/* =========================================================
   Image Preview (inside input composer)
========================================================= */

.chatbot-ai-preview {
    display: none;
    gap: 10px;
    flex-wrap: wrap;
    padding: 2px 4px 2px 0;
    background: transparent;
}

.chatbot-ai-preview.has-images {
    display: flex;
}

.chatbot-ai-preview-item {
    position: relative;
    width: 56px;
    height: 56px;
    border-radius: 8px;
    overflow: visible;
    background: #f3f4f6;
    border: none;
    flex-shrink: 0;
}

.chatbot-ai-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 8px;
}

.chatbot-ai-preview-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    border: 1.5px solid #fff;
    border-radius: 50%;
    background: #111827;
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    z-index: 2;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: background 0.15s ease, transform 0.15s ease;
}

.chatbot-ai-preview-remove:hover {
    background: #000;
    transform: scale(1.06);
}

.chatbot-ai-preview-remove svg {
    display: block;
    width: 8px;
    height: 8px;
}

/* =========================================================
   Animations
========================================================= */

@keyframes cbFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Background overlay */

html.chatbot-ai-scroll-lock,
body.chatbot-ai-scroll-lock {
    overflow: hidden !important;
    height: 100%;
    overscroll-behavior: none;
    touch-action: none;
}

body.chatbot-ai-scroll-lock {
    position: fixed;
    width: 100%;
}

.chatbot-ai-overlay {
    position: fixed;
    inset: 0;

    background: rgba(0, 0, 0, 0.25);

    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);

    opacity: 0;
    visibility: hidden;

    transition: all .3s ease;

    z-index: 999998;
}

.chatbot-ai-overlay.active {
    opacity: 1;
    visibility: visible;
}

.products-list {
    display: grid;
    gap: 8px;
    margin-top: 8px;
}

.product-card {
    border: 1px solid var(--cb-border);
    border-radius: 10px;
    padding: 10px 12px;
    background: #f8fafc;
}

.product-card-title {
    font-weight: 700;
    margin-bottom: 4px;
}

.product-card-meta {
    font-size: 13px;
    color: var(--cb-text);
    opacity: 0.9;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 285px));
    justify-content: left;
    gap: 16px;
    margin-top: 12px;
}

.product-card-grid {
    width: 100%;
    max-width: 285px;
    min-height: 385px;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border: 1px solid var(--cb-border);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.product-card-grid:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.08);
}

.product-card-image {
    width: 100%;
    height: 285px;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.product-card-content {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    background: #f2f2f2;
}

.product-card-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--cb-text);
}

.product-card-price {
    font-size: 15px;
    font-weight: 700;
    color: var(--cb-primary);
}

.product-card-sku {
    font-size: 13px;
    color: var(--cb-text);
    opacity: 0.75;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 285px));
    justify-content: left;
    gap: 16px;
    margin-top: 0;
    width: 100%;
}

.product-card-grid {
    width: 100%;
    max-width: 285px;
    min-height: 385px;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border: 1px solid var(--cb-border);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.product-card-grid + .product-card-grid {
    margin-top: 0;
}

/* ======================================
   AI Chat History - My Account
====================================== */


.chatbot-ai-history-wrapper {
    padding: 20px 0;
}


.chatbot-ai-history-wrapper h2 {
    margin-bottom: 10px;
}


.chatbot-ai-history-wrapper h3 {
    margin-bottom: 25px;
}




/* Empty State */

.chatbot-ai-history-empty {

    background: #f8f8f8;
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;

}


.chatbot-ai-empty-icon {

    display: block;
    font-size: 40px;
    margin-bottom: 15px;

}


.chatbot-ai-history-empty p {

    margin: 0;
    color: #666;

}





/* History Cards */

.chatbot-ai-history-list {

    display: flex;
    flex-direction: column;
    gap: 20px;

}



.chatbot-ai-history-card {

    background: #ffffff;
    border: 1px solid #e8e8e8;
    border-radius: 14px;
    padding: 20px;

}



.chatbot-ai-history-date {

    font-size: 14px;
    margin-bottom: 8px;
    color: #555;

}



.chatbot-ai-history-count {

    font-size: 14px;
    margin-bottom: 15px;

}



.chatbot-ai-history-summary {

    background: #f7f7f7;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 15px;

}



.chatbot-ai-history-summary p {

    margin: 8px 0 0;

    color: #555;

}





/* View Button */

.chatbot-ai-view-chat {

    background: #2563eb;
    color: #fff;

    border: none;

    border-radius: 8px;

    padding: 10px 18px;

    cursor: pointer;

    font-size: 14px;

}


.chatbot-ai-view-chat:hover {

    opacity: .9;

}





/* ======================================
   Chat Modal
====================================== */


.chatbot-ai-history-modal {

    display: none;

    position: fixed;

    z-index: 99999;

    top: 0;
    left: 0;

    width: 100%;
    height: 100%;

    background: rgba(0,0,0,.45);

}




.chatbot-ai-history-modal-content {

    background: #fff;

    width: 90%;

    max-width: 650px;

    max-height: 80vh;

    overflow-y: auto;

    margin: 5% auto;

    border-radius: 16px;

    padding: 25px;

    position: relative;

}




.chatbot-ai-history-close {

    position: absolute;

    right: 20px;

    top: 15px;

    border: none;

    background: none;

    font-size: 28px;

    cursor: pointer;

}





/* Messages */


#chatbot-ai-history-messages {

    padding-top: 30px;

}



.chatbot-ai-history-message {

    display: flex;

    margin-bottom: 15px;

}



.chatbot-ai-history-message.user {

    justify-content: flex-end;

}



.chatbot-ai-history-message.bot {

    justify-content: flex-start;

}




.chatbot-ai-history-bubble {

    max-width: 75%;

    padding: 12px 16px;

    border-radius: 14px;

    line-height: 1.5;

    font-size: 14px;

}




.chatbot-ai-history-message.user 
.chatbot-ai-history-bubble {


    background: #111827;

    color: #fff;

    border-bottom-right-radius: 4px;


}



.chatbot-ai-history-message.bot 
.chatbot-ai-history-bubble {


    background: #f1f1f1;

    color: #333;

    border-bottom-left-radius: 4px;


}





.chatbot-ai-history-loading {

    text-align: center;

    padding: 30px;

    color: #666;

}





.chatbot-ai-history-message.has-products {
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    max-width: 100%;
}

.chatbot-ai-history-message.has-products .chatbot-ai-history-bubble {
    max-width: 75%;
    margin-bottom: 10px;
}

.chatbot-ai-history-products {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    width: 100%;
}

.chatbot-ai-history-product-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.chatbot-ai-history-product-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #f8fafc;
    overflow: hidden;
}

.chatbot-ai-history-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.chatbot-ai-history-product-content {
    padding: 10px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chatbot-ai-history-product-name {
    font-size: 13px;
    font-weight: 700;
    color: #1f2937;
}

.chatbot-ai-history-product-price {
    font-size: 14px;
    font-weight: 700;
    color: #0a84ff;
}

.chatbot-ai-history-product-sku {
    font-size: 11px;
    color: #6b7280;
}

@media(max-width:768px){


    .chatbot-ai-history-modal-content {

        width: 95%;

        margin: 10% auto;

    }


    .chatbot-ai-history-bubble {

        max-width: 90%;

    }
}

.chatbot-clear-chat {
    margin-left: auto;
    margin-right: 10px;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.5);
    background: transparent;
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.chatbot-clear-chat:hover {
    background: rgba(255,255,255,0.15);
    border-color: #fff;
}