/**
 * 推广栏 — 前台样式
 *
 * 样式与原版 hotbar-grid 一致：横排等宽卡片条。
 *   - .io-hotbar-link  flex:1 均分宽度（所有卡片等宽），固定 height:40px（等高）
 *   - 10 色循环边框（nth-child(10n+k) 无限循环，与旧版 10 色一致）
 *   - 「+ 申请推广位」按钮同高同宽（虚线边框区分）
 *   - 响应式：桌面一行 → ≤1200px 5列换行 → ≤768px 2列换行
 *   - 申请弹窗：移动端底部抽屉
 *
 * @package onenavsub
 * @subpackage Core\Modules\Hotbar
 */

/* ===== 容器 =====
 * 宽度语义与父主题搜索区 .search-container 完全一致：
 * max-width: var(--home-max-width)（后台「首页内容宽度」，默认 1600）+ 左右 10px padding。
 * 推广栏被 JS 插入到 .search-container 底部（同处 .header-banner 内），
 * 因此与搜索区同宽居中、内容左右对齐（grid 背景从 170 到 1750）。
 */
.io-hotbar-wrap {
    position: relative;
    /* 表层：父主题「搜索设置-背景渐变」会给 .header-big.bg-gradual::after 添加一个
     * position:absolute; height:380px 的渐变伪元素（body 色→透明）盖在 header 底部，
     * 仅 .header-big .switch-container 有 z-index:1。推广栏必须置顶 z-index:2 才能
     * 不被渐变覆盖导致显示不清晰（处于表层不受背景渐变开关影响）。 */
    z-index: 2;
    max-width: var(--home-max-width);
    margin: 0 auto;
    padding: 10px;
    box-sizing: border-box;
}

/* ===== 横排等宽卡片条 =====
 * 列数由 JS 根据容器实际宽度（父主题「首页内容宽度」--home-max-width 决定）映射设置
 * --io-hb-cols：宽屏 10 / 9 / 8 / 7 / 6 / 5 / 4 / 3 列，卡片严格等宽（repeat(N, 1fr)）。
 * 固定列数而非 auto-fit：卡片数量不足 N 时尾部留白，不会拉伸占满整行。
 */
.io-hotbar-grid {
    --io-hb-cols: 8;
    display: grid;
    grid-template-columns: repeat(var(--io-hb-cols), minmax(0, 1fr));
    align-items: stretch;
    gap: 10px;
    width: 100%;
    padding: 6px 12px;
    margin: 0 auto;
    /* 与父主题侧边栏菜单卡片（.aside-card.blur-bg）相同的半透明磨砂玻璃效果：
     * 背景跟随 --main-blur-bg-color（浅色 rgba(245,245,245,.75) / 暗色 rgba(46,46,46,.65)，
     * 不支持 backdrop-filter 时变量自动降级为纯色），saturate(2) blur(15px) 磨砂。 */
    background: var(--main-blur-bg-color);
    -webkit-backdrop-filter: saturate(2) blur(15px);
    backdrop-filter: saturate(2) blur(15px);
    border-radius: 12px;
    box-sizing: border-box;
}

.io-hotbar-link,
.io-hotbar-apply-btn {
    /* 等宽等高 */
    min-width: 0;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 8px;
    background: #fff;
    border-radius: 10px;
    box-sizing: border-box;
    cursor: pointer;
    text-decoration: none !important;
    outline: none !important;
    transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}
.io-hotbar-link:hover,
.io-hotbar-apply-btn:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, .1);
}
body.io-black-mode .io-hotbar-link,
body.io-black-mode .io-hotbar-apply-btn,
[data-theme="dark"] .io-hotbar-link,
[data-theme="dark"] .io-hotbar-apply-btn {
    background: rgba(40, 40, 40, .85);
}

