/* ============================================================
   机器人列表新 UI（indextest.php 专用）
   卡片式分组布局 + 组别 tab 筛选 + 详情弹窗（桌面 modal / 移动 bottom sheet）
   配色复用站内主题变量（steam-dark / 8bit 等主题自动适配）
   所有类名以 bl- 前缀，避免污染站内样式
   ============================================================ */

/* ===== 组件级变量（引用站内主题，附 fallback） ===== */
#bot-list {
    --bl-card: var(--bg-input, rgba(255, 255, 255, 0.04));
    --bl-card-hover: var(--bg-hover, rgba(255, 255, 255, 0.08));
    --bl-elevated: var(--bg-header, #171d25);
    --bl-primary: var(--text-primary, #fff);
    --bl-secondary: var(--text-secondary, #c7d5e0);
    --bl-muted: var(--text-muted, #8f98a0);
    --bl-accent: var(--accent, #1a9fff);
    --bl-accent-hover: var(--accent-hover, #66c0f4);
    --bl-border: var(--border-color, #2a3f5a);
    --bl-success: #66bb6a;
    --bl-warning: #ffa726;
    --bl-danger: #ef5350;
    --bl-radius: 12px;
    --bl-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
    --bl-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --bl-safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* 覆盖旧表格遗留的 overflow 规则，保证 tab 行 sticky 生效（宽屏） */
#bot-list .content-block {
    overflow-x: visible;
}

/* ===== 副标题 ===== */
#bot-list .bl-subtitle {
    color: var(--bl-muted);
    font-size: 13px;
    margin: -12px 0 16px;
}

/* ===== 组别 tab 行：选项卡 + 统计同一行 ===== */
#bot-list .bl-tabs-row {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin: 0 -30px 20px;
    padding: 12px 30px;
    background: color-mix(in srgb, var(--bl-elevated) 88%, transparent);
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    border-bottom: 1px solid var(--bl-border);
}

#bot-list .bl-tabs-bar {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-behavior: smooth;
}

#bot-list .bl-tabs-bar::-webkit-scrollbar {
    display: none;
}

#bot-list .bl-tab-btn {
    flex-shrink: 0;
    padding: 8px 14px;
    border-radius: 8px;
    background: var(--bl-card);
    border: 1px solid var(--bl-border);
    color: var(--bl-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--bl-transition);
    white-space: nowrap;
}

#bot-list .bl-tab-btn:hover {
    color: var(--bl-primary);
    background: var(--bl-card-hover);
    border-color: var(--bl-accent);
}

#bot-list .bl-tab-btn.active {
    background: var(--bl-accent);
    border-color: var(--bl-accent);
    color: #fff;
    box-shadow: 0 2px 12px rgba(26, 159, 255, 0.35);
}

#bot-list .bl-tab-btn .bl-count {
    margin-left: 5px;
    font-size: 11px;
    opacity: 0.75;
    background: rgba(255, 255, 255, 0.15);
    padding: 1px 6px;
    border-radius: 100px;
}

/* 统计信息：桌面在 tab 行右侧 */
#bot-list .bl-header-stats {
    flex-shrink: 0;
    margin-left: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    font-size: 13px;
    color: var(--bl-muted);
    white-space: nowrap;
}

#bot-list .bl-stat-line {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

#bot-list .bl-header-stats strong {
    color: var(--bl-primary);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

#bot-list .bl-money {
    color: var(--bl-success) !important;
}

#bot-list .bl-trade strong { color: var(--bl-success) !important; }
#bot-list .bl-cool strong { color: var(--bl-warning) !important; }
#bot-list .bl-hang strong { color: var(--bl-danger) !important; }

/* ===== 卡片网格 ===== */
#bot-list .bl-grid-container {
    position: relative;
    z-index: 10;
}

#bot-list .bl-group-section {
    margin-bottom: 28px;
}

#bot-list .bl-group-section:last-child {
    margin-bottom: 0;
}

#bot-list .bl-group-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 8px 0 16px;
}

#bot-list .bl-group-header h2 {
    font-size: 17px;
    font-weight: 600;
    color: var(--bl-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

#bot-list .bl-group-size {
    color: var(--bl-muted);
    font-size: 13px;
    font-weight: 400;
}

#bot-list .bl-group-badge {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

#bot-list .bl-group-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, var(--bl-border) 0%, transparent 100%);
}

#bot-list .bl-bots-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 14px;
}

/* ===== 机器人卡片 ===== */
@keyframes blFadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

#bot-list .bl-bot-card {
    background: var(--bl-card);
    border: 1px solid var(--bl-border);
    border-radius: var(--bl-radius);
    padding: 18px 12px 14px;
    cursor: pointer;
    transition: var(--bl-transition);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-height: 210px;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    animation: blFadeInUp 0.4s ease backwards;
}

