#agtech-chatbot {
    --chatbot-header-bg: #163f7a;
    --chatbot-header-color: #ffffff;
    --chatbot-launcher-bg: #163f7a;
    --chatbot-launcher-color: #ffffff;
    --chatbot-body-bg: #ffffff;
    --chatbot-body-color: #1f2937;
    --chatbot-bot-bg: #e9eef6;
    --chatbot-bot-color: #1f2937;
    --chatbot-user-bg: #163f7a;
    --chatbot-user-color: #ffffff;
    --chatbot-input-bg: #ffffff;
    --chatbot-input-color: #1f2937;
    --chatbot-send-bg: #163f7a;
    --chatbot-send-color: #ffffff;
    --chatbot-product-card-bg: #f8faff;
    --chatbot-product-card-accent: #163f7a;
    --chatbot-product-card-name-color: #111827;
    --chatbot-product-card-price-color: #163f7a;
    --chatbot-add-to-cart-bg: #163f7a;
    --chatbot-add-to-cart-hover-bg: #153b73;
    --chatbot-add-to-cart-color: #ffffff;
    --chatbot-message-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --chatbot-message-font-size: 15px;
    --chatbot-width: 470px;
    --chatbot-height: 560px;
    --chatbot-radius: 22px;
    --chatbot-launcher-size: 72px;
    position: fixed;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.widget-position-bottom_right {
    bottom: 24px;
    right: 24px;
}

.widget-position-bottom_left {
    bottom: 24px;
    left: 24px;
}

.widget-position-top_right {
    top: 24px;
    right: 24px;
}

.widget-position-top_left {
    top: 24px;
    left: 24px;
}

#chatbot-window {
    width: min(var(--chatbot-width), calc(100vw - 32px));
    height: min(var(--chatbot-height), calc(100vh - 48px));
    background: var(--chatbot-body-bg);
    color: var(--chatbot-body-color);
    border-radius: var(--chatbot-radius);
    overflow: hidden;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
    border: 1px solid rgba(15, 23, 42, 0.08);
    display: flex;
    flex-direction: column;
}

#agtech-chatbot:not(.is-open) #chatbot-window {
    display: none;
}

#agtech-chatbot.is-open #chatbot-launcher {
    display: none;
}

#chatbot-teaser {
    width: max-content;
    max-width: min(340px, calc(100vw - 32px));
    background: var(--chatbot-body-bg);
    color: var(--chatbot-body-color);
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: calc(var(--chatbot-radius) - 6px);
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.14);
    padding: 14px 44px 14px 14px;
    position: absolute;
    right: 0;
    bottom: calc(var(--chatbot-launcher-size) + 12px);
    cursor: pointer;
    display: none;
    box-sizing: border-box;
}

#chatbot-teaser-close {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: rgba(15, 23, 42, 0.6);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

#chatbot-teaser-close:hover {
    color: rgba(15, 23, 42, 0.9);
}

.chatbot-teaser-text {
    font-size: 14px;
    line-height: 1.45;
    font-weight: 600;
    white-space: normal;
}

#chatbot-launcher {
    width: var(--chatbot-launcher-size);
    height: var(--chatbot-launcher-size);
    border-radius: 50%;
    border: none;
    background: var(--chatbot-launcher-bg);
    color: var(--chatbot-launcher-color);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.22);
    margin-left: auto;
}

.chatbot-launcher-icon {
    position: relative;
    display: inline-block;
    width: 28px;
    height: 22px;
    border-radius: 7px;
    background: currentColor;
}

.chatbot-launcher-icon::after {
    content: "";
    position: absolute;
    bottom: -4px;
    left: 6px;
    width: 10px;
    height: 10px;
    background: currentColor;
    clip-path: polygon(0 0, 100% 0, 0 100%);
}

.chatbot-launcher-icon span {
    position: absolute;
    left: 6px;
    right: 6px;
    height: 2px;
    border-radius: 999px;
    background: var(--chatbot-launcher-bg);
}