/* 10 色循环边框 — 用 CSS 变量实现，nth-child 无限循环 */
.io-hotbar-link:nth-child(10n+1) { --hb-color: #f9c74f; }
.io-hotbar-link:nth-child(10n+2) { --hb-color: #38c172; }
.io-hotbar-link:nth-child(10n+3) { --hb-color: #ef4444; }
.io-hotbar-link:nth-child(10n+4) { --hb-color: #3b82f6; }
.io-hotbar-link:nth-child(10n+5) { --hb-color: #fb923c; }
.io-hotbar-link:nth-child(10n+6) { --hb-color: #9333ea; }
.io-hotbar-link:nth-child(10n+7) { --hb-color: #14b8a6; }
.io-hotbar-link:nth-child(10n+8) { --hb-color: #f97316; }
.io-hotbar-link:nth-child(10n+9) { --hb-color: #eab308; }
.io-hotbar-link:nth-child(10n+10) { --hb-color: #22c55e; }
.io-hotbar-link {
    border: 2px solid var(--hb-color);
}

/* favicon */
.io-hotbar-icon {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    border-radius: 5px;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, .05);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
}
.io-hotbar-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    max-width: none !important;
    max-height: none !important;
}
.io-hotbar-icon-fallback {
    background: linear-gradient(135deg, var(--hb-color, #2563eb), #9333ea);
}

/* 名称 */
.io-hotbar-name {
    min-width: 0;
    font-size: 13px;
    font-weight: 500;
    color: #1f2937;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1;
}
body.io-black-mode .io-hotbar-name,
[data-theme="dark"] .io-hotbar-name {
    color: #f3f4f6;
}

/* ===== 简介悬浮提示（hover 显示 desc_txt） =====
 * 卡片设置简介（data-tip）时，鼠标悬停在卡片上方显示提示气泡，
 * 顶部色条跟随卡片 10 色循环边框 --hb-color，保持一致视觉。
 * 纯 CSS ::before/::after 实现，attr() 读取纯文本，天然防 XSS。
 */
.io-hotbar-link {
    position: relative;
}
.io-hotbar-link[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    z-index: 30;
    width: max-content;
    max-width: 280px;
    padding: 8px 12px;
    border-radius: 8px;
    background: #fff;
    color: #1f2937;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.6;
    text-align: left;
    white-space: normal;
    word-break: break-all;
    overflow-wrap: break-word;
    box-sizing: border-box;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .14);
    border: 1px solid rgba(0, 0, 0, .08);
    border-top: 3px solid var(--hb-color, #2563eb);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease, visibility .18s;
}
/* 向下的三角箭头（衔接气泡与卡片） */
.io-hotbar-link[data-tip]::before {
    content: "";
    position: absolute;
    bottom: calc(100% + 5px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 31;
    width: 0;
    height: 0;
    border: 6px solid transparent;
    border-top-color: #fff;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .18s ease, visibility .18s;
}
.io-hotbar-link[data-tip]:hover::after,
.io-hotbar-link[data-tip]:hover::before {
    opacity: 1;
    visibility: visible;
}
.io-hotbar-link[data-tip]:hover::after {
    transform: translateX(-50%) translateY(0);
}
body.io-black-mode .io-hotbar-link[data-tip]::after,
[data-theme="dark"] .io-hotbar-link[data-tip]::after {
    background: #262729;
    color: #f3f4f6;
    border-color: rgba(255, 255, 255, .12);
}
body.io-black-mode .io-hotbar-link[data-tip]::before,
[data-theme="dark"] .io-hotbar-link[data-tip]::before {
    border-top-color: #262729;
}

/* 申请按钮：作为普通 grid 项参与自动流，与其他卡片按 1fr 均分宽度，
 * 位于卡片流末尾（若卡片不满一行则自然落在第一行最后一位） */
.io-hotbar-apply-btn {
    border: 2px dashed var(--theme-color, #2563eb);
    color: var(--theme-color, #2563eb);
    background: rgba(37, 99, 235, .04);
    font-size: 13px;
    font-weight: 500;
}
.io-hotbar-apply-btn:hover {
    background: var(--theme-color, #2563eb);
    color: #fff;
    border-style: solid;
}
.io-hotbar-plus {
    font-size: 15px;
    font-weight: 700;
    line-height: 1;
}

/* ===== 响应式：移动端列数同样由 --io-hb-cols 控制（JS 按视口宽度映射）
 * 以下变量声明仅作为无 JS / 极端场景的兜底。 */
@media (max-width: 768px) {
    .io-hotbar-wrap {
        padding: 6px 8px;
    }
    .io-hotbar-grid {
        --io-hb-cols: 2;
        padding: 6px 8px;
        gap: 8px;
    }
    .io-hotbar-link,
    .io-hotbar-apply-btn {
        height: 38px;
    }
}

@media (max-width: 420px) {
    .io-hotbar-grid {
        --io-hb-cols: 1;
    }
}

/* ===== 弹窗（移动端底部抽屉） ===== */
.io-hotbar-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
}
.io-hotbar-modal.io-hotbar-open {
    display: block;
}
.io-hotbar-modal-mask {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    animation: io-hotbar-fade .2s;
}
.io-hotbar-modal-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 460px;
    max-width: 94vw;
    max-height: 88vh;
    overflow-y: auto;
    background: var(--card-bg, #fff);
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
    animation: io-hotbar-rise .25s;
}
body.io-black-mode .io-hotbar-modal-panel,
[data-theme="dark"] .io-hotbar-modal-panel {
    background: var(--card-bg, #1e1f20);
    border: 1px solid rgba(255, 255, 255, .08);
}
.io-hotbar-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, .06);
}
.io-hotbar-modal-title {
    font-size: 15px;
    font-weight: 700;
}
.io-hotbar-modal-close {
    border: none;
    background: transparent;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    color: var(--text-muted, #6b7280);
    padding: 4px;
}
.io-hotbar-modal-body {
    padding: 16px 20px;
}
.io-hotbar-modal-foot {
    padding: 12px 20px 16px;
    border-top: 1px solid rgba(0, 0, 0, .06);
}
@keyframes io-hotbar-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes io-hotbar-rise {
    from { opacity: 0; transform: translate(-50%, -46%); }
    to { opacity: 1; transform: translate(-50%, -50%); }
}

/* ===== 表单 ===== */
.io-hotbar-form-row {
    margin-bottom: 13px;
}
.io-hotbar-form-row label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--text-color, #111827);
}
.io-hotbar-form-row input[type="text"],
.io-hotbar-form-row input[type="url"],
.io-hotbar-form-row input[type="email"] {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid rgba(0, 0, 0, .12);
    border-radius: 8px;
    font-size: 14px;
    background: var(--input-bg, #fff);
    color: var(--text-color, #111827);
    box-sizing: border-box;
    outline: none;
    transition: border-color .2s;
}
.io-hotbar-form-row input:focus {
    border-color: var(--theme-color, #2563eb);
}
body.io-black-mode .io-hotbar-form-row input,
[data-theme="dark"] .io-hotbar-form-row input {
    border-color: rgba(255, 255, 255, .14);
    background: #262729;
}
.io-hotbar-plans {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.io-hotbar-plan {
    position: relative;
    flex: 1 1 100px;
    border: 1px solid rgba(0, 0, 0, .12);
    border-radius: 8px;
    padding: 8px 6px;
    text-align: center;
    cursor: pointer;
    transition: all .18s;
}
.io-hotbar-plan input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.io-hotbar-plan-active {
    border-color: var(--theme-color, #2563eb);
    background: rgba(37, 99, 235, .08);
}
.io-hotbar-plan-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
}
.io-hotbar-plan-price {
    display: block;
    font-size: 12px;
    color: #ef4444;
    font-weight: 600;
    margin-top: 2px;
}
body.io-black-mode .io-hotbar-plan,
[data-theme="dark"] .io-hotbar-plan {
    border-color: rgba(255, 255, 255, .14);
}
.io-hotbar-paymethods {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.io-hotbar-paymethod {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: 1px solid rgba(0, 0, 0, .12);
    border-radius: 8px;
    cursor: pointer;
    transition: all .18s;
    font-size: 13px;
}
.io-hotbar-paymethod input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.io-hotbar-paymethod-active {
    border-color: var(--theme-color, #2563eb);
    background: rgba(37, 99, 235, .08);
}
.io-hotbar-paymethod-ico {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: var(--theme-color, #2563eb);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.io-hotbar-paymethod-name {
    font-weight: 500;
}
body.io-black-mode .io-hotbar-paymethod,
[data-theme="dark"] .io-hotbar-paymethod {
    border-color: rgba(255, 255, 255, .14);
}
.io-hotbar-scan-label {
    font-weight: 400 !important;
    display: flex !important;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}
.io-hotbar-notice {
    margin-top: 4px;
    padding: 9px 12px;
    border-radius: 8px;
    background: rgba(37, 99, 235, .06);
    border-left: 3px solid var(--theme-color, #2563eb);
    font-size: 12px;
    color: var(--text-muted, #6b7280);
    line-height: 1.6;
}
.io-hotbar-submit {
    width: 100%;
    padding: 11px;
    border: none;
    border-radius: 10px;
    background: var(--theme-color, #2563eb);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .2s;
}
.io-hotbar-submit:hover {
    opacity: .88;
}
.io-hotbar-submit:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* ===== 扫码结果 ===== */
.io-hotbar-scan-panel {
    width: 380px;
}
.io-hotbar-scan-body {
    text-align: center;
}
.io-hotbar-scan-qr {
    display: inline-block;
    margin: 8px 6px;
}
.io-hotbar-scan-qr img {
    width: 150px;
    height: 150px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, .08);
}
.io-hotbar-scan-tip {
    font-size: 13px;
    color: var(--text-muted, #6b7280);
    margin-top: 10px;
    line-height: 1.6;
}
/* 扫码订单号：占用中，提示付款备注后6位 */
.io-hotbar-scan-order {
    margin-bottom: 10px;
    padding: 10px 12px;
    background: rgba(37, 99, 235, .06);
    border: 1px dashed rgba(37, 99, 235, .35);
    border-radius: 8px;
}
.io-hotbar-scan-order-label {
    font-size: 12px;
    color: var(--text-muted, #6b7280);
    margin-bottom: 4px;
}
.io-hotbar-scan-order-num {
    font-size: 17px;
    font-weight: 700;
    color: var(--theme-color, #2563eb);
    font-family: Consolas, Menlo, monospace;
    letter-spacing: .5px;
    word-break: break-all;
}
.io-hotbar-scan-remark {
    font-size: 13px;
    color: #dc2626;
    margin-top: 8px;
    line-height: 1.6;
}
.io-hotbar-scan-remark b {
    font-weight: 700;
}
.io-hotbar-scan-cancel {
    display: block;
    width: 100%;
    margin-top: 14px;
    padding: 8px 0;
    border: 1px solid rgba(0, 0, 0, .14);
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted, #6b7280);
    font-size: 13px;
    cursor: pointer;
    transition: all .18s;
}
.io-hotbar-scan-cancel:hover {
    border-color: #dc2626;
    color: #dc2626;
    background: rgba(220, 38, 38, .05);
}