#bot-list .bl-bot-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.03) 0%, transparent 50%);
    pointer-events: none;
}

#bot-list .bl-bot-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--bl-shadow);
    border-color: var(--bl-accent);
}

#bot-list .bl-bot-card:active {
    transform: translateY(-1px) scale(0.98);
}

#bot-list .bl-bot-card:focus-visible {
    outline: 2px solid var(--bl-accent);
    outline-offset: 2px;
}

#bot-list .bl-card-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    margin-bottom: 10px;
    background: var(--bl-elevated);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bl-border);
    overflow: hidden;
    flex-shrink: 0;
}

#bot-list .bl-card-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#bot-list .bl-card-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--bl-primary);
    margin-bottom: 4px;
}

#bot-list .bl-card-balance {
    font-size: 16px;
    font-weight: 700;
    color: var(--bl-accent-hover);
    margin-bottom: 14px;
    font-variant-numeric: tabular-nums;
}

#bot-list .bl-card-balance::before {
    content: "¥";
    font-size: 0.85em;
    opacity: 0.7;
    margin-right: 2px;
}

#bot-list .bl-friends-section {
    width: 100%;
    margin-top: auto;
}

#bot-list .bl-friends-bar-bg {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 7px;
}

#bot-list .bl-friends-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.8s ease;
}

#bot-list .bl-friends-label {
    font-size: 12px;
    color: var(--bl-muted);
}

#bot-list .bl-friends-label strong {
    color: var(--bl-primary);
    font-weight: 600;
}

#bot-list .bl-empty-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--bl-muted);
}

/* ===== 详情弹窗：原生 dialog，桌面居中 ===== */
body:has(#bot-list .bl-detail-dialog[open]) {
    overflow: hidden;
}

#bot-list .bl-detail-dialog {
    width: min(520px, calc(100% - 48px));
    margin: auto;
    max-width: none;
    max-height: 90vh;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    overflow: visible;
}

#bot-list .bl-detail-dialog::backdrop {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

#bot-list .bl-detail-panel {
    background: var(--bl-elevated);
    border: 1px solid var(--bl-border);
    border-radius: var(--bl-radius);
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
    position: relative;
}

#bot-list .bl-sheet-handle {
    display: none;
    justify-content: center;
    padding: 8px 0 4px;
}

#bot-list .bl-sheet-handle-bar {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.2);
}

#bot-list .bl-panel-top {
    padding: 16px 16px 0;
    display: flex;
    justify-content: flex-end;
}

#bot-list .bl-modal-close {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--bl-card);
    border: 1px solid var(--bl-border);
    color: var(--bl-secondary);
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--bl-transition);
}

#bot-list .bl-modal-close:hover {
    background: var(--bl-danger);
    color: #fff;
    border-color: var(--bl-danger);
}

#bot-list .bl-panel-body {
    padding: 0 20px 20px;
}

/* ===== 详情内容 ===== */
#bot-list .bl-detail-hero {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
}

#bot-list .bl-detail-avatar {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: var(--bl-card);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 2px solid var(--bl-border);
    flex-shrink: 0;
}

#bot-list .bl-detail-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#bot-list .bl-detail-title-info h3 {
    font-size: 19px;
    font-weight: 700;
    margin: 0 0 4px;
    color: var(--bl-primary);
}

#bot-list .bl-detail-subtitle {
    color: var(--bl-secondary);
    font-size: 13px;
    word-break: break-all;
}

#bot-list .bl-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

#bot-list .bl-detail-item {
    background: var(--bl-card);
    border: 1px solid var(--bl-border);
    border-radius: 10px;
    padding: 13px;
    min-width: 0;
}

#bot-list .bl-detail-item.bl-full-width {
    grid-column: 1 / -1;
}

#bot-list .bl-detail-label {
    font-size: 11px;
    color: var(--bl-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

#bot-list .bl-detail-value {
    font-size: 15px;
    font-weight: 600;
    color: var(--bl-primary);
    font-variant-numeric: tabular-nums;
    word-break: break-all;
}

#bot-list .bl-detail-value.bl-large {
    font-size: 20px;
}

#bot-list .bl-detail-value.bl-money {
    color: var(--bl-accent-hover);
}

#bot-list .bl-detail-value.bl-accent {
    color: var(--bl-accent);
}

#bot-list .bl-detail-value.bl-dim {
    font-size: 13px;
    color: var(--bl-secondary);
    font-weight: 400;
}

#bot-list .bl-progress-track {
    height: 7px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 8px;
}

#bot-list .bl-progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.8s ease;
}

#bot-list .bl-items-row {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

#bot-list .bl-item-chip {
    flex: 1;
    background: var(--bl-elevated);
    border: 1px solid var(--bl-border);
    border-radius: 6px;
    padding: 8px;
    text-align: center;
    font-size: 13px;
}

