.ai-shop-widget {
    --ai-accent: #b45309;
    --ai-accent-hover: #92400e;
    --ai-accent-soft: #fff7ed;
    --ai-focus: #f59e0b;
    --ai-surface: #ffffff;
    --ai-surface-soft: #f6f7fb;
    --ai-text: #172033;
    --ai-muted: #526174;
    --ai-border: #dce2ea;
    --ai-shadow: 0 18px 50px rgba(15, 23, 42, .18);
    color: var(--ai-text);
    font-family: Manrope, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.ai-shop-widget.is-baraboy {
    --ai-accent: #0369a1;
    --ai-accent-hover: #075985;
    --ai-accent-soft: #f0f9ff;
    --ai-focus: #0ea5e9;
}

.ai-shop-widget [hidden] {
    display: none !important;
}

.ai-shop-launcher {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1040;
    min-height: 50px;
    padding: 0 18px;
    border: 1px solid rgba(255, 255, 255, .28);
    border-radius: 999px;
    background: var(--ai-accent);
    color: #fff;
    box-shadow: 0 10px 26px rgba(15, 23, 42, .2);
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font: inherit;
    font-weight: 800;
    transition: transform 160ms ease-out, box-shadow 160ms ease-out;
}

.ai-shop-launcher i {
    font-size: 22px;
}

.ai-shop-launcher:hover {
    box-shadow: 0 13px 30px rgba(15, 23, 42, .24);
    transform: translateY(-2px);
}

.ai-shop-launcher:active {
    transform: translateY(0);
}

.ai-shop-launcher:focus-visible,
.ai-shop-widget button:focus-visible,
.ai-shop-widget a:focus-visible,
.ai-shop-widget textarea:focus-visible {
    outline: 3px solid var(--ai-focus);
    outline-offset: 2px;
}

.ai-shop-panel {
    position: fixed;
    right: 20px;
    bottom: 84px;
    z-index: 1060;
    width: min(460px, calc(100vw - 32px));
    height: min(720px, calc(100dvh - 104px));
    min-height: 500px;
    border: 1px solid var(--ai-border);
    border-radius: 20px;
    overflow: hidden;
    background: var(--ai-surface);
    box-shadow: var(--ai-shadow);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto auto auto;
    animation: ai-shop-enter 180ms ease-out;
}

.ai-shop-header {
    min-height: 68px;
    padding: 11px 12px 11px 14px;
    background: #172033;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.ai-shop-identity {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 11px;
}

.ai-shop-identity > span:last-child {
    min-width: 0;
    display: grid;
}

.ai-shop-identity strong {
    overflow: hidden;
    font-size: 15px;
    line-height: 1.3;
    text-overflow: ellipsis;
    text-wrap: balance;
    white-space: nowrap;
}

.ai-shop-identity small {
    margin-top: 3px;
    color: #cbd5e1;
    font-size: 11px;
    line-height: 1.3;
}

.ai-shop-avatar {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    border-radius: 13px;
    background: var(--ai-accent);
    display: grid;
    place-items: center;
    font-size: 23px;
}

.ai-shop-online-dot {
    width: 8px;
    height: 8px;
    margin-right: 4px;
    border-radius: 50%;
    background: #34d399;
    display: inline-block;
}

.ai-shop-header-actions {
    display: flex;
    gap: 6px;
}

.ai-shop-header-actions button {
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 12px;
    background: rgba(255, 255, 255, .08);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 18px;
    transition: background-color 160ms ease-out;
}

.ai-shop-header-actions button:hover {
    background: rgba(255, 255, 255, .16);
}

.ai-shop-messages {
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px 14px 10px;
    background: var(--ai-surface-soft);
    scrollbar-color: #cbd5e1 transparent;
    scrollbar-width: thin;
}

.ai-shop-message-row {
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.ai-shop-message-row.is-user {
    align-items: flex-end;
}

.ai-shop-message {
    max-width: 88%;
    padding: 11px 13px;
    border: 1px solid var(--ai-border);
    border-radius: 16px 16px 16px 5px;
    background: var(--ai-surface);
    color: var(--ai-text);
    box-shadow: 0 3px 12px rgba(15, 23, 42, .05);
    font-size: 13.5px;
    line-height: 1.55;
    text-wrap: pretty;
    white-space: pre-wrap;
}

.is-user .ai-shop-message {
    border-color: var(--ai-accent);
    border-radius: 16px 16px 5px 16px;
    background: var(--ai-accent);
    color: #fff;
}

.ai-shop-product-grid {
    width: 100%;
    margin-top: 10px;
    display: grid;
    gap: 10px;
}

.ai-shop-product-card {
    overflow: hidden;
    border: 1px solid var(--ai-border);
    border-radius: 15px;
    background: var(--ai-surface);
    box-shadow: 0 4px 14px rgba(15, 23, 42, .06);
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
}

.ai-shop-product-card:not(:has(.ai-shop-product-image)) {
    grid-template-columns: 1fr;
}

.ai-shop-product-image {
    width: 96px;
    height: 100%;
    min-height: 152px;
    background: #e2e8f0;
    object-fit: cover;
    object-position: top center;
}

.ai-shop-product-body {
    min-width: 0;
    padding: 11px;
}

.ai-shop-product-code {
    color: var(--ai-accent);
    font-size: 12px;
    line-height: 1.3;
}

.ai-shop-product-title {
    margin: 4px 0 7px;
    overflow: hidden;
    color: var(--ai-text);
    font-size: 12px;
    line-height: 1.45;
    text-wrap: pretty;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.ai-shop-product-price {
    color: var(--ai-text);
    font-size: 13px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.ai-shop-product-tags {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.ai-shop-product-tags span {
    padding: 3px 7px;
    border-radius: 999px;
    background: var(--ai-accent-soft);
    color: var(--ai-text);
    font-size: 9.5px;
    font-weight: 700;
}

.ai-shop-product-actions {
    margin-top: 10px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.ai-shop-product-actions a,
.ai-shop-product-actions button {
    min-width: 0;
    min-height: 38px;
    padding: 0 7px;
    border-radius: 9px;
    font: inherit;
    font-size: 10.5px;
    font-weight: 800;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ai-shop-product-link {
    border: 1px solid var(--ai-border);
    background: var(--ai-surface);
    color: var(--ai-text);
}

.ai-shop-product-similar {
    border: 1px solid var(--ai-border);
    background: var(--ai-surface-soft);
    color: var(--ai-text);
}

.ai-shop-product-buy {
    border: 1px solid var(--ai-accent);
    background: var(--ai-accent);
    color: #fff;
}

.ai-shop-product-buy:hover,
.ai-shop-zalo-button:hover,
.ai-shop-send:hover {
    background: var(--ai-accent-hover);
}

.ai-shop-contact-actions {
    width: 100%;
    margin-top: 10px;
    padding: 11px;
    border: 1px solid var(--ai-border);
    border-radius: 14px;
    background: var(--ai-surface);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.ai-shop-contact-actions strong {
    grid-column: 1 / -1;
    font-size: 12px;
}

.ai-shop-zalo-button {
    min-height: 44px;
    padding: 0 12px;
    border-radius: 10px;
    background: #075eaa;
    color: #fff !important;
    font-size: 12px;
    font-weight: 800;
    text-align: center;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ai-shop-contact-actions .ai-shop-zalo-button:only-of-type {
    grid-column: 1 / -1;
}

.ai-shop-status {
    width: fit-content;
    max-width: 100%;
    min-height: 42px;
    margin-bottom: 14px;
    padding: 9px 12px;
    border: 1px solid var(--ai-border);
    border-radius: 13px;
    background: var(--ai-surface);
    color: var(--ai-muted);
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 12px;
    line-height: 1.35;
}

.ai-shop-typing {
    display: inline-flex;
    gap: 3px;
}

.ai-shop-typing i {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--ai-accent);
    animation: ai-shop-dot 1s infinite ease-in-out;
}

.ai-shop-typing i:nth-child(2) {
    animation-delay: .15s;
}

.ai-shop-typing i:nth-child(3) {
    animation-delay: .3s;
}

.ai-shop-suggestions {
    padding: 8px 11px;
    border-top: 1px solid var(--ai-border);
    background: var(--ai-surface);
    display: flex;
    gap: 7px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
}

.ai-shop-suggestions:empty {
    display: none;
}

.ai-shop-suggestion {
    min-height: 38px;
    padding: 0 12px;
    flex: 0 0 auto;
    border: 1px solid var(--ai-border);
    border-radius: 999px;
    background: var(--ai-surface);
    color: var(--ai-text);
    font: inherit;
    font-size: 10.5px;
    font-weight: 700;
}

.ai-shop-composer {
    padding: 9px 10px 5px;
    border-top: 1px solid var(--ai-border);
    background: var(--ai-surface);
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.ai-shop-composer textarea {
    min-height: 44px;
    max-height: 120px;
    padding: 11px 12px;
    flex: 1;
    resize: none;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    background: var(--ai-surface-soft);
    color: var(--ai-text);
    font: inherit;
    font-size: 13px;
    line-height: 1.4;
}

.ai-shop-composer textarea::placeholder {
    color: #64748b;
}

.ai-shop-composer textarea:disabled {
    cursor: wait;
    opacity: .7;
}

.ai-shop-send,
.ai-shop-stop {
    width: 44px;
    height: 44px;
    padding: 0;
    flex: 0 0 44px;
    border: 0;
    border-radius: 12px;
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 18px;
}

.ai-shop-send {
    background: var(--ai-accent);
}

.ai-shop-stop {
    background: #b91c1c;
}

.ai-shop-note {
    margin: 0;
    padding: 2px 12px 8px;
    background: var(--ai-surface);
    color: var(--ai-muted);
    font-size: 9.5px;
    line-height: 1.35;
    text-align: center;
    text-wrap: pretty;
}

.ai-shop-backdrop {
    display: none;
}

body.ai-shop-open .floating-menu-container {
    display: none !important;
}

[data-theme="dark"] .ai-shop-widget {
    --ai-surface: #111827;
    --ai-surface-soft: #0b1220;
    --ai-text: #f1f5f9;
    --ai-muted: #b6c2d1;
    --ai-border: #334155;
    --ai-shadow: 0 18px 52px rgba(0, 0, 0, .5);
}

[data-theme="dark"] .ai-shop-widget.is-z9 {
    --ai-accent-soft: #2a1a0a;
}

[data-theme="dark"] .ai-shop-widget.is-baraboy {
    --ai-accent-soft: #082f49;
}

[data-theme="dark"] .ai-shop-product-link,
[data-theme="dark"] .ai-shop-product-similar {
    color: var(--ai-text);
}

[data-theme="dark"] .ai-shop-composer textarea {
    border-color: #475569;
}

[data-theme="dark"] .ai-shop-composer textarea::placeholder {
    color: #94a3b8;
}

@keyframes ai-shop-enter {
    from {
        opacity: 0;
        transform: translateY(10px) scale(.985);
    }
}

@keyframes ai-shop-dot {
    0%,
    70%,
    100% {
        opacity: .35;
        transform: translateY(0);
    }

    35% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

@media (max-width: 767.98px) {
    body.ai-shop-open {
        overflow: hidden;
        overscroll-behavior: none;
    }

    .ai-shop-launcher {
        right: 14px;
        bottom: calc(104px + env(safe-area-inset-bottom));
        min-height: 48px;
        padding: 0 15px;
    }

    .ai-shop-panel {
        inset: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom));
        width: auto;
        height: auto;
        min-height: 0;
        border-radius: 18px;
    }

    .ai-shop-backdrop {
        position: fixed;
        inset: 0;
        z-index: 1050;
        background: rgba(2, 6, 23, .64);
        display: block;
    }

    .ai-shop-header {
        min-height: 64px;
        padding: 10px 10px 10px 12px;
    }

    .ai-shop-avatar {
        width: 40px;
        height: 40px;
        flex-basis: 40px;
        border-radius: 12px;
        font-size: 21px;
    }

    .ai-shop-header-actions button {
        width: 44px;
        height: 44px;
    }

    .ai-shop-messages {
        padding: 13px 11px 8px;
    }

    .ai-shop-message {
        max-width: 92%;
        padding: 10px 12px;
        font-size: 14px;
    }

    .ai-shop-product-card {
        grid-template-columns: 88px minmax(0, 1fr);
    }

    .ai-shop-product-image {
        width: 88px;
        min-height: 172px;
    }

    .ai-shop-product-body {
        padding: 10px;
    }

    .ai-shop-product-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ai-shop-product-actions a,
    .ai-shop-product-actions button {
        min-height: 42px;
        font-size: 10.5px;
    }

    .ai-shop-product-buy {
        grid-column: 1 / -1;
    }

    .ai-shop-suggestion {
        min-height: 42px;
    }

    .ai-shop-composer {
        padding: 8px 9px 5px;
    }

    .ai-shop-composer textarea {
        min-height: 46px;
        font-size: 16px;
    }

    .ai-shop-send,
    .ai-shop-stop {
        width: 46px;
        height: 46px;
        flex-basis: 46px;
    }

    .ai-shop-note {
        padding-bottom: max(7px, env(safe-area-inset-bottom));
    }
}

@media (max-width: 380px) {
    .ai-shop-identity strong {
        max-width: 155px;
    }

    .ai-shop-product-card {
        grid-template-columns: 78px minmax(0, 1fr);
    }

    .ai-shop-product-image {
        width: 78px;
    }
}

@media (max-width: 767.98px) and (max-height: 600px) {
    .ai-shop-header {
        min-height: 56px;
    }

    .ai-shop-avatar {
        width: 36px;
        height: 36px;
        flex-basis: 36px;
    }

    .ai-shop-note {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ai-shop-panel,
    .ai-shop-typing i,
    .ai-shop-launcher {
        animation: none !important;
        transition: none !important;
    }
}

@media (prefers-contrast: more) {
    .ai-shop-panel,
    .ai-shop-message,
    .ai-shop-product-card,
    .ai-shop-composer textarea,
    .ai-shop-widget button,
    .ai-shop-widget a {
        border-color: currentColor;
    }
}

