:root {
    /* ── Top Trendy Blue Brand Theme ── */
    --chat-blue-1: #3f97f4;
    --chat-blue-2: #2d79d8;
    --chat-blue-3: #1f5fae;
    --chat-blue-soft: #eef6ff;
    --chat-blue-border: #cfe4ff;
    --chat-ink: #17324d;
}

/* ==========================================================================
   ✨ TOP TRENDY LIVE CHAT BUTTON (BLUE BRAND THEME)
   ========================================================================== */
.chat-widget-btn {
    position: fixed;
    right: 24px;
    bottom: calc(24px + var(--mobile-bottom-nav-space, 0px));
    width: 54px;
    height: 54px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    background: linear-gradient(135deg, #5CA0F2 0%, #3B82EC 100%);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 10px 28px rgba(59, 130, 236, 0.35), 0 2px 6px rgba(15, 23, 42, 0.08);
    transition: width 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), 
                padding 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), 
                transform 0.2s ease, 
                box-shadow 0.25s ease;
    z-index: 10000;
    overflow: hidden;
    box-sizing: border-box;
}

.chat-widget-btn:not(.open):hover,
.chat-widget-btn:not(.open):focus-visible,
.chat-widget-btn.is-expanding:not(.open) {
    width: 154px;
    padding: 4px 16px 4px 6px;
    justify-content: space-between;
    transform: translateY(-2px);
    box-shadow: 0 14px 34px rgba(59, 130, 236, 0.42), 0 4px 10px rgba(15, 23, 42, 0.12);
}

.chat-btn-label {
    order: 1;
    display: inline-flex;
    align-items: center;
    max-width: 0;
    margin: 0;
    overflow: hidden;
    white-space: nowrap;
    font-size: 13.5px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #FFFFFF;
    opacity: 0;
    transition: max-width 0.24s ease, opacity 0.2s ease, margin 0.24s ease;
    text-shadow: 0 1px 2px rgba(27, 73, 128, 0.4);
}

.chat-widget-btn:not(.open):hover .chat-btn-label,
.chat-widget-btn:not(.open):focus-visible .chat-btn-label,
.chat-widget-btn.is-expanding:not(.open) .chat-btn-label {
    max-width: 90px;
    margin-right: 8px;
    opacity: 1;
}

.chat-btn-icon,
.chat-btn-close {
    order: 0;
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
    color: #FFFFFF;
    box-shadow: 0 2px 6px rgba(27, 73, 128, 0.18);
    transition: transform 0.2s ease;
}

/* Đèn tín hiệu trực tuyến xanh lá cây radar (Live Pulse Indicator) */
.chat-btn-icon::after {
    content: '';
    position: absolute;
    top: 1px;
    right: 1px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #10B981;
    border: 1.5px solid #3B82EC;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.9);
    animation: chatPulseRadar 2.2s infinite ease-out;
}

