.chat-bubble {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 300px;
    height: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    cursor: pointer;
    z-index: 1000;

    @media only screen and (max-width: 768px) {
        flex-direction: row;
        justify-content: flex-end;
        gap: 10px;
    }

    .chat-header-avatar {
        display: none;

        @media only screen and (max-width: 768px) {
            display: block;
            width: 35px;
            height: 35px;
            border-radius: 50%;
        }
    }

    .chat-bubble-toggle {
        position: relative;
        background: #5246FF;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: .34s cubic-bezier(0.215, 0.610, 0.355, 1.000);

        @media only screen and (max-width: 768px) {
            width: 35px;
            height: 35px;
        }

        svg {
            transform: rotate(180deg);
            transition: .34s cubic-bezier(0.215, 0.610, 0.355, 1.000);
        }

        &:hover {
            transform: scale(1.1);

            svg {
                /*transform: rotate(180deg);*/
            }
        }
    }

    &.is-open {

        .chat-header-avatar {
            display: none;
        }

        .chat-bubble-toggle {

            svg {
                transform: rotate(0);
            }
        }

    }
}

.chat-container {
    position: fixed;
    bottom: 70px;
    right: 20px;
    width: 300px;
    height: 48px;
    background-color: #f9f9f9;
    border-radius: 20px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    z-index: 1000;
    transition: height .34s cubic-bezier(0.215, 0.610, 0.355, 1.000);
    will-change: height;
    border: 1px solid #ddd;

    @media only screen and (max-width: 768px) {
        height: 0;
        opacity: 0;
    }

    .chat-header {
        background: #5246FF;
        width: 100%;
        height: 48px;
        padding: 9px 10px;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 10px;
        box-sizing: border-box;
        cursor: pointer;

        .chat-header-avatar {
            position: relative;
            width: 30px;
            height: 30px;
            max-width: 30px;
            max-height: 30px;
            min-width: 30px;
            min-height: 30px;
        }

        .chat-header-name {
            font-size: 16px;
            font-weight: 600;
        }
    }

    &.open {
        height: 536px;

        @media only screen and (max-width: 768px) {
            opacity: 1;
        }
    }

    /* Dark Theme Settings */
    &.theme-dark {
        background: #2A2A2A;

        .chat-header-name {
            color: #fff!important;
        }

        .chat-box {
            background: #2A2A2A;
        }

        .chat-message.assistant {
            color: #fff;

            .chat-message-container {
                background: #222;
                color: white;

                * {
                    color: #fff;
                }
            }
        }

        .predefined-questions-message {
            background: #222!important;
            color: white!important;
        }

        .amaya-chat-product-cards {

            .amaya-chat-product-card {

                .amaya-chat-product-title {

                    a {
                        color: #fff!important;
                    }
                }

                .amaya-chat-product-actions {

                    a {
                        border-color: #323232!important;
                        color: #fff!important;

                        &:hover {
                            background: #323232!important;
                        }
                    }
                }
            }
        }

        .input-box {

            input {
                border: 0.8px solid #484848;
                background: #484848;
                color: #fff;
            }
        }

        /* Ensure confirmation message is visible in dark theme */
        .amaya-chat-product-card .amaya-chat-product-actions .amaya-chat-added-msg,
        .chat-message.assistant .amaya-chat-product-card .amaya-chat-product-actions .amaya-chat-added-msg,
        .chat-message.assistant .amaya-chat-product-cards .amaya-chat-product-card .amaya-chat-product-actions .amaya-chat-added-msg {
            color: #00C30C;
        }
    }

    &.theme-light {

        .chat-header-name {
            color: #fff!important;
        }
    }
}

.close-chat-button {
    background: none;
    border: none;
    color: white;
    position: absolute;
    top: 8px;
    right: 10px;
    font-size: 18px;
    cursor: pointer;
    padding: 5px;
}

.chat-box {
    padding: 15px;
    height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    background-color: #f9f9f9;
    gap: 20px;

    .chat-box-date {
        text-align: center;
        font-size: 8px;
        color: #7E7E7E;
        font-weight: normal;
    }
}

.chat-message {
    position: relative;
    display: flex;
    width: 100%;
    max-width: 100%;
    font-size: 12px;
    flex-wrap: wrap;

    .chat-message-container {
        position: relative;
        padding: 8px 10px;
        border-radius: 10px;
        width: 100%;
        font-size: 12px;
        background: #EDEDED;
        display: flex;
        flex-direction: column;
        gap: 20px;

        * {
            margin: 0!important;
        }

        p {
            margin: 5px 0 !important;
            strong {
                font-weight: normal!important;
            }
        }
    }

    .chat-message-time {
        margin: 3px 0 0 39px;
        width: 100%;
        color: #7E7E7E;
        font-size: 8px;
        text-align: left;
    }

    &.user {
        max-width: calc(100% - 30px);

        .chat-message-container {
            background: #5246FF;
            color: white;
        }

        .chat-message-time {
            text-align: right;
            margin: 3px 0 0 0;
        }
    }

    &.assistant {
        align-items: flex-end;
        gap: 4px;

        .chat-message-avatar {
            position: relative;
            width: 26px;
            height: 26px;
            max-width: 26px;
            max-height: 26px;
            min-width: 26px;
            min-height: 26px;
        }

        .chat-message-container {
            width: calc(100% - 50px);
        }
    }
}

.chat-message h1,h2,h3 {
    font-size: 18px;
}

