/* Slide kích thước sản phẩm — gallery trang chi tiết */
.pd-dim {
    --pd-dim-line: #8a8f96;
    --pd-dim-ink: #4b5563;
    --pd-dim-mute: #64748b;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    min-height: 0;
    background: #fff;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 8px 8px;
    box-sizing: border-box;
}
.pd-dim-caption {
    flex: 0 0 auto;
    margin: 0 6px;
    font-size: 12px;
    font-weight: 700;
    color: #475569;
    text-align: center;
    letter-spacing: .01em;
}
.pd-dim-caption span { font-weight: 600; color: var(--pd-dim-mute); }
.pd-dim-frame {
    position: relative;
    flex: 0 0 auto;
    min-height: 0;
    margin: 0;
    padding: 4px 8px 2px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}
.pd-dim-stage {
    position: relative;
    flex: none;
    padding: 6px 58px 48px 42px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pd-dim-note {
    flex: 0 0 auto;
    margin: 0 10px;
    font-size: 11px;
    font-weight: 600;
    color: var(--pd-dim-mute);
    text-align: center;
    line-height: 1.35;
    max-width: 92%;
}
.pd-dim-note i { color: #3b82f6; margin-right: 4px; }

/* Khối máy góc ¾ — kích thước mặc định vừa khung gallery (~420px) */
.pd-rf {
    --w: 96px;
    --h: 230px;
    --pd-side: 40px;
    display: flex;
    align-items: stretch;
    width: fit-content;
    height: var(--h);
    position: relative;
    overflow: visible;
    filter: drop-shadow(0 10px 14px rgba(15, 23, 42, .18));
}
.pd-rf-body {
    position: relative;
    z-index: 1;
    width: var(--w);
    flex: none;
    height: 100%;
    background: linear-gradient(90deg, #8b939e 0%, #c5cad1 22%, #9aa3ae 55%, #d0d5dc 100%);
    border-radius: 0 8px 8px 0;
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .35),
                inset 0 0 0 1px rgba(15, 23, 42, .12);
}
.pd-rf-side {
    width: var(--pd-side, 40px);
    flex: none;
    position: relative;
    clip-path: polygon(0 8%, 100% 0, 100% 100%, 0 93%);
    background: linear-gradient(90deg, #5c6570 0%, #7a8490 55%, #4a5360 100%);
    margin-right: -1px;
}
.pd-rf-side::after {
    content: "";
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(255, 255, 255, .28);
}

/* Tủ lạnh 2 cánh */
.pd-rf--tu-lanh .pd-rf-top,
.pd-rf--tu-lanh .pd-rf-bot {
    position: absolute;
    left: 0;
    right: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, .22), transparent 28%, rgba(15, 23, 42, .18));
}
.pd-rf--tu-lanh .pd-rf-top { top: 0; height: 34%; border-bottom: 1px solid rgba(15, 23, 42, .2); }
.pd-rf--tu-lanh .pd-rf-bot { top: 34%; bottom: 0; }
.pd-rf--tu-lanh .pd-rf-mid {
    position: absolute;
    left: 8%;
    right: 18%;
    top: 34%;
    height: 1px;
    background: rgba(15, 23, 42, .22);
    z-index: 2;
}
.pd-rf--tu-lanh .pd-rf-handle {
    position: absolute;
    right: 10px;
    width: 5px;
    border-radius: 2px;
    background: linear-gradient(90deg, #6b7280, #f1f5f9 45%, #64748b);
    box-shadow: 0 0 0 1px rgba(15, 23, 42, .25);
}
.pd-rf--tu-lanh .pd-rf-handle.t { top: 22%; height: 38%; }
.pd-rf--tu-lanh .pd-rf-handle.b { top: 18%; height: 48%; }

/* Máy giặt — khối vuông + cửa tròn */
.pd-rf--may-giat {
    --w: 120px;
    --h: 136px;
    --pd-side: 34px;
}
.pd-rf--may-giat .pd-rf-body { border-radius: 0 12px 12px 0; }
.pd-rf--may-giat .pd-rf-door {
    position: absolute;
    left: 50%;
    top: 52%;
    transform: translate(-50%, -50%);
    width: 68%;
    aspect-ratio: 1;
    border-radius: 50%;
    border: 6px solid #64748b;
    background: radial-gradient(circle at 35% 30%, #cbd5e1 0%, #64748b 55%, #334155 100%);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .2);
}
.pd-rf--may-giat .pd-rf-panel {
    position: absolute;
    left: 10%;
    right: 10%;
    top: 8%;
    height: 12%;
    border-radius: 4px;
    background: linear-gradient(180deg, #94a3b8, #64748b);
}

/* Điều hòa — khối ngang thấp */
.pd-rf--dieu-hoa {
    --w: 168px;
    --h: 60px;
    --pd-side: 30px;
}
.pd-rf--dieu-hoa .pd-rf-side { clip-path: polygon(0 12%, 100% 0, 100% 100%, 0 88%); }
.pd-rf--dieu-hoa .pd-rf-body { border-radius: 0 10px 10px 0; }
.pd-rf--dieu-hoa .pd-rf-vent {
    position: absolute;
    left: 8%;
    right: 8%;
    bottom: 18%;
    height: 28%;
    border-radius: 3px;
    background: repeating-linear-gradient(
        180deg,
        #94a3b8 0 3px,
        #64748b 3px 6px
    );
    opacity: 1;
}
.pd-rf--dieu-hoa .pd-rf-logo-bar {
    position: absolute;
    left: 12%;
    top: 14%;
    width: 28%;
    height: 10%;
    border-radius: 2px;
    background: rgba(15, 23, 42, .18);
}

/* Máy nước nóng — đứng hẹp */
.pd-rf--may-nuoc-nong {
    --w: 74px;
    --h: 210px;
    --pd-side: 32px;
}
.pd-rf--may-nuoc-nong .pd-rf-body { border-radius: 0 14px 14px 0; }
.pd-rf--may-nuoc-nong .pd-rf-cap {
    position: absolute;
    left: 12%;
    right: 12%;
    top: 6%;
    height: 10%;
    border-radius: 6px;
    background: linear-gradient(180deg, #cbd5e1, #64748b);
}
.pd-rf--may-nuoc-nong .pd-rf-gauge {
    position: absolute;
    left: 50%;
    top: 42%;
    transform: translate(-50%, -50%);
    width: 42%;
    aspect-ratio: 1;
    border-radius: 50%;
    border: 3px solid #94a3b8;
    background: #475569;
}

/* Vạch kích thước — neo theo --w/--h của .pd-rf */
.pd-dim-h,
.pd-dim-w,
.pd-dim-d {
    position: absolute;
    pointer-events: none;
}
.pd-dim-h {
    top: 0;
    left: calc(var(--pd-side, 52px) + var(--w) + 10px);
    width: 58px;
    height: var(--h);
}
.pd-rf--tu-lanh { --w: 96px; --h: 230px; --pd-side: 40px; }

.pd-dim-h .shaft {
    position: absolute;
    left: 5px;
    top: 8px;
    bottom: 8px;
    width: 0;
    border-left: 1.25px solid var(--pd-dim-line);
}
.pd-dim-h .shaft::before,
.pd-dim-h .shaft::after,
.pd-dim-w .shaft::before,
.pd-dim-w .shaft::after,
.pd-dim-d .shaft::before,
.pd-dim-d .shaft::after {
    content: "";
    position: absolute;
    width: 0;
    height: 0;
}
.pd-dim-h .shaft::before {
    left: -4.5px;
    top: -8px;
    border-left: 4.5px solid transparent;
    border-right: 4.5px solid transparent;
    border-bottom: 8px solid var(--pd-dim-line);
}
.pd-dim-h .shaft::after {
    left: -4.5px;
    bottom: -8px;
    border-left: 4.5px solid transparent;
    border-right: 4.5px solid transparent;
    border-top: 8px solid var(--pd-dim-line);
}
.pd-dim-w {
    left: var(--pd-side, 52px);
    top: calc(var(--h) + 14px);
    width: var(--w);
    height: 44px;
}
.pd-dim-w .shaft {
    position: absolute;
    left: 0;
    right: 0;
    top: 6px;
    border-top: 1.25px solid var(--pd-dim-line);
}
.pd-dim-w .shaft::before {
    left: 0;
    top: -4.5px;
    border-top: 4.5px solid transparent;
    border-bottom: 4.5px solid transparent;
    border-right: 8px solid var(--pd-dim-line);
}
.pd-dim-w .shaft::after {
    right: 0;
    top: -4.5px;
    border-top: 4.5px solid transparent;
    border-bottom: 4.5px solid transparent;
    border-left: 8px solid var(--pd-dim-line);
}
.pd-dim-d {
    left: -8px;
    top: calc(var(--h) - 10px);
    width: 64px;
    height: 40px;
    transform: rotate(25deg);
    transform-origin: 54px 8px;
}
.pd-dim-d .shaft {
    position: absolute;
    left: 2px;
    right: 4px;
    top: 8px;
    border-top: 1.25px solid var(--pd-dim-line);
}
.pd-dim-d .shaft::before {
    left: 0;
    top: -4.5px;
    border-top: 4.5px solid transparent;
    border-bottom: 4.5px solid transparent;
    border-right: 8px solid var(--pd-dim-line);
}
.pd-dim-d .shaft::after {
    right: 0;
    top: -4.5px;
    border-top: 4.5px solid transparent;
    border-bottom: 4.5px solid transparent;
    border-left: 8px solid var(--pd-dim-line);
}
.pd-dim-pill {
    display: inline-block;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    padding: 2px 8px;
    box-shadow: 0 2px 10px rgba(15, 23, 42, .08);
    white-space: nowrap;
    font-size: 12px;
    font-weight: 700;
    color: var(--pd-dim-ink);
    line-height: 1.3;
}
.pd-dim-h .pd-dim-pill {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
}
.pd-dim-w .pd-dim-pill {
    position: absolute;
    left: 50%;
    top: 12px;
    transform: translateX(-50%);
}
.pd-dim-d .pd-dim-pill {
    position: absolute;
    left: 50%;
    top: 12px;
    transform: translateX(-50%);
}

/* Overlay kích thước — cùng khung với ảnh sản phẩm, nội dung căn giữa */
.pd-dim-overlay {
    display: none;
    z-index: 5;
    align-items: center;
    justify-content: center;
    background: #fff;
    overflow: hidden;
    padding: 0;
    box-sizing: border-box;
    container-type: size;
    container-name: pddim;
    pointer-events: none;
    cursor: zoom-in;
}
.pd-dim-overlay.is-on {
    display: flex;
}
.pd-dim-overlay.dim-current {
    position: relative;
    width: 100%;
    pointer-events: auto;
    z-index: 6;
}
.main-image-track > .pd-dim-overlay.dim-current {
    height: 420px;
    min-height: 420px;
    max-height: 420px;
}
.pd-dim-overlay.dim-prev,
.pd-dim-overlay.dim-next {
    position: absolute;
    top: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: none;
}
.pd-dim-overlay.dim-prev {
    right: calc(100% + var(--slide-gap, 16px));
    left: auto;
}
.pd-dim-overlay.dim-next {
    left: calc(100% + var(--slide-gap, 16px));
    right: auto;
}

/* Ảnh 1×1 trong suốt không được chiếm layout khi đang xem mô hình */
.main-product-image-container.is-showing-dim .main-slide.is-current {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-height: none;
    opacity: 0;
    pointer-events: none;
}
.main-product-image-container.is-showing-dim > .arrow {
    visibility: visible;
    pointer-events: auto;
    z-index: 8;
}

#image-modal .modal-image-wrap.is-showing-dim .modal-slide.is-current {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-height: none;
    opacity: 0;
    pointer-events: none;
    margin: 0;
}
#image-modal .modal-image-wrap.is-showing-dim .modal-topbar .modal-hd-btn,
#image-modal .modal-image-wrap.is-showing-dim .modal-hd-status {
    display: none !important;
}
/* Wrap phải có kích thước thật: ảnh hiện tại đang opacity 0 nên không còn đẩy layout */
#image-modal .modal-image-wrap.is-showing-dim {
    width: min(520px, calc(100vw - 24px));
    height: min(90vh, 100dvh);
    max-width: min(520px, calc(100vw - 24px));
    max-height: min(90vh, 100dvh);
}
#image-modal .modal-image-wrap.is-showing-dim .modal-track {
    width: 100%;
    height: 100%;
}

/* Lightbox: mô hình cùng sân tối với ảnh — bỏ card trắng */
#image-modal .pd-dim-overlay {
    background: transparent;
    overflow: visible;
}
#image-modal .pd-dim-overlay.dim-current {
    background: transparent;
    border-radius: 0;
    position: relative;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    min-height: 0;
    margin: 0;
}
#image-modal .pd-dim-overlay.dim-prev,
#image-modal .pd-dim-overlay.dim-next {
    background: transparent;
}
#image-modal .pd-dim {
    background: transparent;
    overflow: visible;
    --pd-dim-line: #cbd5e1;
    --pd-dim-ink: #1e293b;
    --pd-dim-mute: #94a3b8;
}
#image-modal .pd-dim-caption {
    color: #e2e8f0;
}
#image-modal .pd-dim-caption span {
    color: #94a3b8;
}
#image-modal .pd-dim-note {
    color: #94a3b8;
}
#image-modal .pd-dim-note i {
    color: #60a5fa;
}
#image-modal .pd-dim-pill {
    background: #fff;
    border-color: #e2e8f0;
    color: #1e293b;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .35);
}
/* Lightbox: cùng xám bạc với gallery; chỉ tăng bóng trên nền tối */
#image-modal .pd-rf {
    filter: drop-shadow(0 10px 24px rgba(0, 0, 0, .5))
            drop-shadow(0 0 1px rgba(255, 255, 255, .35));
}