@keyframes chatPulseRadar {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.85);
    }
    70% {
        box-shadow: 0 0 0 7px rgba(16, 185, 129, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

.chat-btn-icon i,
.chat-btn-close {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.chat-btn-close {
    display: none;
    font-size: 24px;
    line-height: 1;
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.3);
}

.chat-widget-btn.open {
    width: 54px;
    padding: 0;
    justify-content: center;
}

.chat-widget-btn.open .chat-btn-label,
.chat-widget-btn.open:hover .chat-btn-label {
    max-width: 0;
    margin-right: 0;
    opacity: 0;
}

.chat-widget-btn.open .chat-btn-icon {
    display: none;
}

.chat-widget-btn.open .chat-btn-close {
    display: flex;
}

.chat-widget-notif {
    position: absolute;
    top: 5px;
    right: 4px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ef4444;
    border: 2px solid #fff;
    display: none;
}

.chat-widget-notif.show {
    display: block;
}

.chat-widget-window {
    position: fixed;
    right: 24px;
    bottom: calc(98px + var(--mobile-bottom-nav-space, 0px));
    width: min(475px, calc(100vw - 40px));
    max-width: calc(100vw - 40px);
    height: min(730px, calc(100vh - 120px));
    max-height: min(800px, calc(100vh - 120px));
    border-radius: 28px;
    background: linear-gradient(180deg, #f7fbff 0%, #ffffff 100%);
    box-shadow: 0 28px 74px rgba(27, 73, 128, 0.24);
    overflow: hidden;
    display: none;
    flex-direction: column;
    z-index: 9999;
    border: 1px solid rgba(63, 151, 244, 0.16);
}

.chat-widget-window.show {
    display: flex;
    animation: chat-widget-in 0.24s ease;
}

@keyframes chat-widget-in {
    from {
        opacity: 0;
        transform: translateY(18px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.chat-widget-header {
    padding: 18px 20px 16px;
    color: #fff;
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.24), transparent 42%),
        linear-gradient(135deg, var(--chat-blue-1) 0%, var(--chat-blue-3) 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.16);
    position: relative;
}

.chat-widget-header h4 {
    margin: 0;
    font-size: 17px;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: #FFFFFF;
}

.chat-widget-header p {
    margin: 4px 0 0;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-widget-header p::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10B981;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.9);
}

.chat-widget-close {
    position: absolute;
    top: 12px;
    right: 14px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    cursor: pointer;
}

.chat-widget-intro {
    padding: 18px;
    background: #f7fbff;
}

.chat-widget-intro-card {
    border: 1px solid var(--chat-blue-border);
    border-radius: 22px;
    background: #fff;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-widget-intro label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    font-weight: 700;
    color: var(--chat-ink);
}

.chat-widget-intro input,
.chat-widget-input textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--chat-blue-border);
    border-radius: 16px;
    font-size: 14px;
    color: var(--chat-ink);
    box-sizing: border-box;
    background: #fff;
}

.chat-widget-intro input:focus,
.chat-widget-input textarea:focus {
    outline: none;
    border-color: var(--chat-blue-2);
    box-shadow: 0 0 0 4px rgba(63, 151, 244, 0.14);
}

.chat-widget-intro-submit,
.chat-widget-input button {
    border: 0;
    background: linear-gradient(135deg, var(--chat-blue-1) 0%, var(--chat-blue-2) 100%);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(45, 121, 216, 0.28);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.chat-widget-intro-submit:hover,
.chat-widget-input button:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(45, 121, 216, 0.38);
}

.chat-widget-intro-submit {
    border-radius: 999px;
    padding: 12px 18px;
    font-size: 14px;
    font-weight: 800;
}

.chat-widget-content {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
}

.chat-widget-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 16px 16px 10px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.chat-widget-profile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--chat-blue-border);
    border-radius: 20px;
    background: #fff;
}

.chat-widget-profile-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
    color: var(--chat-ink);
}

.chat-widget-profile-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6b8aa8;
}

.chat-widget-profile-copy strong {
    font-size: 14px;
}

.chat-widget-profile-copy span:last-child {
    font-size: 12px;
    color: #5f7894;
}

.chat-widget-profile-edit {
    border: 0;
    background: transparent;
    color: var(--chat-blue-2);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}

