/* Giới hạn toàn bộ bố cục trong shortcode để không ảnh hưởng đến giao diện cửa hàng. */
div.kcw {
    display: block;
    width: 100%;
    height: auto;
    max-width: 48rem;
    margin: 0 auto;
    padding: 0;
    border: 1px solid #dde1e6;
    border-radius: 16px;
    background: #fff;
    color: #20242b;
    font: 500 15px/1.4 system-ui, sans-serif;
    letter-spacing: normal;
    isolation: isolate;
    box-sizing: border-box;
}

.kcw [hidden] {
    display: none !important;
}

/* Chiều cao riêng giúp Safari dựng canvas trước khi tài nguyên 3D tải xong. */
.kcw .kcw__stage {
    position: relative;
    display: block;
    height: clamp(200px, 43vh, 480px);
    height: clamp(200px, 43svh, 480px);
    min-width: 0;
    margin: 0;
    overflow: hidden;
    border-radius: 15px 15px 0 0;
    background: #f1f3f5;
}

.kcw model-viewer.kcw__viewer {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    background: #f1f3f5;
    --poster-color: transparent;
}

.kcw p.kcw__status {
    position: absolute;
    right: 12px;
    bottom: 12px;
    left: 12px;
    width: fit-content;
    max-width: calc(100% - 24px);
    box-sizing: border-box;
    margin: 0 auto;
    padding: 6px 12px;
    border-radius: 10px;
    background: #fff;
    color: #364152;
    text-align: center;
    pointer-events: none;
}

.kcw .kcw__panel {
    padding: 12px 12px max(12px, env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #dde1e6;
}

.kcw .kcw__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.kcw .kcw__actions:has(> :not([hidden])) {
    margin-bottom: 12px;
}

.kcw .kcw__quick-look,
.kcw .kcw__purchase,
.kcw button.kcw__ar,
.kcw button.kcw__product {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    margin: 0;
    padding: 8px 12px;
    border: 1px solid #d0d5dc;
    border-radius: 10px;
    background: #fff;
    color: #20242b;
    font: 650 14px/1.3 system-ui, sans-serif;
    letter-spacing: normal;
    white-space: normal;
    text-align: center;
    text-transform: none;
    text-decoration: none;
    cursor: pointer;
}

.kcw .kcw__quick-look,
.kcw .kcw__purchase {
    flex: 1 1 auto;
}

.kcw .kcw__quick-look,
.kcw button.kcw__ar {
    border-color: #f1d100;
    background: #ffde02;
    color: #19202a;
}

/* rel="ar" cần một ảnh con duy nhất. Nhãn hiển thị do CSS cung cấp. */
.kcw .kcw__quick-look::after {
    content: "Thử trên cửa (AR)";
}

.kcw .kcw__quick-look img {
    width: 1px;
    height: 1px;
    margin: 0;
}

/* Slot gốc của model-viewer vẫn được dùng cho các thiết bị AR khác. */
.kcw button.kcw__ar {
    position: absolute;
    right: 12px;
    bottom: 12px;
    max-width: calc(100% - 24px);
}

.kcw button.kcw__ar:disabled {
    visibility: hidden;
}

.kcw .kcw__label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    letter-spacing: normal;
}

.kcw .kcw__carousel {
    display: flex;
    align-items: stretch;
    gap: 8px;
    min-width: 0;
    padding: 3px 3px 6px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scroll-padding-inline: 3px;
}

.kcw button.kcw__product {
    flex: 0 0 auto;
    justify-content: flex-start;
    gap: 8px;
    min-width: 0;
    max-width: min(90%, 16rem);
    min-height: 56px;
    text-align: start;
    scroll-snap-align: start;
}

.kcw button.kcw__product[aria-pressed="true"] {
    border-color: #384455;
    background: #eef1f5;
    box-shadow: inset 0 0 0 1px #384455;
}

.kcw .kcw__product span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.kcw .kcw__product img {
    flex: none;
    width: 40px;
    height: 40px;
    margin: 0;
    border-radius: 6px;
    object-fit: contain;
    background: #fff;
}

.kcw :is(a, button):focus-visible {
    outline: 2px solid #1766cc;
    outline-offset: 2px;
}

@media (max-width: 600px) {
    /* Chừa khoảng cuộn dưới khung khi trang có thanh gọi điện cố định. */
    div.kcw {
        margin-bottom: max(64px, env(safe-area-inset-bottom, 0px));
    }
}

.kcw .kcw__faces {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

.kcw .kcw__faces button {
    flex: 1;
    min-height: 44px;
    margin: 0;
    padding: 6px 10px;
    border: 1px solid #d0d5dc;
    border-radius: 10px;
    background: #fff;
    color: #20242b;
    font: 650 14px/1.3 system-ui, sans-serif;
    text-transform: none;
    letter-spacing: normal;
    white-space: normal;
    cursor: pointer;
}

.kcw .kcw__faces button[aria-pressed="true"] {
    border-color: #384455;
    background: #eef1f5;
    box-shadow: inset 0 0 0 1px #384455;
}
