/* ===========================================================
   游戏套餐选择器 —— 侧栏分组折叠 + 主区域档位切换
   仅作用于 supreme_comparison 下单模板
   =========================================================== */

/* ---------- 侧栏：搜索框 ---------- */
.product-selection-sidebar .tier-search-wrap {
    padding: 10px 12px 6px;
    border-bottom: 1px solid #eef1f5;
}
.product-selection-sidebar #tierSearchInput {
    border-radius: 16px;
    border-color: #e2e6ec;
    box-shadow: none;
    font-size: 13px;
    padding: 6px 12px;
}
.product-selection-sidebar #tierSearchInput:focus {
    border-color: #9fb3c8;
    box-shadow: 0 0 0 2px rgba(44, 62, 80, .08);
}

/* ---------- 侧栏：可滚动列表 ---------- */
.product-selection-sidebar .tier-list {
    max-height: 72vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-bottom: 6px;
}
.product-selection-sidebar .tier-list::-webkit-scrollbar {
    width: 6px;
}
.product-selection-sidebar .tier-list::-webkit-scrollbar-thumb {
    background: #cfd6de;
    border-radius: 3px;
}
.product-selection-sidebar .tier-list::-webkit-scrollbar-thumb:hover {
    background: #b6c0cb;
}

/* ---------- 侧栏：游戏分组 ---------- */
.product-selection-sidebar .tier-group {
    border-bottom: 1px solid #f0f2f5;
}
.product-selection-sidebar .tier-group:last-child {
    border-bottom: 0;
}
.product-selection-sidebar .tier-group-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 14px;
    cursor: pointer;
    user-select: none;
    font-size: 13.5px;
    line-height: 1.35;
    color: #3c4858;
    background: #fff;
    transition: background-color .15s ease, color .15s ease;
}
.product-selection-sidebar .tier-group-head:hover {
    background: #f6f8fb;
    color: #1f2b3a;
}
.product-selection-sidebar .tier-group-head:focus-visible {
    outline: 2px solid #9fb3c8;
    outline-offset: -2px;
}
.product-selection-sidebar .tier-group-name {
    flex: 1 1 auto;
    min-width: 0;
    word-break: break-word;
}
.product-selection-sidebar .tier-group-arrow {
    flex: 0 0 auto;
    font-size: 11px;
    color: #a8b3c0;
    transition: transform .2s ease, color .15s ease;
}
.product-selection-sidebar .tier-group.open .tier-group-arrow {
    transform: rotate(90deg);
    color: #5a6b7d;
}
.product-selection-sidebar .tier-group.has-active .tier-group-head {
    font-weight: 600;
    color: #1a2330;
    background: #f2f6fa;
}

/* 折叠体 */
.product-selection-sidebar .tier-group-body {
    display: none;
    padding: 2px 0 8px;
    background: #fafbfd;
}
.product-selection-sidebar .tier-group.open .tier-group-body {
    display: block;
    animation: tierFadeIn .18s ease;
}
@keyframes tierFadeIn {
    from { transform: translateY(-4px); }
    to   { transform: translateY(0); }
}

/* 档位子项 */
.product-selection-sidebar .tier-group-body .tier-item {
    display: block;
    padding: 8px 14px 8px 30px;
    margin: 0 8px 2px;
    border: 0;
    border-radius: 6px;
    font-size: 13px;
    color: #55606e;
    background: transparent;
    position: relative;
    text-decoration: none;
    transition: background-color .15s ease, color .15s ease;
}
.product-selection-sidebar .tier-group-body .tier-item::before {
    content: "";
    position: absolute;
    left: 16px;
    top: 50%;
    width: 5px;
    height: 5px;
    margin-top: -2.5px;
    border-radius: 50%;
    background: #c8d2dd;
    transition: background-color .15s ease;
}
.product-selection-sidebar .tier-group-body .tier-item:hover {
    background: #eaf1f8;
    color: #1f2b3a;
}
.product-selection-sidebar .tier-group-body .tier-item:hover::before {
    background: #7f97ae;
}
.product-selection-sidebar .tier-group-body .tier-item.active,
.product-selection-sidebar .tier-group-body .tier-item.active:hover {
    background: #2c3e50;
    color: #fff;
    font-weight: 600;
}
.product-selection-sidebar .tier-group-body .tier-item.active::before {
    background: #8fd0a3;
}

/* 搜索无结果提示 */
.product-selection-sidebar .tier-empty {
    padding: 18px 14px;
    text-align: center;
    font-size: 13px;
    color: #97a3b0;
}

/* ---------- 主区域：档位切换 ---------- */
.tier-switch {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 4px 0 20px;
    padding: 0;
}
.tier-switch .tier-switch-label {
    align-self: center;
    margin-right: 4px;
    font-size: 13px;
    color: #8b96a3;
}
.tier-switch a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 18px;
    border: 1px solid #dfe5ec;
    border-radius: 20px;
    background: #fff;
    color: #55606e;
    font-size: 13.5px;
    text-decoration: none;
    transition: all .15s ease;
}
.tier-switch a:hover {
    border-color: #b9c6d4;
    color: #1f2b3a;
    background: #f6f8fb;
    text-decoration: none;
}
.tier-switch a.active {
    background: #2c3e50;
    border-color: #2c3e50;
    color: #fff;
    font-weight: 600;
}
.tier-switch a .tier-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #c8d2dd;
}
.tier-switch a.active .tier-dot {
    background: #8fd0a3;
}

/* ---------- 主区域：套餐卡片可读性微调 ---------- */
div#order-supreme_comparison .price-table-container ul li {
    vertical-align: top;
}
div#order-supreme_comparison .price-table .product-title h3 {
    font-size: 17px;
    margin: 8px 0 4px;
}
div#order-supreme_comparison .price-table .price-area .price {
    font-size: 20px;
    font-weight: 700;
}

