/* ==========================================================
   资源库列表页专用样式（列表现代化）
   设计规范见项目根目录 .design-spec.md
   ========================================================== */

.lib-body {
    background: #f8fafc !important;
}

.lib-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 24px 48px;
}

/* ---------- 工具条：搜索 + 分类 ---------- */
.lib-toolbar {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.04);
}

.lib-search {
    position: relative;
    margin-bottom: 16px;
}

.lib-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 0.95rem;
}

.lib-search-input {
    width: 100%;
    padding: 11px 16px 11px 40px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    font-size: 0.95rem;
    color: #0f172a;
    background: #f8fafc;
    transition: all 0.2s ease;
}

.lib-search-input::placeholder {
    color: #94a3b8;
}

.lib-search-input:focus {
    outline: none;
    border-color: #14b8a6;
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.12);
}

.lib-filter-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    border-top: 1px solid #eef2f7;
    padding-top: 16px;
}

.lib-chip {
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: #475569;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    font-family: inherit;
}

.lib-chip:hover {
    border-color: #14b8a6;
    color: #0d9488;
}

.lib-chip.active {
    background: linear-gradient(135deg, #14b8a6 0%, #06b6d4 100%);
    color: #ffffff;
    border-color: #14b8a6;
    box-shadow: 0 4px 12px rgba(20, 184, 166, 0.3);
}

.lib-chip .count {
    font-size: 0.72rem;
    padding: 1px 7px;
    border-radius: 999px;
    background: #f1f5f9;
    color: #64748b;
}

.lib-chip.active .count {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

.lib-chip-link {
    text-decoration: none;
    background: #f0f9ff;
    color: #0369a1;
    border-color: #e0f2fe;
}

.lib-chip-link:hover {
    background: #e0f2fe;
    border-color: #0ea5e9;
    color: #0369a1;
}

/* ---------- 列表 ---------- */
.lib-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 40px;
}

.lib-item {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 16px 20px;
    cursor: pointer;
    transition: all 0.25s ease;
}

.lib-item:hover {
    background: #fbfcfd;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.07);
    transform: translateY(-2px);
}

.lib-item.hidden {
    display: none;
}

.lib-item-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.lib-item-name {
    font-size: 1.05rem;
    font-weight: 650;
    color: #0f172a;
    flex-shrink: 0;
    letter-spacing: -0.01em;
}

.lib-item-cat {
    font-size: 0.78rem;
    color: #0369a1;
    background: #f0f9ff;
    border: 1px solid #e0f2fe;
    padding: 2px 10px;
    border-radius: 999px;
    font-weight: 500;
    white-space: nowrap;
}

.lib-item-meta {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.lib-item-version {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', Consolas, monospace;
    font-size: 0.75rem;
    color: #475569;
    background: #f1f5f9;
    padding: 3px 9px;
    border-radius: 6px;
    font-weight: 500;
}

.lib-item-expand {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    transition: all 0.25s ease;
    background: transparent;
}

.lib-item:hover .lib-item-expand {
    color: #334155;
    background: #f1f5f9;
}

.lib-item-expand i {
    transition: transform 0.25s ease;
    font-size: 0.85rem;
}

.lib-item.expanded .lib-item-expand i {
    transform: rotate(180deg);
}

.lib-item-desc {
    font-size: 0.85rem;
    color: #64748b;
    margin-top: 8px;
    line-height: 1.55;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- 展开区 ---------- */
.lib-details {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.35s ease, opacity 0.3s ease;
}

.lib-item.expanded .lib-details {
    max-height: 900px;
    opacity: 1;
}

.lib-details-inner {
    border-top: 1px solid #eef2f7;
    margin-top: 14px;
    padding-top: 14px;
}

.lib-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.lib-tag {
    font-size: 0.72rem;
    background: #f1f5f9;
    color: #475569;
    padding: 3px 9px;
    border-radius: 6px;
    font-weight: 500;
}

.lib-version-select {
    margin-left: auto;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background: #0f172a;
    color: #ffffff;
    border: 1px solid #0f172a;
    border-radius: 8px;
    padding: 6px 30px 6px 12px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    min-width: 100px;
    height: 32px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
}

.lib-version-select:hover {
    background-color: #1e293b;
    border-color: #1e293b;
}

.lib-version-select option {
    background: #0f172a;
    color: #ffffff;
    padding: 8px 12px;
    font-size: 0.8rem;
}

.lib-files {
    background: #f8fafc;
    border: 1px solid #eef2f7;
    border-radius: 10px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 12px;
}

.lib-files-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: #64748b;
    padding: 2px 6px 0;
}

/* 文件行（签名元素：终端提示符风格 URL） */
.lib-file {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: #ffffff;
    border: 1px solid #e8edf3;
    border-radius: 8px;
    padding: 8px 12px;
    transition: all 0.2s ease;
}

.lib-file:hover {
    background: #f1f5f9;
}

.lib-file-prefix {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', Consolas, monospace;
    color: #64748b;
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
}

.lib-file-path {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', Consolas, monospace;
    font-size: 0.78rem;
    color: #0f172a;
    flex: 1;
    word-break: break-all;
    line-height: 1.5;
}

.lib-copy {
    border: none;
    background: #f1f5f9;
    color: #475569;
    padding: 6px 12px;
    border-radius: 7px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
    font-family: inherit;
}

.lib-copy:hover {
    background: #334155;
    color: #ffffff;
    transform: translateY(-1px);
}

.lib-copy.copied {
    background: #059669;
    color: #ffffff;
}

/* ---------- 状态 ---------- */
.lib-loading,
.lib-empty {
    text-align: center;
    padding: 60px 20px;
    color: #94a3b8;
    font-size: 0.95rem;
}

.lib-loading i,
.lib-empty i {
    display: block;
    font-size: 2.4rem;
    margin-bottom: 14px;
    color: #cbd5e1;
}

.lib-empty h3 {
    font-size: 1.05rem;
    color: #475569;
    margin-bottom: 6px;
}

.lib-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 14px 18px;
    border-radius: 10px;
    text-align: center;
    margin: 0 auto 24px;
    max-width: 600px;
    font-size: 0.875rem;
}

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
    .lib-container {
        padding: 16px 14px 40px;
    }

    .lib-head {
        align-items: flex-start;
    }

    .lib-item {
        padding: 14px 16px;
    }

    .lib-item-header {
        flex-wrap: wrap;
    }

    .lib-item-meta {
        margin-left: auto;
    }

    .lib-item-desc {
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
    }

    .lib-version-select {
        margin-left: 0;
    }

    .lib-tags {
        gap: 5px;
    }
}

/* 尊重减少动态效果偏好 */
@media (prefers-reduced-motion: reduce) {
    .lib-details {
        transition: none;
    }

    .lib-item,
    .lib-copy {
        transition: none;
    }
}