.chat-widget-assistant {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.chat-widget-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #dbeeff 0%, #b8d9fb 100%);
    color: var(--chat-blue-3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    flex-shrink: 0;
}

.chat-widget-assistant-bubble {
    background: var(--chat-blue-soft);
    color: var(--chat-ink);
    border-radius: 18px;
    border-top-left-radius: 8px;
    padding: 14px 16px;
    font-size: 14px;
    line-height: 1.55;
    border: 1px solid #d9eafc;
}

.chat-widget-assistant-name {
    font-size: 14px;
    font-weight: 800;
    margin-bottom: 4px;
}

.chat-widget-assistant-bubble p {
    margin: 0;
}

.chat-widget-assistant-bubble p + p {
    margin-top: 4px;
}

.chat-widget-faq-title {
    margin-bottom: 10px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #6b8aa8;
}

.chat-widget-faq-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.chat-widget-faq-item {
    border: 1px solid var(--chat-blue-border);
    border-radius: 16px;
    background: #fff;
    color: #406483;
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.35;
    cursor: pointer;
    transition: all 0.18s ease;
}

.chat-widget-faq-item:hover {
    border-color: var(--chat-blue-2);
    color: var(--chat-blue-2);
    background: var(--chat-blue-soft);
}

.chat-widget-stream {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 4px;
}

.cw-welcome-msg {
    padding: 11px 14px;
    border-radius: 16px;
    background: #fff;
    border: 1px solid var(--chat-blue-border);
    color: #51708f;
    font-size: 13px;
    line-height: 1.45;
}

.chat-widget-msg {
    display: flex;
    flex-direction: column;
    max-width: 82%;
}

.chat-widget-msg.cw-customer {
    align-self: flex-end;
    align-items: flex-end;
}

.chat-widget-msg.cw-bot,
.chat-widget-msg.cw-admin {
    align-self: flex-start;
    align-items: flex-start;
}

.cw-bubble {
    padding: 11px 14px;
    border-radius: 18px;
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
}

.cw-customer .cw-bubble {
    background: linear-gradient(135deg, var(--chat-blue-1) 0%, var(--chat-blue-2) 100%);
    color: #fff;
    border-bottom-right-radius: 6px;
}

.cw-bot .cw-bubble,
.cw-admin .cw-bubble {
    background: #fff;
    color: var(--chat-ink);
    border: 1px solid var(--chat-blue-border);
    border-bottom-left-radius: 6px;
}

.cw-bot-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--chat-blue-soft);
    color: var(--chat-blue-3);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.cw-time {
    display: block;
    margin-top: 6px;
    font-size: 10px;
    opacity: 0.7;
    text-align: right;
}

.cw-customer .cw-time {
    color: rgba(255, 255, 255, 0.82);
}

.cw-typing {
    display: none;
    align-items: center;
    gap: 5px;
    padding: 0 18px 10px;
}

.cw-typing.show {
    display: flex;
}

.cw-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #7fb7f7;
    animation: cw-typing 1s infinite ease-in-out;
}

.cw-typing span:nth-child(2) {
    animation-delay: 0.15s;
}

.cw-typing span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes cw-typing {
    0%, 80%, 100% {
        transform: scale(0.7);
        opacity: 0.55;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.chat-widget-input {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 14px 16px;
    border-top: 1px solid var(--chat-blue-border);
    background: rgba(255, 255, 255, 0.96);
}

.chat-widget-input textarea {
    flex: 1;
    min-height: 22px;
    max-height: 96px;
    resize: none;
}

.chat-widget-input button {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    flex-shrink: 0;
    font-size: 15px;
    box-shadow: 0 10px 22px rgba(45, 121, 216, 0.25);
}

/* Suggestions Container & Chips */
.cw-suggestions-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    margin-bottom: 6px;
    justify-content: flex-start;
    clear: both;
    width: 100%;
}

.cw-suggestion-chip {
    background: #ffffff;
    border: 1.5px solid var(--chat-blue-border);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 13px;
    color: var(--chat-blue-2);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(45, 121, 216, 0.05);
    outline: none;
    text-align: left;
}

.cw-suggestion-chip:hover,
.cw-suggestion-chip:focus-visible {
    background: linear-gradient(135deg, var(--chat-blue-1) 0%, var(--chat-blue-2) 100%);
    color: #ffffff;
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(45, 121, 216, 0.2);
}

/* Product Grid & Cards */
.chat-product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin: 14px 0;
    width: 100%;
    box-sizing: border-box;
    clear: both;
}

.chat-product-card {
    background: #ffffff;
    border: 1px solid rgba(63, 151, 244, 0.12);
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    box-shadow: 0 6px 16px rgba(27, 73, 128, 0.04);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.25s ease;
    box-sizing: border-box;
}

.chat-product-card:hover,
.chat-product-card:focus-visible {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(27, 73, 128, 0.1);
    border-color: var(--chat-blue-1);
}

.chat-product-img-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #f8fafc;
}

.chat-product-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease, opacity 0.25s ease;
}

.chat-product-card:hover .chat-product-img {
    transform: scale(1.05);
}

.chat-product-info {
    padding: 10px 12px 12px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    justify-content: space-between;
    gap: 6px;
}