.chatbot-launcher-icon span:first-child {
    top: 7px;
}

.chatbot-launcher-icon span:last-child {
    top: 12px;
}

#chatbot-header {
    background: var(--chatbot-header-bg);
    color: var(--chatbot-header-color);
    padding: 18px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.chatbot-header-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.chatbot-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.12);
    color: var(--chatbot-header-color);
    flex: 0 0 auto;
}

.chatbot-avatar .chatbot-launcher-icon span {
    background: var(--chatbot-header-bg);
}

.chatbot-brand-text {
    min-width: 0;
}

.chatbot-title {
    font-size: 20px;
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.chatbot-status {
    margin-top: 4px;
    font-size: 12px;
    opacity: 0.9;
}

#chatbot-toggle {
    border: none;
    background: transparent;
    color: var(--chatbot-header-color);
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

#chatbot-body {
    display: flex;
    flex-direction: column;
    height: calc(100% - 88px);
    background: var(--chatbot-body-bg);
}

.chatbot-intro {
    padding: 8px 22px 8px;
    font-family: var(--chatbot-message-font-family);
    font-size: var(--chatbot-message-font-size);
    line-height: 1.6;
    color: rgba(31, 41, 55, 0.88);
}

#chatbot-messages {
    flex: 1;
    padding: 8px 22px 18px;
    overflow-y: auto;
}

.chatbot-message {
    margin-bottom: 14px;
    padding: 15px 18px;
    border-radius: 20px;
    max-width: 82%;
    line-height: 1.7;
    font-family: var(--chatbot-message-font-family);
    font-size: var(--chatbot-message-font-size);
    word-break: break-word;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
}

.chatbot-message.user {
    background: var(--chatbot-user-bg);
    color: var(--chatbot-user-color);
    margin-left: auto;
    border-bottom-right-radius: 8px;
}

.chatbot-message.bot {
    background: var(--chatbot-bot-bg);
    color: var(--chatbot-bot-color);
    margin-right: auto;
    border-bottom-left-radius: 8px;
}

.chatbot-message.bot.has-products {
    max-width: 100%;
}

.chatbot-cart-confirmation {
    line-height: 1.6;
}

.chatbot-cart-link {
    display: inline-block;
    margin-top: 4px;
    font-weight: 600;
}

.chatbot-message.bot a {
    color: #1d4ed8;
    text-decoration: underline;
}

.chatbot-message.bot a:hover {
    color: #1e40af;
}

.chatbot-message.bot .chatbot-product-card__link,
.chatbot-message.bot .chatbot-product-card__link:hover,
.chatbot-message.bot .chatbot-product-card__link:focus {
    color: inherit;
    text-decoration: none;
}

.chatbot-message.bot table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 14px;
}

