/**
 * Mobile popup сортировки и общий каркас mobile filters overlay.
 * Внешний вид попапа сортировки общий для категории, каталога и продавца.
 */
.mobile-filter-icons {
    display: none;
}

.listing-mobile-filters-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: linear-gradient(135deg, #ff6b8f 0%, #ff3d6d 100%);
    box-shadow: 0 8px 14px rgba(255, 61, 109, 0.28);
    border-radius: 50%;
    padding: 2px 6px;
    font-size: 10px;
    line-height: 1;
    display: none;
    min-width: 16px;
    text-align: center;
    color: #fff;
}

.mobile-sort-popup {
    position: fixed;
    inset: 0 0 0 0;
    z-index: 10001;
    display: none;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.mobile-sort-popup.show {
    display: block;
}

.mobile-sort-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(3, 8, 22, 0.72);
    backdrop-filter: blur(6px);
}

.mobile-sort-content {
    position: absolute;
    bottom: var(--mobile-menu-height, 68px);
    left: 12px;
    right: 12px;
    border: 1px solid rgba(109, 145, 238, 0.18);
    border-radius: 24px;
    background: linear-gradient(160deg, rgba(7, 15, 38, 0.98) 0%, rgba(13, 25, 58, 0.95) 52%, rgba(9, 18, 42, 0.98) 100%);
    box-shadow: 0 24px 42px rgba(4, 10, 27, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    max-height: calc(100vh - var(--mobile-menu-height, 68px) - 20px);
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.mobile-sort-content::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(112, 241, 255, 0.12), transparent 28%), linear-gradient(320deg, rgba(87, 102, 255, 0.14), transparent 34%);
    pointer-events: none;
}

.mobile-sort-popup.show .mobile-sort-content {
    transform: translateY(0);
}

.mobile-sort-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px;
    border-bottom: 1px solid rgba(109, 145, 238, 0.18);
    background: rgba(7, 15, 38, 0.72);
}

.mobile-sort-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #f4f7ff;
    letter-spacing: 0.12em;
}

.mobile-sort-close {
    width: 40px;
    height: 40px;
    border: 1px solid rgba(127, 156, 228, 0.2);
    border-radius: 12px;
    background: rgba(10, 18, 42, 0.72);
    color: #d7e2ff;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.mobile-sort-close:hover {
    border-color: rgba(103, 236, 255, 0.3);
    background: rgba(19, 34, 74, 0.92);
    color: #f4f7ff;
}

.mobile-sort-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 20px;
}

.mobile-sort-item {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    margin-bottom: 8px;
    padding: 12px 14px;
    border: 1px solid rgba(121, 157, 242, 0.16);
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(17, 29, 63, 0.86) 0%, rgba(11, 19, 43, 0.92) 100%);
}

.mobile-sort-item:last-child {
    margin-bottom: 0;
}

.mobile-sort-item input[type="radio"] {
    width: 20px;
    height: 20px;
    margin: 0;
    cursor: pointer;
    accent-color: #62e2ff;
}

.mobile-sort-item span {
    flex: 1;
    color: #e7efff;
}

.mobile-sort-item:hover {
    border-color: rgba(103, 236, 255, 0.38);
    background: linear-gradient(135deg, rgba(29, 77, 176, 0.92) 0%, rgba(55, 64, 180, 0.94) 55%, rgba(83, 44, 172, 0.92) 100%);
    box-shadow: 0 14px 26px rgba(8, 18, 52, 0.22), 0 0 18px rgba(66, 214, 255, 0.16);
}

.mobile-sort-footer {
    padding: 14px 16px 18px;
    border-top: 1px solid rgba(109, 145, 238, 0.18);
    background: rgba(6, 12, 31, 0.86);
    backdrop-filter: blur(18px);
}

.mobile-sort-apply {
    width: 100%;
    min-height: 52px;
    padding: 12px;
    border: 1px solid rgba(109, 242, 255, 0.24);
    border-radius: 14px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: linear-gradient(135deg, #20b8ff 0%, #3a4dff 55%, #7c48ff 100%);
    color: #fff;
    box-shadow: 0 10px 22px rgba(19, 39, 117, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.mobile-sort-apply:hover {
    box-shadow: 0 14px 24px rgba(8, 18, 52, 0.22), 0 0 18px rgba(66, 214, 255, 0.16);
    transform: translateY(-1px);
}

body.mobile-sort-open {
    overflow: hidden;
}

/**
 * Shared structural layer для mobile filters overlay (каталог, категория).
 * Визуальные стили — в page-specific CSS.
 */
.listing-mobile-filters-overlay {
    position: fixed;
    inset: 0;
    z-index: 10001;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.listing-mobile-filters-overlay.show {
    display: flex;
}

.listing-mobile-filters-overlay__panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.listing-mobile-filters-overlay__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.listing-mobile-filters-overlay__title {
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.listing-mobile-popup-close {
    flex-shrink: 0;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.listing-mobile-filters-overlay__body {
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.listing-mobile-filters-overlay__footer {
    flex-shrink: 0;
    display: flex;
    gap: 12px;
}

.listing-mobile-filters-overlay__footer .listing-filter-action--secondary {
    flex: 0 0 30%;
    max-width: 30%;
}

.listing-mobile-filters-overlay__footer .listing-filter-action:not(.listing-filter-action--secondary) {
    flex: 0 0 70%;
    max-width: 70%;
}

.listing-mobile-filters-overlay__footer .listing-filter-action {
    font-size: 16px;
}

/* Оверлей каталога внутри .basis-background (z-index:1); .mobile-menu-footer (10000) иначе выше всего поддерева. */
body.catalog-mobile-filters-open .mobile-menu-footer,
body.category-mobile-ui-open .mobile-menu-footer,
body.mobile-sort-open .mobile-menu-footer {
    z-index: 0;
}

@media (min-width: 1100.01px) {
    .mobile-filter-icons {
        display: none !important;
    }

    .mobile-sort-popup {
        display: none !important;
    }
}

@media (max-width: 1100.99px) {
    :root {
        --mobile-menu-height: 68px;
    }

    .mobile-filter-icons {
        display: flex !important;
        gap: 10px;
        margin-left: 10px;
    }

    .mobile-sort-icon,
    .mobile-filters-icon {
        width: 45px;
        height: 45px;
        border-radius: 8px;
        background: #fff;
        border: 1px solid #e9ecef;
        color: #495057;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.2s ease;
        box-shadow: 2px 2px 3px rgba(0, 0, 0, 0.2);
        position: relative;
    }

    .mobile-sort-icon:hover,
    .mobile-filters-icon:hover {
        background: #e9ecef;
        border-color: #adb5bd;
    }

    .mobile-sort-icon.active,
    .mobile-filters-icon.active {
        background: #e8f4fd;
        border: 1px solid #4a90e2;
        color: #2c5aa0;
    }

    .mobile-sort-icon i,
    .mobile-filters-icon i {
        font-size: 18px;
    }

    .mobile-sort-badge,
    .mobile-filters-badge {
        position: absolute;
        top: -5px;
        right: -5px;
        background: #dc3545;
        color: #fff;
        border-radius: 50%;
        padding: 2px 6px;
        font-size: 10px;
        line-height: 1;
        display: none;
        min-width: 16px;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .mobile-sort-icon,
    .mobile-filters-icon {
        width: 40px;
        height: 40px;
    }

    .mobile-sort-icon i,
    .mobile-filters-icon i {
        font-size: 16px;
    }

    .mobile-filter-icons {
        gap: 8px;
    }
}