/* Scale theo chiều cao khung (gallery / lightbox) — mô hình chiếm phần lớn khung như ảnh */
@supports (height: 1cqh) {
    .pd-dim-caption {
        font-size: clamp(10px, 2.6cqh, 12px);
    }
    .pd-dim-note {
        font-size: clamp(9.5px, 2.4cqh, 11px);
    }
    .pd-dim-stage {
        padding: 4px clamp(34px, 11cqw, 58px) clamp(36px, 10cqh, 52px) clamp(28px, 9cqw, 42px);
    }
    .pd-rf--tu-lanh {
        --h: clamp(148px, 62cqh, 286px);
        --w: calc(var(--h) * 96 / 230);
        --pd-side: calc(var(--h) * 40 / 230);
    }
    .pd-rf--may-giat {
        --h: clamp(108px, 46cqh, 176px);
        --w: calc(var(--h) * 120 / 136);
        --pd-side: calc(var(--h) * 34 / 136);
    }
    .pd-rf--dieu-hoa {
        --h: clamp(48px, 18cqh, 72px);
        --w: calc(var(--h) * 168 / 60);
        --pd-side: calc(var(--h) * 30 / 60);
    }
    .pd-rf--may-nuoc-nong {
        --h: clamp(140px, 56cqh, 240px);
        --w: calc(var(--h) * 74 / 210);
        --pd-side: calc(var(--h) * 32 / 210);
    }
    .pd-dim-h {
        width: clamp(44px, 11cqw, 58px);
    }
    .pd-dim-pill {
        font-size: clamp(10.5px, 2.6cqh, 12.5px);
        padding: 2px 7px;
    }
    /* Lightbox: phóng mô hình gần cỡ ảnh máy */
    #image-modal .pd-rf--tu-lanh {
        --h: clamp(220px, 58cqh, 420px);
        --w: calc(var(--h) * 96 / 230);
        --pd-side: calc(var(--h) * 40 / 230);
    }
    #image-modal .pd-rf--may-giat {
        --h: clamp(160px, 48cqh, 280px);
        --w: calc(var(--h) * 120 / 136);
        --pd-side: calc(var(--h) * 34 / 136);
    }
    #image-modal .pd-rf--dieu-hoa {
        --h: clamp(64px, 20cqh, 100px);
        --w: calc(var(--h) * 168 / 60);
        --pd-side: calc(var(--h) * 30 / 60);
    }
    #image-modal .pd-rf--may-nuoc-nong {
        --h: clamp(200px, 54cqh, 380px);
        --w: calc(var(--h) * 74 / 210);
        --pd-side: calc(var(--h) * 32 / 210);
    }
    #image-modal .pd-dim-caption {
        font-size: clamp(11px, 2.2cqh, 14px);
    }
    #image-modal .pd-dim-note {
        font-size: clamp(10px, 2cqh, 12px);
    }
    #image-modal .pd-dim-stage {
        padding: 6px clamp(40px, 12cqw, 72px) clamp(44px, 11cqh, 64px) clamp(32px, 10cqw, 52px);
    }
}