.chatbot-message.bot table th,
.chatbot-message.bot table td {
    padding: 8px;
    text-align: left;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.chatbot-message.bot table th {
    font-weight: 600;
    background: rgba(255, 255, 255, 0.35);
}

.chatbot-product-cards {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin: 10px 0;
    padding: 0 2px;
    font-family: var(--chatbot-message-font-family);
}

.chatbot-product-card {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    overflow: hidden;
    background: linear-gradient(110deg, #ffffff 0%, var(--chatbot-product-card-bg) 100%);
    border: 1px solid rgba(22, 63, 122, 0.12);
    border-left: 3px solid var(--chatbot-product-card-accent);
    border-radius: 12px;
    box-shadow: 0 3px 10px rgba(15, 23, 42, 0.055);
    transition: box-shadow 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}

.chatbot-product-card:hover {
    border-color: var(--chatbot-product-card-accent);
    border-left-color: var(--chatbot-product-card-accent);
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.1);
    transform: translateY(-1px);
}

.chatbot-product-card__link {
    display: flex;
    flex: 1 1 155px;
    min-width: 0;
    align-items: center;
    color: inherit;
}

.chatbot-add-to-cart {
    margin: 6px 8px 6px auto;
    padding: 7px 10px;
    border: 0;
    border-radius: 8px;
    background: var(--chatbot-add-to-cart-bg);
    color: var(--chatbot-add-to-cart-color);
    font: inherit;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 2px 5px color-mix(in srgb, var(--chatbot-add-to-cart-bg) 24%, transparent);
}

.chatbot-add-to-cart:hover,
.chatbot-add-to-cart:focus,
.chatbot-add-to-cart:active {
    background: var(--chatbot-add-to-cart-hover-bg);
    color: var(--chatbot-add-to-cart-color) !important;
}

.chatbot-add-to-cart:disabled {
    cursor: default;
    opacity: 0.7;
}

.chatbot-add-to-cart-status {
    flex-basis: 100%;
    padding: 0 9px 6px;
    color: #166534;
    font-size: 11px;
    line-height: 1.4;
}

.chatbot-add-to-cart-status:empty {
    display: none;
}

.chatbot-add-to-cart-status.is-error {
    color: #b91c1c;
}

.chatbot-product-card__media {
    position: relative;
    width: 56px;
    min-width: 56px;
    height: 56px;
    margin: 5px 0 5px 5px;
    border-radius: 8px;
    background: linear-gradient(145deg, #f1f5fb, #e8eef8);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.chatbot-product-card__media img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.chatbot-product-card__media--empty::after {
    content: "";
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.08);
}

.chatbot-product-card__info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 6px 9px;
    min-width: 0;
}

.chatbot-product-card__name {
    font-size: 11px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--chatbot-product-card-name-color);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.chatbot-product-card__price {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 4px;
}

.chatbot-product-card__price-now {
    font-size: 12px;
    font-weight: 700;
    color: var(--chatbot-product-card-price-color);
}

.chatbot-product-card__price-old {
    font-size: 11px;
    color: #9ca3af;
    text-decoration: line-through;
}

#chatbot-thinking {
    padding: 13px 16px;
    margin: 0 22px 14px;
    display: none;
    background: color-mix(in srgb, var(--chatbot-bot-bg) 88%, #ffffff 12%);
    border-radius: 20px;
    border-bottom-left-radius: 8px;
    color: var(--chatbot-bot-color);
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.05);
}

#chatbot-thinking-text {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--chatbot-message-font-family);
    font-size: var(--chatbot-message-font-size);
    line-height: 1.45;
    font-weight: 600;
}

#chatbot-thinking-text::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--chatbot-header-bg);
    box-shadow: 0 0 0 6px color-mix(in srgb, var(--chatbot-header-bg) 14%, transparent);
    animation: chatbotThinkingPulse 1.5s infinite ease-in-out;
}

@keyframes chatbotThinkingPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.9;
    }
    50% {
        transform: scale(1.15);
        opacity: 0.55;
    }
}

#chatbot-input-container {
    padding: 16px 22px 20px;
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    background: var(--chatbot-body-bg);
}

.chatbot-input-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

#chatbot-input {
    flex: 1;
    padding: 13px 16px;
    border: 1px solid rgba(22, 63, 122, 0.35);
    border-radius: 14px;
    outline: none;
    font-family: var(--chatbot-message-font-family);
    font-size: var(--chatbot-message-font-size);
    background: var(--chatbot-input-bg);
    color: var(--chatbot-input-color);
    transition: border-color 0.2s, box-shadow 0.2s;
    min-width: 0;
}

#chatbot-input::placeholder {
    color: rgba(100, 116, 139, 0.85);
}

#chatbot-input:focus {
    border-color: var(--chatbot-header-bg);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

#chatbot-send {
    min-width: 110px;
    padding: 13px 20px;
    background: var(--chatbot-send-bg);
    color: var(--chatbot-send-color);
    border: none;
    border-radius: 14px;
    cursor: pointer;
    font-weight: 700;
    font-size: 15px;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
}

#chatbot-send:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.16);
}

#chatbot-send:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.chatbot-footer-hint {
    margin-top: 12px;
    font-size: 13px;
    color: #64748b;
}