/* 移动端：侧栏隐藏时档位切换仍可用 */
@media (max-width: 767px) {
    .tier-switch {
        margin: 0 0 16px;
    }
    .tier-switch a {
        padding: 6px 14px;
        font-size: 13px;
    }
}

/* ===========================================================
   主区域套餐卡片：固定 155px 改为自适应网格
   解决 7 张卡片换行并溢出容器右边界的问题
   =========================================================== */
div#order-supreme_comparison .price-table-container ul {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(172px, 1fr));
    gap: 18px;
    align-items: start;
    text-align: center;
    width: 100%;
}
div#order-supreme_comparison .price-table-container ul li {
    display: block;
    width: auto;
    max-width: none;
    padding: 0;
    margin: 0;
}
div#order-supreme_comparison .price-table-container .price-table {
    width: 100%;
    max-width: none;
    margin: 0;
}
div#order-supreme_comparison .price-table .product-icon {
    height: 95px;
    overflow: hidden;
}
div#order-supreme_comparison .price-table .product-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
div#order-supreme_comparison .price-table .product-title h3 {
    font-size: 22px;
    line-height: 30px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 价格区自适应宽度 */
div#order-supreme_comparison .price-table .price-area {
    max-width: none;
    width: 100%;
}
div#order-supreme_comparison .price-table .price {
    max-width: none;
}

/* 描述文字：默认截断 4 行，悬停展开，避免 7 张卡片重复大段文案 */
div#order-supreme_comparison .product-body ul {
    max-height: 8.2em;
    overflow: hidden;
    transition: max-height .2s ease;
    position: relative;
}
div#order-supreme_comparison .product-body ul::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2.2em;
    background: linear-gradient(to bottom, rgba(255,255,255,0), #fff 85%);
    pointer-events: none;
    border-radius: 0 0 10px 10px;
}
div#order-supreme_comparison .price-table:hover .product-body ul {
    max-height: 32em;
}
div#order-supreme_comparison .price-table:hover .product-body ul::after {
    display: none;
}

/* 窄屏：卡片最小宽度下调，保证两列 */
@media (max-width: 991px) {
    div#order-supreme_comparison .price-table-container ul {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 14px;
    }
    div#order-supreme_comparison .price-table .product-title h3 {
        font-size: 19px;
        line-height: 26px;
    }
}
@media (max-width: 480px) {
    div#order-supreme_comparison .price-table-container ul {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 10px;
    }
}

/* ===========================================================
   修复原模板布局缺陷：
   原实现为「侧栏 absolute left:-300px + 整行 left:300px 右移」，
   行宽未同步减去 300px，导致主区域右侧 300px 超出视口、卡片被裁。
   改为 flex 两栏，彻底消除横向溢出。
   =========================================================== */
.row-product-selection {
    display: flex !important;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 20px;
    left: 0 !important;
    width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    box-sizing: border-box;
}
/* #tip 在模板中被嵌套在 row 内部，作为 flex 子项会抢占宽度，令其独占一行 */
.row-product-selection > #tip {
    flex: 0 0 100%;
    width: 100% !important;
    max-width: 100%;
    left: 0 !important;
    top: 0 !important;
    margin-top: 20px;
    box-sizing: border-box;
}
.row-product-selection > .product-selection-sidebar {
    position: static !important;
    left: auto !important;
    top: auto !important;
    width: 300px !important;
    max-width: 300px;
    flex: 0 0 300px;
    float: none !important;
    display: block;
    box-sizing: border-box;
}
.row-product-selection > .col-xs-12 {
    flex: 1 1 0% !important;
    width: auto !important;
    max-width: none !important;
    min-width: 0;
    float: none !important;
    padding-left: 0;
    padding-right: 0;
    box-sizing: border-box;
}

/* 侧栏收起时（fadeOut 后 display:none），主区自动占满 */
.row-product-selection > .product-selection-sidebar[style*="display: none"] + .col-xs-12 {
    flex-basis: 100%;
}

/* 窄屏：侧栏改为上方折叠，避免横向挤压 */
@media (max-width: 767px) {
    .row-product-selection {
        display: block !important;
    }
    .row-product-selection > .product-selection-sidebar {
        width: 100% !important;
        max-width: 100%;
        flex: none;
        margin-bottom: 16px;
    }
    .product-selection-sidebar .tier-list {
        max-height: 320px;
    }
}

/* ===========================================================
   Ajax 局部加载态：用顶部进度条 + 内容淡化替代整页白屏
   =========================================================== */
#order-supreme_comparison {
    position: relative;
}
#order-supreme_comparison.is-loading {
    opacity: .5;
    pointer-events: none;
    transition: opacity .12s ease;
}
#order-supreme_comparison.is-loading::before {
    content: "";
    position: absolute;
    top: -4px;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: 2px;
    background: linear-gradient(90deg, #2c3e50 0%, #8fd0a3 45%, #2c3e50 100%);
    background-size: 200% 100%;
    animation: tierLoadingBar 1s linear infinite;
    z-index: 5;
}
@keyframes tierLoadingBar {
    from { background-position: 0 0; }
    to   { background-position: 200% 0; }
}
/* 侧栏点击时的即时反馈 */
.product-selection-sidebar .tier-item:active {
    background: #e3ecf5;
}

/* 尊重系统「减少动态效果」偏好 */
@media (prefers-reduced-motion: reduce) {
    #order-supreme_comparison.is-loading::before { animation: none; }
    .product-selection-sidebar .tier-group-body { animation: none; }
}
