:root {
    --size-guide-sheet-accent: var(--bs-primary, #4f46e5);
    --size-guide-sheet-surface: #fff;
    --size-guide-sheet-border: rgba(15, 23, 42, .1);
    --size-guide-sheet-text: #172033;
    --size-guide-sheet-muted: #6b7280;
}

.product-guide-card {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    max-width: 100%;
    min-height: 32px;
    padding: 4px 10px;
    color: var(--amin-color-text);
    background: color-mix(in srgb, var(--amin-color-primary) 6%, var(--amin-color-surface));
    border: 1px solid var(--amin-color-border);
    border-inline-start: 2px solid var(--amin-color-primary);
    border-radius: 8px;
    text-decoration: none;
    text-align: center;
    transition: background .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.product-guide-card:hover,
.product-guide-card:focus-visible {
    color: var(--amin-color-text);
    background: color-mix(in srgb, var(--amin-color-primary) 11%, var(--amin-color-surface));
    border-color: var(--amin-color-primary);
    box-shadow: 0 6px 18px color-mix(in srgb, var(--amin-color-primary) 12%, transparent);
    text-decoration: none;
}

.product-guide-card:focus-visible {
    outline: 3px solid var(--amin-button-primary-focus-ring);
    outline-offset: 3px;
}

.product-guide-card:active { background: var(--amin-color-surface-raised); }
.product-guide-card__title { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; line-height: 1.6; overflow-wrap: anywhere; }
.product-guide-card__icon {
    display: grid;
    flex: 0 0 22px;
    height: 22px;
    place-items: center;
    color: inherit;
    background: color-mix(in srgb, var(--amin-color-primary) 12%, var(--amin-color-surface));
    border-radius: 6px;
    font-size: 13px;
}
.product-guide-card__arrow { flex: 0 0 22px; text-align: center; font-size: 10px; }

@media (prefers-reduced-motion: reduce) {
    .product-guide-card { transition: none; }
}

body.size-guide-sheet-is-open {
    overflow: hidden;
}

.size-guide-sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1075;
    background: rgba(8, 15, 29, .58);
    opacity: 0;
    backdrop-filter: blur(2px);
    transition: opacity .28s ease;
}

.size-guide-sheet-backdrop.is-open {
    opacity: 1;
}

.size-guide-sheet {
    --size-guide-sheet-drag-y: 0px;
    position: fixed;
    inset-inline: 0;
    bottom: 0;
    z-index: 1080;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: min(86vh, 820px);
    height: min(86dvh, 820px);
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
    overflow: hidden;
    color: var(--size-guide-sheet-text);
    background: var(--size-guide-sheet-surface);
    border: 1px solid var(--size-guide-sheet-border);
    border-bottom: 0;
    border-radius: 28px 28px 0 0;
    box-shadow: 0 -22px 70px rgba(8, 15, 29, .24);
    transform: translate3d(0, calc(100% + 24px), 0);
    transition: transform .36s cubic-bezier(.22, 1, .36, 1);
    will-change: transform;
}

/* این گونه همان شِل راهنمای انتخاب را برای هات‌اسپات به پنل کم‌ارتفاع،
   محتوایی و اسکرول‌دار تبدیل می‌کند. */
.size-guide-sheet--hotspot {
    height: auto;
    max-height: min(72vh, 650px);
    max-height: min(72dvh, 650px);
}

.size-guide-sheet--loading {
    height: auto;
    min-height: 150px;
    max-height: min(36vh, 260px);
    max-height: min(36dvh, 260px);
    padding: 22px 64px max(22px, env(safe-area-inset-bottom));
}

.size-guide-sheet__loading-close {
    position: absolute;
    top: 24px;
    inset-inline-end: clamp(14px, 3vw, 30px);
    z-index: 3;
}

.size-guide-sheet--hotspot .size-guide-sheet__body {
    flex: 0 1 auto;
}

.hotspot-sheet__rail {
    display: grid;
    grid-auto-columns: minmax(190px, 230px);
    grid-auto-flow: column;
    gap: 14px;
    overflow-x: auto;
    padding: 2px 2px 12px;
    scroll-snap-type: inline mandatory;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
}

.hotspot-sheet__product-card,
.hotspot-sheet__category-card {
    min-width: 0;
    scroll-snap-align: start;
    color: var(--size-guide-sheet-text);
    background: #fff;
    border: 1px solid var(--size-guide-sheet-border);
    border-radius: 16px;
    box-shadow: 0 4px 14px rgba(15, 23, 42, .06);
    overflow: hidden;
}

.hotspot-sheet__product-card { display: flex; flex-direction: column; padding-bottom: 12px; }
.hotspot-sheet__product-image { display: grid; height: 155px; place-items: center; color: var(--size-guide-sheet-muted); background: #f8fafc; }
.hotspot-sheet__product-image img { width: 100%; height: 100%; object-fit: cover; }
.hotspot-sheet__product-card h3 { min-height: 44px; margin: 12px 12px 7px; font-size: 14px; line-height: 1.55; }
.hotspot-sheet__product-card h3 a { color: inherit; text-decoration: none; }
.hotspot-sheet__product-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-height: 24px; margin: 0 12px 12px; }
.hotspot-sheet__product-meta strong { color: var(--size-guide-sheet-accent); font-size: 14px; }
.hotspot-sheet__product-meta small { font-size: 10px; font-weight: 500; }
.hotspot-sheet__product-meta span { font-size: 11px; font-weight: 700; }
.hotspot-sheet__product-meta .is-available { color: #15803d; }
.hotspot-sheet__product-meta .is-unavailable { color: #b91c1c; }
.hotspot-sheet__cta { min-height: 40px; margin: auto 12px 0; padding: 10px; color: var(--amin-button-primary-foreground, #fff); background: var(--amin-button-primary-background, var(--size-guide-sheet-accent)); border-radius: 10px; font-size: 12px; font-weight: 700; text-align: center; text-decoration: none; }
.hotspot-sheet__rail--categories { grid-auto-columns: minmax(132px, 175px); }
.hotspot-sheet__category-card { display: grid; gap: 10px; padding-bottom: 12px; color: inherit; font-size: 13px; text-align: center; text-decoration: none; }
.hotspot-sheet__category-image { display: grid; height: 128px; place-items: center; color: var(--size-guide-sheet-muted); background: #f8fafc; }
.hotspot-sheet__category-image img { width: 100%; height: 100%; object-fit: cover; }
.hotspot-sheet__category-card strong { padding-inline: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hotspot-sheet__state { display: grid; min-height: 112px; place-content: center; gap: 9px; color: var(--size-guide-sheet-muted); text-align: center; }
.hotspot-sheet__state p { margin: 0; }

.ubd-hotspot { padding: 0; border: 0; cursor: pointer; }
.ubd-hotspot:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

.size-guide-sheet.is-open {
    transform: translate3d(0, var(--size-guide-sheet-drag-y), 0);
}

.size-guide-sheet.is-dragging {
    transition: none;
    user-select: none;
}

.size-guide-sheet__container.container {
    width: 100%;
    max-width: 1200px;
    padding-inline: clamp(18px, 3vw, 36px);
}

.size-guide-sheet__drag-handle {
    position: absolute;
    top: 0;
    inset-inline: 0;
    z-index: 2;
    display: flex;
    justify-content: center;
    height: 22px;
    padding-top: 8px;
    cursor: grab;
    touch-action: none;
}

.size-guide-sheet__drag-handle:active {
    cursor: grabbing;
}

.size-guide-sheet__drag-handle span {
    display: block;
    width: 52px;
    height: 5px;
    background: #c7ced9;
    border-radius: 999px;
}

.size-guide-sheet__header {
    flex: 0 0 auto;
    padding-top: 22px;
    background: linear-gradient(180deg, #f8fafc 0%, #fff 100%);
    border-bottom: 1px solid var(--size-guide-sheet-border);
}

.size-guide-sheet__header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 76px;
    gap: 20px;
}

.size-guide-sheet__header--controls-only .size-guide-sheet__header-inner {
    min-height: 54px;
    justify-content: flex-end;
}

.size-guide-sheet__heading {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 14px;
}

.size-guide-sheet__icon {
    display: grid;
    flex: 0 0 46px;
    width: 46px;
    height: 46px;
    place-items: center;
    color: var(--size-guide-sheet-accent);
    background: color-mix(in srgb, var(--size-guide-sheet-accent) 11%, white);
    border-radius: 15px;
    font-size: 20px;
}

.size-guide-sheet__eyebrow {
    display: block;
    margin-bottom: 2px;
    color: var(--size-guide-sheet-muted);
    font-size: 12px;
    font-weight: 600;
}

.size-guide-sheet__title {
    margin: 0;
    overflow: hidden;
    color: var(--size-guide-sheet-text);
    font-size: clamp(18px, 2vw, 24px);
    font-weight: 800;
    line-height: 1.45;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.size-guide-sheet__close {
    display: grid;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    padding: 0;
    place-items: center;
    color: #475569;
    background: #fff;
    border: 1px solid var(--size-guide-sheet-border);
    border-radius: 14px;
    box-shadow: 0 4px 14px rgba(15, 23, 42, .06);
    transition: color .2s ease, border-color .2s ease, transform .2s ease;
}

.size-guide-sheet__close:hover,
.size-guide-sheet__close:focus-visible {
    color: var(--size-guide-sheet-accent);
    border-color: var(--size-guide-sheet-accent);
    transform: translateY(-1px);
}

.size-guide-sheet__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
}

.size-guide-sheet__content {
    padding-block: 28px 36px;
}

.size-guide-sheet__content > :last-child {
    margin-bottom: 0 !important;
}

.size-guide-sheet__footer {
    position: sticky;
    bottom: 0;
    z-index: 3;
    flex: 0 0 auto;
    padding-block: 14px;
    background: var(--amin-color-surface, var(--theme-surface-bg));
    border-top: 1px solid var(--amin-color-border, var(--theme-surface-border));
    box-shadow: 0 -10px 28px color-mix(in srgb, var(--amin-color-text) 8%, transparent);
}

.size-guide-sheet__full-page-link {
    display: flex;
    width: 100%;
    align-items: center;
    min-height: 64px;
    padding: 10px 16px;
    gap: 13px;
    color: var(--amin-button-primary-foreground);
    background: var(--amin-button-primary-background);
    border: 1px solid var(--amin-button-primary-background);
    border-radius: 16px;
    box-shadow: 0 10px 24px color-mix(in srgb, var(--amin-color-primary) 22%, transparent);
    text-decoration: none;
    transition: color .2s ease, background .2s ease, border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.size-guide-sheet__full-page-link:hover,
.size-guide-sheet__full-page-link:focus-visible {
    color: var(--amin-button-primary-hover-foreground);
    background: var(--amin-button-primary-hover-background);
    border-color: var(--amin-button-primary-hover-background);
    box-shadow: 0 12px 30px color-mix(in srgb, var(--amin-color-primary) 28%, transparent);
    transform: translateY(-1px);
}

.size-guide-sheet__full-page-link:focus-visible {
    outline: 3px solid var(--amin-button-primary-focus-ring);
    outline-offset: 2px;
}

.size-guide-sheet__full-page-link:active {
    color: var(--amin-button-primary-active-foreground);
    background: var(--amin-button-primary-active-background);
    border-color: var(--amin-button-primary-active-background);
    transform: translateY(0);
}

.size-guide-sheet__full-page-icon {
    display: grid;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    place-items: center;
    color: inherit;
    background: color-mix(in srgb, currentColor 12%, transparent);
    border: 1px solid color-mix(in srgb, currentColor 22%, transparent);
    border-radius: 12px;
    font-size: 17px;
}

.size-guide-sheet__full-page-copy {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    flex-direction: column;
    gap: 2px;
    line-height: 1.45;
}

.size-guide-sheet__full-page-copy strong {
    font-size: 15px;
    font-weight: 800;
}

.size-guide-sheet__full-page-copy small {
    color: inherit;
    font-size: 11px;
    opacity: .76;
}

.size-guide-sheet__full-page-arrow {
    flex: 0 0 auto;
    margin-inline-start: auto;
    font-size: 13px;
}

.size-guide-sheet__loading {
    display: grid;
    height: 100%;
    min-height: 104px;
    place-content: center;
    gap: 14px;
    color: var(--size-guide-sheet-muted);
    text-align: center;
}

.size-guide-sheet__loading--error {
    min-height: 180px;
}

.size-guide-sheet__retry {
    min-height: 42px;
    padding: 8px 16px;
    color: var(--amin-button-primary-foreground, #fff);
    background: var(--amin-button-primary-background, var(--size-guide-sheet-accent));
    border: 0;
    border-radius: 10px;
    font: inherit;
    font-weight: 700;
}

.size-guide-sheet__retry:focus-visible {
    outline: 3px solid var(--amin-button-primary-focus-ring, var(--size-guide-sheet-accent));
    outline-offset: 3px;
}

.size-guide-sheet .loader {
    --color-1: var(--amin-color-primary, var(--size-guide-sheet-accent, #4f46e5));
    --color-2: color-mix(in srgb, var(--color-1) 18%, transparent);
    --size: 1px;
    position: relative;
    width: calc(16 * var(--size));
    height: calc(16 * var(--size));
    margin-inline: auto;
    background-color: var(--color-1);
    border-radius: 50%;
    box-shadow:
        calc(32 * var(--size)) 0 var(--color-1),
        calc(-32 * var(--size)) 0 var(--color-1);
    animation: size-guide-sheet-loader-flash .5s ease-out infinite alternate;
}

@keyframes size-guide-sheet-loader-flash {
    0% {
        background-color: var(--color-2);
        box-shadow:
            calc(32 * var(--size)) 0 var(--color-2),
            calc(-32 * var(--size)) 0 var(--color-1);
    }
    50% {
        background-color: var(--color-1);
        box-shadow:
            calc(32 * var(--size)) 0 var(--color-2),
            calc(-32 * var(--size)) 0 var(--color-2);
    }
    100% {
        background-color: var(--color-2);
        box-shadow:
            calc(32 * var(--size)) 0 var(--color-1),
            calc(-32 * var(--size)) 0 var(--color-2);
    }
}

@media (max-width: 767.98px) {
    .size-guide-sheet {
        height: 92vh;
        height: 92dvh;
        max-height: calc(100vh - 8px);
        max-height: calc(100dvh - 8px);
        border-radius: 22px 22px 0 0;
    }
    .size-guide-sheet--hotspot { max-height: min(78vh, 640px); max-height: min(78dvh, 640px); }
    .size-guide-sheet--loading { min-height: 132px; max-height: min(32vh, 210px); max-height: min(32dvh, 210px); }
    .hotspot-sheet__rail { grid-auto-columns: minmax(164px, 72vw); gap: 10px; }
    .hotspot-sheet__rail--categories { grid-auto-columns: minmax(126px, 48vw); }
    .hotspot-sheet__product-image { height: 130px; }

    .size-guide-sheet__container.container {
        max-width: none;
        padding-inline: 12px;
    }

    .size-guide-sheet__header-inner {
        min-height: 66px;
        gap: 12px;
    }

    .size-guide-sheet__heading {
        gap: 10px;
    }

    .size-guide-sheet__icon {
        flex-basis: 40px;
        width: 40px;
        height: 40px;
        border-radius: 12px;
        font-size: 18px;
    }

    .size-guide-sheet__title {
        font-size: 17px;
    }

    .size-guide-sheet__close {
        flex-basis: 40px;
        width: 40px;
        height: 40px;
        border-radius: 12px;
    }

    .size-guide-sheet__content {
        padding-block: 18px 26px;
    }

    .size-guide-sheet__footer {
        padding-block: 10px max(10px, env(safe-area-inset-bottom));
    }

    .size-guide-sheet__full-page-link {
        min-height: 60px;
        padding: 8px 12px;
        border-radius: 14px;
    }

    .size-guide-sheet__full-page-icon {
        flex-basis: 38px;
        width: 38px;
        height: 38px;
    }

    .size-guide-sheet__full-page-copy strong {
        font-size: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .size-guide-sheet,
    .size-guide-sheet-backdrop,
    .size-guide-sheet__close {
        transition-duration: .01ms;
    }

    .size-guide-sheet .loader {
        animation: none;
        background-color: var(--color-1);
        box-shadow:
            calc(32 * var(--size)) 0 var(--color-2),
            calc(-32 * var(--size)) 0 var(--color-2);
    }
}
