/**
 * BAILU AI · 共享骨架屏样式系统（Skeleton Screen / Shimmer UI）
 * 版本：v1
 * 引用方式：<link rel="stylesheet" href="/assets/css/skeleton.css?v=...">
 *
 * 设计原则：
 *   - 与真实内容布局一致（高度、间距、行数）→ CLS=0
 *   - shimmer 通过 background-position 平移实现，GPU 友好，无 JS
 *   - prefers-reduced-motion: 自动停用动画
 *
 * 使用方法：
 *   <span class="skel skel-line skel-line--md skel-w-50"></span>
 *   <span class="skel skel-circle" style="width:40px;height:40px"></span>
 *   <span class="skel skel-text" style="width:6em"></span>      // 内联文本占位
 *
 * 复合骨架（容器类）：
 *   .skel-model-list / .skel-model-card     // 模型卡片网格
 *   .skel-keys / .skel-key-row              // API Key 列表
 *   .skel-invite / .skel-invite-row         // 邀请奖励
 *   .skel-dist-grid / .skel-dist-card       // 模型分布卡
 *   .skel-notif-list / .skel-notif-row      // 通知列表
 *   .skel-dash-model-grid / .skel-dash-model-card  // dashboard 模型卡片
 */

.skel {
    --skel-base: #eef2f6;
    --skel-mid: #f7fafc;
    display: block;
    background: linear-gradient(90deg,
            var(--skel-base) 0%,
            var(--skel-mid) 50%,
            var(--skel-base) 100%);
    background-size: 200% 100%;
    background-position: 0% 0;
    border-radius: 6px;
    animation: skel-shimmer 1.4s linear infinite;
    pointer-events: none;
    user-select: none;
}

.skel-circle {
    border-radius: 50%;
}

.skel-line {
    height: 12px;
}

.skel-line--xs {
    height: 8px;
}

.skel-line--sm {
    height: 10px;
}

.skel-line--md {
    height: 14px;
}

.skel-line--lg {
    height: 18px;
}

.skel-line--xl {
    height: 22px;
}

.skel-w-20 {
    width: 20%;
}

.skel-w-30 {
    width: 30%;
}

.skel-w-40 {
    width: 40%;
}

.skel-w-50 {
    width: 50%;
}

.skel-w-60 {
    width: 60%;
}

.skel-w-70 {
    width: 70%;
}

.skel-w-80 {
    width: 80%;
}

.skel-w-90 {
    width: 90%;
}

.skel-w-full {
    width: 100%;
}

.skel-btn {
    height: 32px;
    width: 96px;
    border-radius: 8px;
}

.skel-pill {
    height: 22px;
    width: 60px;
    border-radius: 999px;
    display: inline-block;
}

.skel-block {
    width: 100%;
    height: 100%;
}

.skel-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.skel-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

@keyframes skel-shimmer {
    0% {
        background-position: -120% 0;
    }

    100% {
        background-position: 120% 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .skel {
        animation: none;
        background: var(--skel-base);
    }
}

/* 内联文本骨架（如顶栏用户名 / 邮箱 / 计划名等内联场景） */
.skel-text {
    display: inline-block;
    vertical-align: middle;
    height: 0.9em;
    width: 5em;
    border-radius: 4px;
    --skel-base: #e9eef3;
    --skel-mid: #f5f8fb;
    background: linear-gradient(90deg,
            var(--skel-base) 0%,
            var(--skel-mid) 50%,
            var(--skel-base) 100%);
    background-size: 200% 100%;
    animation: skel-shimmer 1.4s linear infinite;
    color: transparent;
    pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
    .skel-text {
        animation: none;
        background: #e9eef3;
    }
}

/* ===========================================================
 * 复合骨架模板：模型卡片（API Platform 用 .skel-model-card）
 *
 * wrapper 使用 display: contents 透传父级 grid（如 .models-list），让骨架卡
 * 直接成为父网格的 grid items，与真实数据卡片完全等价。如父级不是 grid，
 * 改为 .skel-model-list--standalone 即可启用独立 grid 布局。
 * =========================================================== */
.skel-model-list {
    display: contents;
}

.skel-model-list--standalone {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
    padding: 0;
}

.skel-model-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 18px 18px 16px;
    border-radius: 12px;
    border: 1px solid var(--border-color, #e2e8f0);
    background: #fff;
    min-height: 158px;
}

.skel-model-card .smc-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.skel-model-card .smc-meta {
    display: flex;
    gap: 16px;
    margin-top: auto;
    padding-top: 6px;
}

/* ===========================================================
 * Dashboard 模型卡片（与 .dash-model-item 对齐：300px 列宽 / 紧凑高度）
 * 同样使用 display: contents 透传父 .dash-model-grid 的 grid 布局
 * =========================================================== */
.skel-dash-model-grid {
    display: contents;
}

.skel-dash-model-grid--standalone {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.skel-dash-model-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px 18px;
    border-radius: 8px;
    border: 1px solid var(--border-color, #e2e8f0);
    background: #fff;
    min-height: 130px;
}

.skel-dash-model-card .sdmc-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.skel-dash-model-card .sdmc-meta {
    display: flex;
    gap: 14px;
    margin-top: auto;
}

/* ===========================================================
 * API Key 列表骨架（与 .api-key-item 对齐）
 * =========================================================== */
.skel-keys {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.skel-key-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 18px 20px;
    border-radius: 12px;
    border: 1px solid var(--border-color, #e2e8f0);
    background: #fff;
    min-height: 88px;
}

.skel-key-row .skr-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.skel-key-row .skr-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
}

/* ===========================================================
 * 邀请奖励骨架
 * =========================================================== */
.skel-invite {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.skel-invite-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.skel-invite-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.skel-invite-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border-light, #eef1f6);
    background: #fff;
}

/* ===========================================================
 * 用量分布卡骨架（与 .model-dist-card 对齐）
 * 透传父 .model-distribution-grid 的 grid 布局
 * =========================================================== */
.skel-dist-grid {
    display: contents;
}

.skel-dist-grid--standalone {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}

.skel-dist-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 10px;
    border: 1px solid var(--border-light, #eef1f6);
    background: #fff;
    min-height: 86px;
}

.skel-dist-card .sdc-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

/* ===========================================================
 * 通知列表骨架
 * =========================================================== */
.skel-notif-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
}

.skel-notif-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px 12px;
    border-radius: 10px;
    background: #fff;
    border: 1px solid var(--border-light, #eef1f6);
}

.skel-notif-row .snr-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

/* ===========================================================
 * 数据填充瞬间的可选淡出动效（按需使用）
 * =========================================================== */
.skel-fade-leave {
    animation: skel-fade-out 200ms ease-out forwards;
}

@keyframes skel-fade-out {
    to {
        opacity: 0;
    }
}