.chat-product-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--chat-ink);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 35px;
    transition: color 0.2s ease;
}

.chat-product-card:hover .chat-product-name {
    color: var(--chat-blue-2);
}

.chat-product-price {
    font-size: 14px;
    font-weight: 700;
    color: var(--chat-blue-2);
}

/* FAQ Popover and Input Toggle Button */
.chat-widget-faq-toggle {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1.5px solid var(--chat-blue-border);
    background: #ffffff;
    color: var(--chat-blue-2);
    display: none; /* Controlled by JS dynamic visibility */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    flex-shrink: 0;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 10px rgba(45, 121, 216, 0.05);
    box-sizing: border-box;
    outline: none;
    padding: 0;
}

.chat-widget-faq-toggle:hover,
.chat-widget-faq-toggle:focus-visible {
    background: var(--chat-blue-soft);
    border-color: var(--chat-blue-1);
    color: var(--chat-blue-1);
    transform: scale(1.05);
}

.chat-widget-faq-toggle.active {
    background: linear-gradient(135deg, var(--chat-blue-1) 0%, var(--chat-blue-2) 100%);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(45, 121, 216, 0.25);
}

.chat-widget-faq-popover {
    position: absolute;
    bottom: 100%;
    left: 14px;
    right: 14px;
    background: #ffffff;
    border: 1px solid var(--chat-blue-border);
    border-radius: 18px;
    box-shadow: 0 -8px 28px rgba(27, 73, 128, 0.15);
    max-height: 220px;
    overflow-y: auto;
    z-index: 10005;
    padding: 6px 0;
    box-sizing: border-box;
    margin-bottom: 8px;
    display: none;
    scrollbar-width: thin;
    scrollbar-color: rgba(63, 151, 244, 0.2) transparent;
}

/* Custom scrollbar styling for webkit */
.chat-widget-faq-popover::-webkit-scrollbar {
    width: 6px;
}

.chat-widget-faq-popover::-webkit-scrollbar-track {
    background: transparent;
}

.chat-widget-faq-popover::-webkit-scrollbar-thumb {
    background-color: rgba(63, 151, 244, 0.2);
    border-radius: 3px;
}

.chat-widget-faq-popover-item {
    display: block;
    width: 100%;
    background: none;
    border: 0;
    padding: 11px 18px;
    text-align: left;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--chat-ink);
    cursor: pointer;
    box-sizing: border-box;
    transition: all 0.15s ease;
    border-bottom: 1px solid #f1f5f9;
    outline: none;
}

.chat-widget-faq-popover-item:last-child {
    border-bottom: 0;
}

.chat-widget-faq-popover-item:hover,
.chat-widget-faq-popover-item:focus-visible {
    background: var(--chat-blue-soft);
    color: var(--chat-blue-2);
    padding-left: 22px;
}

@media (max-width: 768px) {
    body.public-page-product .chat-widget-btn,
    body.public-page-product .chat-widget-window {
        display: none !important;
    }
}

