/* Top-Matras Unified Width -> Length Size Picker Popup & Triggers (Desktop + Mobile) */

/* 1. Keep native <select> & FormStyler invisible while preserving DOM geometry & events */
.topm-sz-native-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
}

.jq-selectbox.topm-sz-styler-hidden {
    position: relative !important;
    display: inline !important;
    width: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
}

.jq-selectbox.topm-sz-styler-hidden > .jq-selectbox__select,
.jq-selectbox.topm-sz-styler-hidden > .jq-selectbox__dropdown {
    display: none !important;
}

/* 2. Wrapper & Trigger Button Base */
.topm-sz-wrap {
    position: relative;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.topm-sz-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
    background: #ffffff;
    border: 1.5px solid #c2daf0;
    border-radius: 8px;
    color: #162c43;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    outline: none !important;
    transition: border-color 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease;
}

.topm-sz-trigger:hover,
.topm-sz-trigger:focus {
    border-color: #4aa0d5;
    background: #f5faff;
    box-shadow: 0 2px 8px rgba(74, 160, 213, 0.16);
}

.topm-sz-trigger__left {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    overflow: hidden;
}

.topm-sz-trigger__icon {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    color: #3b93ca;
}

.topm-sz-trigger__label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topm-sz-trigger__right {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}

.topm-sz-trigger__hint {
    font-size: 11.5px;
    font-weight: 600;
    color: #267eb8;
    background: #eaf4fd;
    padding: 2px 8px;
    border-radius: 10px;
    line-height: 1.35;
}

.topm-sz-trigger__chev {
    width: 14px;
    height: 14px;
    color: #3b93ca;
    flex: 0 0 auto;
    transition: transform 0.16s ease;
}

.topm-sz-trigger:hover .topm-sz-trigger__chev {
    transform: translateY(1px);
}

/* Variant A: Product Card / Quick View / Fast Buy */
.topm-sz-wrap--detail {
    display: block;
    width: 100%;
    margin: 4px 0;
}

.sezis-list-xs > div > .topm-sz-wrap--detail,
.sezis-list-xs > div:has(.topm-sz-wrap--detail) {
    width: 100% !important;
}

.topm-sz-wrap--detail .topm-sz-trigger {
    height: 44px !important;
    padding: 0 13px !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    border-radius: 8px !important;
    border: 1.5px solid #b8d5ee !important;
    background: #ffffff !important;
    color: #162c43 !important;
    box-shadow: 0 2px 6px rgba(18, 42, 68, 0.04) !important;
}

.topm-sz-wrap--detail .topm-sz-trigger:hover {
    border-color: #3b93ca !important;
    background: #f7fbff !important;
}

/* Variant B: Filter (Homepage, Catalog Left Sidebar, Inner Pages, Mobile Filter Popup) */
.topm-sz-wrap--filter {
    display: block;
    width: 100%;
}

.topm-sz-wrap--filter .topm-sz-trigger {
    height: 38px !important;
    padding: 0 11px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    border-radius: 7px !important;
    border: 1.5px solid #bcd7ee !important;
    background: #ffffff !important;
    color: #243b53 !important;
}

.topm-sz-wrap--filter.has-active-size .topm-sz-trigger {
    background: #eef7fe !important;
    border-color: #4aa0d5 !important;
    color: #124d77 !important;
    font-weight: 700 !important;
}

.topm-sz-trigger__clear {
    display: none;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(43, 132, 189, 0.16);
    color: #175c8a;
    font-size: 13px;
    line-height: 1;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.14s ease, color 0.14s ease;
}

.topm-sz-wrap--filter.has-active-size .topm-sz-trigger__clear {
    display: inline-flex;
}

.topm-sz-trigger__clear:hover {
    background: #3b93ca;
    color: #ffffff;
}

/* Quick Popular Size Chips under Filter Trigger */
.topm-sz-quick-filter {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
    margin-top: 7px;
}

.topm-sz-quick-chip {
    width: 100%;
    height: 27px;
    padding: 0 6px;
    white-space: nowrap;
    border-radius: 6px;
    border: 1px solid #d5e4f2;
    background: #f8fbff;
    color: #2b4c6b;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.14s ease;
    outline: none !important;
}

.topm-sz-quick-chip:hover {
    border-color: #4aa0d5;
    background: #eaf5fe;
    color: #156092;
}