.chat-message h4 {
    font-size: 15px;
}

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

.chat-message.assistant {
    align-self: flex-start;
}

.chat-message.assistant a {
    color: inherit;
    text-decoration: underline;
}

.input-box {
    display: flex;
    width: calc(100% - 20px);
    margin: auto auto 10px auto;

    input {
        width: 100%;
        border-radius: 20px;
        border: 0.8px solid #EEE;
        background: #FFF;
        padding: 11.5px 10px;
        color: #535353;
        font-size: 12px;

        &:focus,
        &:active {
            outline: none;
        }
    }

    button {
        display: none;
    }
}

.input-box button:hover {
    background-color: #006bbf;
    color: white;
}

#predefined-questions-container {
    position: relative;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 4px;

    .chat-header-avatar {
        position: relative;
        width: 26px;
        height: 26px;
        max-width: 26px;
        max-height: 26px;
        min-width: 26px;
        min-height: 26px;
    }

    .predefined-questions-message {
        position: relative;
        border-radius: 10px;
        background: #EDEDED;
        padding: 8px 10px;
        width: 100%;
        font-size: 12px;
        font-style: normal;
        font-weight: 400;
        margin: 0!important;
    }
}

#predefined-questions-container.fade-out {
    opacity: 0;
    transform: translateY(-10px);
}

.amaya-chat-product-cards {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 30px;

    &:before,
    &:after {
        display: none!important;
        content: none!important;
    }
}

.amaya-chat-product-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.amaya-chat-product-image {
    position: relative;
    display: block;
    height: 113px;
    width: 100%;
    border-radius: 6px;

    img {
        width: 100%!important;
        height: 100%!important;
        object-fit: cover!important;
        object-position: center!important;
        border-radius: 6px;
    }
}

.amaya-chat-product-title {
    position: relative;
    display: flex;
    width: 100%!important;
    font-size: 14px!important;
    font-style: normal!important;
    font-weight: 600!important;
}

.amaya-chat-product-title a {
    text-decoration: none;
}

.amaya-chat-product-title a:hover {
    text-decoration: none;
}

.amaya-chat-product-price {
    font-size: 18px!important;
    font-style: normal!important;
    font-weight: 600!important;
    padding-top: 4px!important;
    padding-bottom: 10px!important;
}

.amaya-chat-product-actions {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.amaya-chat-product-actions button,
.amaya-chat-product-actions a {
    width: 100%;
    text-align: center;
    border-radius: 8px;
    background: #5246FF;
    padding: 9px 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px!important;
    font-weight: normal!important;
    line-height: 1!important;
    transition: .34s cubic-bezier(0.215, 0.610, 0.355, 1.000);

    &:hover {
        background: #f9f9f9!important;
        border-color: #f9f9f9!important;
        color: #5246FF!important;
    }
}

.amaya-chat-product-actions a {
    border-radius: 8px!important;
    border: 1px solid #D9D9D9!important;
    background: none!important;
    color: #7E7E7E!important;
    padding: 7px 10px;
    box-sizing: border-box;

    &:hover {
        background: none!important;
        border-color: #5246FF!important;
    }
}

/* Confirmation message when product is added to cart */
/* Default color - can be customized via admin settings or custom CSS */
.amaya-chat-added-msg {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: #00C30C;
}

/* Ensure confirmation message is visible in all contexts with high specificity */
.chat-message.assistant .amaya-chat-product-card .amaya-chat-product-actions .amaya-chat-added-msg,
.chat-message.assistant .amaya-chat-product-cards .amaya-chat-product-card .amaya-chat-product-actions .amaya-chat-added-msg,
.chat-container .amaya-chat-product-card .amaya-chat-product-actions .amaya-chat-added-msg,
.amaya-chat-product-card .amaya-chat-product-actions .amaya-chat-added-msg {
    color: #00C30C;
}

@media (max-width: 600px) {
    .amaya-chat-product-card {
        flex: 0 0 100%;
    }
}

.chat-message.assistant .amaya-chat-product-card,
.chat-message.assistant .amaya-chat-product-card .amaya-chat-product-title,
.chat-message.assistant .amaya-chat-product-card .amaya-chat-product-title a,
.chat-message.assistant .amaya-chat-product-card .amaya-chat-product-price {
    color: #000 !important;
}

/* Ensure confirmation message color is not overridden by parent color rules */
/* Using more specific selector to override parent color rules */
.chat-message.assistant .amaya-chat-product-card .amaya-chat-product-actions .amaya-chat-added-msg,
.chat-message.assistant .amaya-chat-product-cards .amaya-chat-product-card .amaya-chat-product-actions .amaya-chat-added-msg {
    color: #00C30C;
}

.chat-message.assistant .amaya-chat-product-card a:not(.wp-block-button__link) {
    text-decoration: none;
}

.chat-message.assistant .amaya-chat-product-card a.wp-block-button__link,
.chat-message.assistant .amaya-chat-product-card .wp-block-button__link {
    text-decoration: none;
}


/* Center a single card and keep it from stretching edge-to-edge */
.amaya-chat-view-details {
    text-align: center;
}

.chat-container .amaya-chat-product-cards {
    justify-content: center;
}

.chat-container .amaya-chat-product-card {
    flex: 0 1 92%;
    max-width: 340px;
    margin: 0 auto;
}

@media (max-width: 600px) {
    .chat-container .amaya-chat-product-card {
        flex: 0 1 94%;
        max-width: 320px;
    }
}