#bot-list .bl-item-chip .bl-num {
    font-size: 15px;
    font-weight: 700;
    color: var(--bl-primary);
    display: block;
}

#bot-list .bl-item-chip .bl-lbl {
    font-size: 10px;
    color: var(--bl-muted);
    margin-top: 2px;
    display: block;
}

/* ===== 底部操作按钮 ===== */
#bot-list .bl-action-row {
    display: flex;
    gap: 10px;
    padding-top: 8px;
}

#bot-list .bl-sheet-btn {
    flex: 1;
    padding: 11px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    border: none;
    cursor: pointer;
    transition: opacity 0.2s;
}

#bot-list .bl-sheet-btn:active {
    opacity: 0.7;
}

#bot-list .bl-sheet-btn.bl-primary {
    background: var(--bl-accent);
    color: #fff;
}

#bot-list .bl-sheet-btn.bl-secondary {
    background: var(--bl-card);
    color: var(--bl-primary);
    border: 1px solid var(--bl-border);
}

/* 加好友按钮状态 */
#bot-list .bl-sheet-btn:disabled {
    cursor: not-allowed;
}

#bot-list .bl-sheet-btn.bl-loading {
    opacity: 0.7;
}

#bot-list .bl-sheet-btn.bl-success {
    background: var(--bl-success);
    color: #fff;
    border-color: transparent;
}

/* ===== 滚动条 ===== */
#bot-list ::-webkit-scrollbar {
    width: 6px;
}

#bot-list ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 3px;
}

/* ===== 平板 ===== */
@media (max-width: 1199px) {
    #bot-list .bl-bots-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ===== 移动端 ===== */
@media (max-width: 768px) {
    #bot-list .bl-subtitle {
        margin-top: -8px;
        font-size: 12px;
    }

    /* 窄屏下 content-block 无 padding（站内规则），tab 行负边距归零 */
    #bot-list .bl-tabs-row {
        margin: 0 0 14px;
        padding: 10px 12px;
        gap: 8px;
    }

    /* 统计换行到 tab 下方，占满整行 */
    #bot-list .bl-header-stats {
        width: 100%;
        margin-left: 0;
        font-size: 11px;
        gap: 6px 12px;
    }

    #bot-list .bl-tab-btn {
        padding: 8px 16px;
        border-radius: 100px;
        font-size: 13px;
    }

    #bot-list .bl-tab-btn.active {
        transform: scale(1.04);
        box-shadow: 0 2px 12px rgba(26, 159, 255, 0.4);
    }

    #bot-list .bl-bots-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    #bot-list .bl-bot-card {
        min-height: 190px;
        padding: 14px 10px 12px;
    }

    #bot-list .bl-bot-card:hover {
        transform: none;
        box-shadow: none;
    }

    #bot-list .bl-bot-card:active {
        transform: scale(0.97);
    }

    #bot-list .bl-card-avatar {
        width: 54px;
        height: 54px;
        margin-bottom: 8px;
    }

    #bot-list .bl-card-name {
        font-size: 13px;
    }

    #bot-list .bl-card-balance {
        font-size: 15px;
        margin-bottom: 12px;
    }

    #bot-list .bl-friends-label {
        font-size: 11px;
    }

    #bot-list .bl-group-header {
        margin: 6px 0 12px;
    }

    #bot-list .bl-group-header h2 {
        font-size: 15px;
    }

    #bot-list .bl-group-badge {
        width: 26px;
        height: 26px;
        font-size: 12px;
    }

    /* 详情改为底部 bottom sheet */
    #bot-list .bl-detail-dialog {
        width: 100%;
        max-height: 85vh;
        margin: auto 0 0;
    }

    #bot-list .bl-detail-dialog::backdrop {
        background: rgba(0, 0, 0, 0.55);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    #bot-list .bl-detail-panel {
        max-width: 100%;
        max-height: 85vh;
        border-radius: 16px 16px 0 0;
        border-bottom: none;
        padding-bottom: var(--bl-safe-bottom);
    }

    #bot-list .bl-sheet-handle {
        display: flex;
    }

    #bot-list .bl-panel-top {
        display: none;
    }

    #bot-list .bl-panel-body {
        padding: 8px 16px calc(16px + var(--bl-safe-bottom));
    }

    #bot-list .bl-detail-avatar {
        width: 58px;
        height: 58px;
    }

    #bot-list .bl-detail-title-info h3 {
        font-size: 18px;
    }

    #bot-list .bl-detail-subtitle {
        font-size: 12px;
    }

    #bot-list .bl-detail-value.bl-large {
        font-size: 18px;
    }

    #bot-list .bl-progress-track {
        height: 5px;
    }
}

@media (max-width: 380px) {
    #bot-list .bl-detail-grid {
        grid-template-columns: 1fr;
    }

    #bot-list .bl-detail-hero {
        flex-direction: column;
        text-align: center;
    }
}