.topm-sz-quick-chip.is-active {
    background: linear-gradient(90deg, #3b93ca 0%, #4aa0d5 100%);
    border-color: #3b93ca;
    color: #ffffff;
}

/* Variant C: Catalog Product Tiles, Related Products, Favorites, Comparison */
.topm-sz-wrap--tile {
    display: inline-block;
    vertical-align: middle;
}

.sel-size .select-cont .topm-sz-wrap--tile {
    width: auto;
}

.topm-sz-wrap--tile .topm-sz-trigger {
    height: 27px !important;
    min-width: 92px;
    padding: 0 8px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    border-radius: 6px !important;
    border: 1px solid #bfd8ee !important;
    background: #f7fbff !important;
    color: #16324f !important;
    gap: 5px;
}

.topm-sz-wrap--tile .topm-sz-trigger:hover {
    background: #eaf5fe !important;
    border-color: #4aa0d5 !important;
}

.topm-sz-wrap--tile .topm-sz-trigger__icon,
.topm-sz-wrap--tile .topm-sz-trigger__hint {
    display: none !important;
}

.topm-sz-wrap--tile .topm-sz-trigger__chev {
    width: 12px;
    height: 12px;
}

/* Mobile m/ catalog tile trigger (.js-catalog-item-size) */
a.js-catalog-item-size.topm-sz-mob-brief {
    display: inline-flex !important;
    align-items: center;
    gap: 5px;
    padding: 4px 10px !important;
    border-radius: 6px;
    border: 1px solid #bfd8ee;
    background: #f5faff;
    color: #16324f !important;
    font-weight: 700;
    font-size: 13px;
    text-decoration: none !important;
    line-height: 1.25;
}

a.js-catalog-item-size.topm-sz-mob-brief::after {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    border-right: 1.8px solid #3b93ca;
    border-bottom: 1.8px solid #3b93ca;
    transform: rotate(45deg);
    margin-top: -2px;
}

/* 3. Modal Popup (#topm-size-picker-modal) */
body.topm-sz-modal-lock {
    overflow: hidden !important;
}

.topm-sz-modal {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 100200;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.topm-sz-modal.is-open {
    display: flex;
}

.topm-sz-modal__backdrop {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(14, 29, 46, 0.54);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.topm-sz-modal__card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 560px;
    max-height: 88vh;
    background: #ffffff;
    border-radius: 14px;
    border: 1px solid #d7e6f4;
    box-shadow: 0 22px 54px rgba(12, 30, 50, 0.32);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: topmSzPopIn 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes topmSzPopIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.topm-sz-modal__grabber {
    display: none;
    width: 38px;
    height: 4px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.55);
    margin: 7px auto -3px;
}

.topm-sz-modal__head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 13px 16px;
    background: linear-gradient(90deg, #3b93ca 0%, #4aa0d5 100%);
    color: #ffffff;
}

.topm-sz-modal__head-left {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
}

.topm-sz-modal__title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.25;
    color: #ffffff;
}

.topm-sz-modal__current-pill {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 12px;
    background: rgba(11, 48, 78, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.35);
    font-size: 12.5px;
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
}

.topm-sz-modal__close {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    outline: none !important;
    transition: background-color 0.15s ease;
}

.topm-sz-modal__close:hover {
    background: rgba(255, 255, 255, 0.32);
}

/* Scrollable Body */
.topm-sz-modal__body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 14px 16px 16px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* Popular Quick Bar inside Modal */
.topm-sz-modal__popular {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid #e9f1f8;
}

.topm-sz-modal__popular-label {
    font-size: 12px;
    font-weight: 600;
    color: #637b94;
    margin-right: 2px;
}

.topm-sz-modal__pop-btn {
    height: 28px;
    padding: 0 10px;
    border-radius: 14px;
    border: 1px solid #cfe1f1;
    background: #f5faff;
    color: #195d8d;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.14s ease;
    outline: none !important;
}

.topm-sz-modal__pop-btn:hover {
    border-color: #4aa0d5;
    background: #e4f2fd;
}

.topm-sz-modal__pop-btn.is-active {
    background: #3b93ca;
    border-color: #3b93ca;
    color: #ffffff;
}

.topm-sz-modal__pop-btn--reset {
    border-color: #d6dfe8;
    background: #f8fafc;
    color: #486078;
}

.topm-sz-modal__pop-btn--reset:hover {
    border-color: #9ab0c5;
    background: #eef3f7;
    color: #1e354d;
}

/* Step Sections (1. Width -> 2. Length) */
.topm-sz-step {
    margin-bottom: 14px;
}

.topm-sz-step:last-child {
    margin-bottom: 0;
}

.topm-sz-step__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.topm-sz-step__title-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.topm-sz-step__num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #e6f2fc;
    color: #2176ae;
    font-size: 12px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.16s ease, color 0.16s ease;
}