@media (max-width: 640px) {
    .chat-widget-btn {
        right: 16px;
        bottom: calc(var(--mobile-bottom-nav-space, 68px) + 14px) !important;
        height: 46px !important;
        width: 46px !important;
        min-width: 46px !important;
        padding: 0 !important;
        justify-content: center !important;
        gap: 0 !important;
        background: linear-gradient(135deg, #5CA0F2 0%, #3B82EC 100%) !important;
        border: 1px solid rgba(255, 255, 255, 0.35) !important;
        box-shadow: 0 8px 22px rgba(59, 130, 236, 0.35), 
                    0 2px 6px rgba(15, 23, 42, 0.1) !important;
        border-radius: 50% !important;
        transform: translateY(0) !important;
        transition: width 0.28s cubic-bezier(0.34, 1.56, 0.64, 1),
                    padding 0.28s cubic-bezier(0.34, 1.56, 0.64, 1),
                    border-radius 0.25s ease,
                    box-shadow 0.25s ease,
                    transform 0.2s ease !important;
    }

    .chat-widget-btn:not(.open):hover,
    .chat-widget-btn:not(.open):focus-visible,
    .chat-widget-btn.is-expanding:not(.open) {
        width: 136px !important;
        height: 46px !important;
        padding: 4px 14px 4px 5px !important;
        justify-content: flex-start !important;
        gap: 8px !important;
        border-radius: 999px !important;
        border-color: rgba(255, 255, 255, 0.45) !important;
        box-shadow: 0 10px 28px rgba(59, 130, 236, 0.45), 
                    inset 0 1px 1px rgba(255, 255, 255, 0.45) !important;
        transform: translateY(-1px) !important;
    }

    .chat-widget-btn:active {
        transform: scale(0.95) translateY(1px) !important;
        box-shadow: 0 4px 14px rgba(59, 130, 236, 0.28) !important;
    }

    .chat-widget-btn.open {
        display: none !important;
    }

    .chat-btn-label {
        display: inline-flex !important;
        order: 1 !important;
        max-width: 0 !important;
        margin: 0 !important;
        opacity: 0 !important;
        overflow: hidden !important;
        white-space: nowrap !important;
        font-size: 13px !important;
        font-weight: 700 !important;
        color: #FFFFFF !important;
        letter-spacing: 0.02em !important;
        text-shadow: 0 1px 2px rgba(27, 73, 128, 0.4) !important;
        transition: max-width 0.24s ease, opacity 0.2s ease, margin 0.2s ease !important;
    }

    .chat-widget-btn:not(.open):hover .chat-btn-label,
    .chat-widget-btn:not(.open):focus-visible .chat-btn-label,
    .chat-widget-btn.is-expanding:not(.open) .chat-btn-label {
        max-width: 80px !important;
        margin-right: 4px !important;
        opacity: 1 !important;
        font-size: 13px !important;
        line-height: 1 !important;
        letter-spacing: 0.02em !important;
    }

    .chat-btn-icon {
        order: 0 !important;
        width: 36px !important;
        height: 36px !important;
        font-size: 15px !important;
        background: rgba(255, 255, 255, 0.22) !important;
        border: 1px solid rgba(255, 255, 255, 0.35) !important;
        box-shadow: 0 2px 6px rgba(27, 73, 128, 0.2) !important;
        border-radius: 50% !important;
        flex-shrink: 0 !important;
    }

    .chat-btn-icon i {
        font-size: 14.5px !important;
        color: #FFFFFF !important;
        filter: drop-shadow(0 1px 2px rgba(27, 73, 128, 0.3)) !important;
    }

    .chat-widget-btn:not(.open):hover .chat-btn-icon,
    .chat-widget-btn:not(.open):focus-visible .chat-btn-icon,
    .chat-widget-btn.is-expanding:not(.open) .chat-btn-icon {
        width: 36px !important;
        height: 36px !important;
        background: rgba(255, 255, 255, 0.28) !important;
        border-color: rgba(255, 255, 255, 0.5) !important;
        font-size: 15px !important;
    }

    .chat-widget-window {
        left: 12px !important;
        right: 12px !important;
        width: calc(100vw - 24px) !important;
        max-width: calc(100vw - 24px) !important;
        bottom: calc(max(12px, env(safe-area-inset-bottom, 12px)) + 74px) !important;
        height: calc(100dvh - max(12px, env(safe-area-inset-bottom, 12px)) - 88px - max(12px, env(safe-area-inset-top, 12px))) !important;
        max-height: calc(100dvh - max(12px, env(safe-area-inset-bottom, 12px)) - 88px - max(12px, env(safe-area-inset-top, 12px))) !important;
        border-radius: 24px !important;
        border: 1px solid rgba(63, 151, 244, 0.24) !important;
        box-shadow: 0 16px 44px rgba(15, 23, 42, 0.22), 0 2px 10px rgba(27, 73, 128, 0.1) !important;
        overflow: hidden !important;
        z-index: 10005 !important;
    }

    .chat-widget-header {
        padding: 16px 18px !important;
        border-radius: 24px 24px 0 0 !important;
    }

    .chat-widget-close {
        top: 13px !important;
        right: 14px !important;
    }

    .chat-widget-profile {
        flex-direction: row !important;
        align-items: center !important;
        padding: 12px 14px !important;
    }

    .chat-widget-msg {
        max-width: 90% !important;
    }

    .chat-widget-input {
        border-radius: 0 0 24px 24px !important;
        padding: 10px 14px 12px !important;
        background: #ffffff !important;
    }
}

@media (max-width: 420px) {
    .chat-widget-window {
        left: 8px !important;
        right: 8px !important;
        width: calc(100vw - 16px) !important;
        max-width: calc(100vw - 16px) !important;
        bottom: calc(max(12px, env(safe-area-inset-bottom, 12px)) + 72px) !important;
        border-radius: 20px !important;
    }

    .chat-widget-header {
        border-radius: 20px 20px 0 0 !important;
        padding: 14px 16px !important;
    }

    .chat-widget-input {
        border-radius: 0 0 20px 20px !important;
        padding: 8px 12px 10px !important;
    }

    .chat-widget-scroll {
        padding: 12px 12px 8px;
    }
}

/* Ẩn hoàn toàn Chat Widget trên Mobile ở trang Cart & Checkout */
@media (max-width: 1024px) {
    body.public-page-cart-flow .chat-widget-btn,
    body.public-page-cart-flow #chatWidgetBtn,
    body.public-page-cart-flow .chat-widget-window,
    body.public-page-cart-flow #chatWidgetWindow {
        display: none !important;
        visibility: hidden !important;
        pointer-events: none !important;
        opacity: 0 !important;
    }
}