@media (max-width: 640px) {
    #agtech-chatbot {
        right: 12px;
        left: 12px;
        bottom: 12px;
        top: auto;
    }

    #chatbot-window {
        width: auto;
        height: min(var(--chatbot-height), calc(100vh - 24px));
    }

    #chatbot-launcher {
        margin-left: auto;
    }

    #chatbot-teaser {
        width: min(320px, calc(100vw - 24px));
    }

    .chatbot-title {
        font-size: 24px;
    }

    .chatbot-message {
        max-width: 92%;
    }

    .chatbot-input-row {
        flex-direction: column;
        align-items: stretch;
    }

    #chatbot-send {
        width: 100%;
    }
}

/* === FEEDBACK POPUP (COMPACT TOOLTIP ABOVE LAUNCHER) === */

#chatbot-feedback {
    position: fixed;
    z-index: 10000;
    width: 290px;
    max-width: calc(100vw - 24px);
    background: var(--fb-popup-bg, #ffffff);
    color: var(--fb-title-color, #0f172a);
    border-radius: 16px;
    padding: 16px 14px 14px;
    box-shadow:
        0 18px 40px rgba(15, 23, 42, 0.22),
        0 2px 6px rgba(15, 23, 42, 0.08);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    text-align: left;
    box-sizing: border-box;
    animation: agtechFeedbackPop 0.24s cubic-bezier(0.22, 1.25, 0.5, 1);
}

/* TRIPLE SAFETY for when admin disables feedback popup */
#agtech-chatbot.chatbot-feedback--disabled #chatbot-feedback,
#agtech-chatbot[data-feedback-enabled="0"] #chatbot-feedback,
#agtech-chatbot[data-feedback-enabled="false"] #chatbot-feedback {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transform: scale(0.5) translateY(50px) !important;
    height: 0 !important;
    width: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
    overflow: hidden !important;
}

@keyframes agtechFeedbackPop {
    from { opacity: 0; transform: translateY(6px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0)   scale(1); }
}

.chatbot-feedback__close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--fb-subtitle-color, #94a3b8);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    border-radius: 6px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.chatbot-feedback__close:hover {
    background: #f1f5f9;
    color: var(--fb-title-color, #0f172a);
}

.chatbot-feedback__title {
    margin: 0 24px 2px 0;
    font-size: 14px;
    line-height: 1.3;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--fb-title-color, #0f172a);
}