.topm-sz-step.is-current-step .topm-sz-step__num {
    background: linear-gradient(135deg, #3b93ca 0%, #4aa0d5 100%);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(59, 147, 202, 0.3);
}

.topm-sz-step__title {
    font-size: 14px;
    font-weight: 700;
    color: #162c43;
}

.topm-sz-step__sub {
    font-size: 12px;
    font-weight: 500;
    color: #678099;
}

.topm-sz-step.is-current-step .topm-sz-step__sub {
    color: #1d74ad;
    font-weight: 600;
}

/* Dimension Button Grids */
.topm-sz-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
    gap: 7px;
}

.topm-sz-btn {
    height: 38px;
    padding: 0 4px;
    border-radius: 8px;
    border: 1.5px solid #d7e5f2;
    background: #ffffff;
    color: #1e354d;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease, box-shadow 0.14s ease, transform 0.1s ease;
    outline: none !important;
    user-select: none;
}

.topm-sz-btn:hover:not(:disabled) {
    border-color: #4aa0d5;
    background: #eef7fe;
    color: #135c8d;
}

.topm-sz-btn:active:not(:disabled) {
    transform: scale(0.97);
}

.topm-sz-btn.is-selected {
    background: linear-gradient(135deg, #3b93ca 0%, #4aa0d5 100%) !important;
    border-color: #3589bf !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    box-shadow: 0 3px 10px rgba(59, 147, 202, 0.28);
}

.topm-sz-btn.is-current-pair:not(.is-selected) {
    border-color: #4aa0d5;
    background: #f0f8ff;
    color: #156092;
}

.topm-sz-btn:disabled,
.topm-sz-btn.is-disabled {
    background: #f4f7fa !important;
    border-color: #e8eef4 !important;
    color: #b3c2d1 !important;
    cursor: not-allowed !important;
    box-shadow: none !important;
    opacity: 0.65;
}

/* Extra Non-WxL Sizes (if any exist) */
.topm-sz-extra-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.topm-sz-extra-grid .topm-sz-btn {
    padding: 0 12px;
    width: auto;
}

/* Footer (Custom Size Link on Product Card) */
.topm-sz-modal__foot {
    flex: 0 0 auto;
    padding: 11px 16px;
    background: #f7fbff;
    border-top: 1px solid #e4eef7;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.topm-sz-modal__custom-link {
    font-size: 13px;
    font-weight: 600;
    color: #1b6ea5 !important;
    text-decoration: none !important;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.topm-sz-modal__custom-link:hover {
    color: #0f4c75 !important;
    text-decoration: underline !important;
}

/* 4. Mobile Bottom-Sheet Adaptation (<= 767px) */
@media screen and (max-width: 767px) {
    .topm-sz-modal {
        align-items: flex-end;
        padding: 0;
    }

    .topm-sz-modal__card {
        max-width: 100%;
        max-height: 88vh;
        border-radius: 18px 18px 0 0;
        border-bottom: none;
        animation: topmSzSheetUp 0.22s cubic-bezier(0.22, 1, 0.36, 1);
    }

    @keyframes topmSzSheetUp {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }

    .topm-sz-modal__grabber {
        display: block;
    }

    .topm-sz-modal__head {
        flex-direction: column;
        align-items: stretch;
        padding: 4px 14px 11px;
        gap: 6px;
    }

    .topm-sz-modal__head-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
    }

    .topm-sz-modal__title {
        font-size: 15px;
    }

    .topm-sz-modal__body {
        padding: 12px 14px 16px;
    }

    .topm-sz-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 6px;
    }

    .topm-sz-btn {
        height: 40px;
        font-size: 13px;
    }

    .topm-sz-modal__foot {
        padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
    }
}

@media screen and (min-width: 768px) {
    .topm-sz-modal__head-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        gap: 10px;
    }
}

@media screen and (max-width: 359px) {
    .topm-sz-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}