.thumbnail-images .thumb-dim {
    width: 64px;
    height: 64px;
    box-sizing: border-box;
    border-radius: 6px;
    border: 2px solid transparent;
    background: #eef4ff;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding: 2px;
    color: #334155;
    flex: none;
    flex-shrink: 0;
    overflow: hidden;
    line-height: 1.1;
}
.thumbnail-images .thumb-dim.active {
    border-color: #0d6efd;
}
.thumbnail-images .thumb-dim span {
    font-size: 8px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #64748b;
}
.thumbnail-images .thumb-dim b {
    font-size: 9px;
    font-weight: 800;
    line-height: 1.15;
    text-align: center;
}

@media (max-width: 767.98px) {
    .main-image-track > .pd-dim-overlay.dim-current {
        height: 260px;
        min-height: 260px;
        max-height: 260px;
    }
    .pd-dim { padding: 4px 4px 6px; gap: 0; }
    .pd-dim-caption { font-size: 11px; }
    .pd-dim-stage { padding: 2px 44px 40px 32px; }
    .pd-rf--tu-lanh { --w: 68px; --h: 152px; --pd-side: 26px; }
    .pd-rf--may-giat { --w: 96px; --h: 110px; --pd-side: 26px; }
    .pd-rf--dieu-hoa { --w: 132px; --h: 48px; --pd-side: 22px; }
    .pd-rf--may-nuoc-nong { --w: 56px; --h: 148px; --pd-side: 24px; }
    .pd-dim-pill { font-size: 10.5px; padding: 2px 6px; }
    .pd-dim-note { font-size: 10px; margin-top: 2px; }
    #image-modal .modal-image-wrap.is-showing-dim {
        width: 100vw;
        max-width: 100vw;
        height: min(100vh, 100dvh);
        max-height: min(100vh, 100dvh);
    }
}