.chatbot-feedback__subtitle {
    margin: 0 0 10px;
    font-size: 12px;
    line-height: 1.45;
    color: var(--fb-subtitle-color, #64748b);
}

.chatbot-feedback__stars {
    display: inline-flex;
    flex-direction: row-reverse;
    align-items: center;
    justify-content: center;
    gap: 2px;
    margin: 0 0 2px;
    padding: 4px 2px;
    border-radius: 999px;
    background: var(--fb-star-track-bg, #f8fafc);
    width: fit-content;
}

.chatbot-feedback__star {
    appearance: none;
    border: none;
    /* background: transparent; */
    padding: 2px;
    cursor: pointer;
    border-radius: 6px;
    color: var(--fb-star-empty, #cbd5e1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    transition: color 0.12s ease, transform 0.12s ease, background-color 0.12s ease;
}

.chatbot-feedback__star:hover,
.chatbot-feedback__star:focus-visible,
.chatbot-feedback__star.is-hover,
.chatbot-feedback__star.is-filled {
    outline: none;
    background: color-mix(in srgb, var(--fb-star-hover-tile, #f59e0b) 10%, transparent);
}

.chatbot-feedback__star:focus-visible {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--fb-star-hover-tile, #f59e0b) 32%, transparent);
}

@supports not (background: color-mix(in srgb, black 0%, transparent)) {
    .chatbot-feedback__star:hover,
    .chatbot-feedback__star:focus-visible,
    .chatbot-feedback__star.is-hover,
    .chatbot-feedback__star.is-filled {
        background: rgba(245, 158, 11, 0.10);
    }
    .chatbot-feedback__star:focus-visible {
        box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.32);
    }
}

.chatbot-feedback__star.is-hover {
    color: var(--fb-star-filled, #f59e0b);
    transform: translateY(-1px);
}

.chatbot-feedback__star.is-filled {
    color: var(--fb-star-filled, #f59e0b);
    transform: translateY(-1px);
}

.chatbot-feedback__rating-label {
    min-height: 16px;
    margin: 2px 0 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--fb-rating-label-color, #b45309);
    text-align: left;
}

.chatbot-feedback__comment {
    display: block;
    width: 100%;
    resize: vertical;
    min-height: 46px;
    max-height: 140px;
    margin: 0 0 10px;
    padding: 8px 10px;
    border: 1px solid var(--fb-comment-border, #cbd5e1);
    border-radius: 10px;
    background: #ffffff;
    color: var(--fb-title-color, #0f172a);
    font-family: inherit;
    font-size: 12px;
    line-height: 1.45;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
    box-sizing: border-box;
}

.chatbot-feedback__comment::placeholder {
    color: var(--fb-subtitle-color, #94a3b8);
}

.chatbot-feedback__comment:focus {
    border-color: var(--fb-comment-focus, #f59e0b);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--fb-comment-focus, #f59e0b) 15%, transparent);
}

@supports not (box-shadow: color-mix(in srgb, black 0%, transparent)) {
    .chatbot-feedback__comment:focus {
        box-shadow: 0 0 0 3px var(--fb-comment-focus-a15, rgba(245, 158, 11, 0.15));
    }
}

.chatbot-feedback__actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.chatbot-feedback__btn {
    border: none;
    cursor: pointer;
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    transition: background-color 0.15s ease, color 0.15s ease,
        box-shadow 0.15s ease, opacity 0.15s ease, transform 0.1s ease, filter 0.15s ease;
}

.chatbot-feedback__btn--ghost {
    background: transparent;
    color: var(--fb-skip-text, #475569);
    padding: 8px 12px;
}

.chatbot-feedback__btn--ghost:hover {
    background: #f1f5f9;
    color: var(--fb-title-color, #0f172a);
}

.chatbot-feedback__btn--primary {
    flex: 1 1 auto;
    background: var(--fb-submit-bg, #f59e0b);
    color: var(--fb-submit-text, #ffffff);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.24), inset 0 -2px 0 rgba(255,255,255,0.1);
}

.chatbot-feedback__btn--primary:hover:not(:disabled) {
    filter: brightness(0.9) saturate(1.05);
    transform: translateY(-1px);
}

.chatbot-feedback__btn--primary:active:not(:disabled) {
    filter: brightness(0.82) saturate(1.1);
    transform: translateY(0);
    box-shadow: 0 3px 10px rgba(245, 158, 11, 0.24), inset 0 2px 3px rgba(0,0,0,0.18);
}

.chatbot-feedback__btn--primary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    filter: saturate(0.6);
}

.chatbot-feedback__message {
    display: none;
    margin: 8px 0 0;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.45;
}

.chatbot-feedback__message[data-kind="success"] {
    color: var(--fb-message-color, #0e7c3b) !important;
}

.chatbot-feedback__message[data-kind="error"] {
    color: #b30000 !important;
}

.chatbot-feedback__tail {
    position: absolute;
    bottom: -6px;
    width: 14px;
    height: 14px;
    background: var(--fb-popup-bg, #ffffff);
    transform: translateX(-50%) rotate(45deg);
    box-shadow: 2px 2px 6px rgba(15, 23, 42, 0.12);
    border-bottom-right-radius: 2px;
}

@media (max-width: 480px) {
    #chatbot-feedback {
        width: 260px;
        padding: 14px 12px 12px;
        border-radius: 14px;
    }

    .chatbot-feedback__star {
        width: 30px;
        height: 30px;
    }

    .chatbot-feedback__actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }
}