/* Support contact actions are shown only when verified settings are supplied by the server. */
.cw-support-contacts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 7px 0 3px 20px;
}
.cw-support-contacts a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    background: #fff;
    padding: 7px 11px;
    color: #164e63;
    text-decoration: none;
    font-size: 12px;
    line-height: 1.3;
    font-weight: 650;
}
.cw-support-contacts a:hover,
.cw-support-contacts a:focus-visible {
    border-color: #0891b2;
    outline: 2px solid transparent;
    background: #ecfeff;
}

/* Product Card Actions, Option Selectors & Add to Cart Button */
.chat-product-link {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    flex-grow: 1;
}

.chat-product-link:hover .chat-product-name {
    color: var(--chat-blue-2);
}

.chat-product-actions {
    padding: 0 10px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-product-options {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-product-option-row {
    width: 100%;
}

.chat-product-select {
    width: 100%;
    height: 28px;
    padding: 2px 6px;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--chat-ink, #0f172a);
    background-color: #f8fafc;
    border: 1px solid rgba(63, 151, 244, 0.22);
    border-radius: 7px;
    outline: none;
    cursor: pointer;
    text-overflow: ellipsis;
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    background-position: right 6px center;
    background-repeat: no-repeat;
    background-size: 14px 14px;
    padding-right: 22px;
}

.chat-product-select:focus {
    border-color: var(--chat-blue-1, #2563eb);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
    background-color: #ffffff;
}

.chat-btn-add-cart {
    width: 100%;
    height: 34px;
    padding: 0 10px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    color: #ffffff;
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-shadow: 0 2px 8px rgba(22, 163, 74, 0.28);
    transition: all 0.2s ease;
    user-select: none;
}

.chat-btn-add-cart:hover:not(:disabled) {
    background: linear-gradient(135deg, #15803d 0%, #166534 100%);
    box-shadow: 0 4px 14px rgba(22, 163, 74, 0.38);
    transform: translateY(-1px);
}

.chat-btn-add-cart:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(22, 163, 74, 0.2);
}

.chat-btn-add-cart.loading {
    opacity: 0.85;
    cursor: wait;
}

.chat-btn-add-cart.success,
.chat-btn-add-cart.is-success {
    background: linear-gradient(135deg, #059669 0%, #047857 100%) !important;
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.35) !important;
    color: #ffffff !important;
}

.chat-btn-add-cart.error {
    background: #dc2626 !important;
    color: #ffffff !important;
}

.chat-btn-add-cart-skeleton {
    opacity: 0.6;
    cursor: default;
    background: #94a3b8;
    box-shadow: none;
}
