/* ============ 布局 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif; color: #1a1a2e; background: #f0f2f5; }

.app-layout { display: flex; min-height: 100vh; }

/* ============ 侧边栏 ============ */
.sidebar {
    width: 260px; background: #1a1a2e; color: #fff;
    display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0;
    z-index: 100; transition: transform 0.3s;
}
.sidebar-header { padding: 24px 20px; border-bottom: 1px solid rgba(255,255,255,0.08); display: flex; align-items: center; gap: 10px; }
.sidebar-header h1 { font-size: 20px; }
.version { font-size: 11px; background: rgba(255,255,255,0.1); padding: 2px 8px; border-radius: 10px; }

.sidebar-search { padding: 12px; }
.sidebar-search input {
    width: 100%; padding: 8px 12px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.06); color: #fff; font-size: 13px; outline: none;
}
.sidebar-search input::placeholder { color: rgba(255,255,255,0.4); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.nav-header { display: flex; justify-content: space-between; align-items: center; padding: 8px 20px; font-size: 12px; color: rgba(255,255,255,0.4); text-transform: uppercase; letter-spacing: 1px; }

#categoryList, #logicCategoryList { list-style: none; }
#categoryList li, #logicCategoryList li {
    display: flex; align-items: center; gap: 10px; padding: 10px 20px; cursor: pointer;
    transition: background 0.2s; font-size: 14px; color: rgba(255,255,255,0.7);
}
#categoryList li:hover, #logicCategoryList li:hover { background: rgba(255,255,255,0.06); color: #fff; }
#categoryList li.active, #logicCategoryList li.active { background: rgba(108,92,231,0.2); color: #a29bfe; border-right: 3px solid #6c5ce7; }
.cat-icon { font-size: 16px; width: 24px; text-align: center; }

/* ============ 主区域 ============ */
.main-content { flex: 1; margin-left: 260px; }

.topbar {
    display: flex; align-items: center; gap: 16px;
    padding: 16px 24px; background: #fff; border-bottom: 1px solid #e8e8e8;
    position: sticky; top: 0; z-index: 50;
}
.topbar h2 { font-size: 20px; font-weight: 600; flex: 1; }
.count-badge { font-size: 13px; color: #999; }

/* 库切换 [全部组件 | 全部逻辑] */
.lib-switch {
    display: flex; align-items: center; gap: 0;
    flex: 1; font-size: 15px;
}
.lib-item {
    cursor: pointer; color: #8c8c8c; font-weight: 500;
    transition: color 0.15s;
}
.lib-item:hover { color: #595959; }
.lib-item.active { 
    color: #1a1a2e; font-weight: 700;
    box-shadow: 0 2px 0 #6c5ce7;
}
.lib-sep {
    margin: 0 12px; color: #e0e0e0; user-select: none;
}

.content-body { padding: 24px; }

.grid-container {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.component-card {
    background: #fff; border-radius: 12px; overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06); cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.component-card:hover { transform: translateY(-4px); box-shadow: 0 8px 24px rgba(108,92,231,0.12); }

.card-preview {
    height: 160px; overflow: hidden; background: #fff; padding: 4px;
    display: flex; align-items: flex-start; justify-content: center;
    position: relative;
}
.card-preview iframe { width: 100%; border: none; pointer-events: none; overflow: hidden; display: block; }

.card-info {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px; border-top: 1px solid #f0f0f0;
}
.card-name { font-size: 14px; font-weight: 500; }
.btn-copy {
    padding: 4px 12px; border-radius: 6px; border: 1px solid #e0e0e0;
    background: #fafafa; font-size: 12px; cursor: pointer; transition: 0.2s;
}
.btn-copy:hover { background: #6c5ce7; color: #fff; border-color: #6c5ce7; }

/* ============ 弹窗 ============ */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5);
    display: none; align-items: center; justify-content: center; z-index: 200;
}
.modal-overlay.show { display: flex; }
.modal {
    background: #fff; border-radius: 12px; width: 420px; max-width: 90vw;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; border-bottom: 1px solid #f0f0f0; }
.modal-header h3 { font-size: 18px; }
.modal-body { padding: 24px; }
.modal-body label { display: block; font-size: 13px; color: #666; margin-bottom: 6px; margin-top: 16px; }
.modal-body label:first-child { margin-top: 0; }
.modal-body input[type="text"] { width: 100%; padding: 10px 12px; border: 1px solid #e0e0e0; border-radius: 8px; font-size: 14px; outline: none; }
.modal-body input[type="text"]:focus { border-color: #6c5ce7; box-shadow: 0 0 0 3px rgba(108,92,231,0.1); }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid #f0f0f0; }
.btn { padding: 8px 20px; border-radius: 8px; border: none; font-size: 14px; cursor: pointer; }
.btn-primary { background: #6c5ce7; color: #fff; }
.btn-primary:hover { background: #5a4bd1; }
.btn-default { background: #f5f5f5; color: #666; }
.btn-default:hover { background: #e8e8e8; }
.btn-icon { background: none; border: none; color: inherit; cursor: pointer; font-size: 16px; padding: 4px 8px; border-radius: 6px; }
.btn-icon:hover { background: rgba(255,255,255,0.1); }

.empty-state { grid-column: 1 / -1; text-align: center; padding: 80px 20px; color: #999; font-size: 16px; }

/* ============ 隐藏滚动条 ============ */
.sidebar-nav::-webkit-scrollbar,
.content-body::-webkit-scrollbar,
.grid-container::-webkit-scrollbar,
.card-preview iframe::-webkit-scrollbar,
.card-preview::-webkit-scrollbar { display: none; }
.sidebar-nav,
.content-body,
.grid-container,
.card-preview,
.card-preview iframe { -ms-overflow-style: none; scrollbar-width: none; }

/* ============ 移动端 ============ */
.mobile-menu { display: none; }
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .mobile-menu { display: block; }
    .tab-underline { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .grid-container { grid-template-columns: 1fr; }
}

.comp-id {
    font-size: 11px; background: #f0f0f0; padding: 2px 8px;
    border-radius: 4px; color: #999; font-family: monospace;
}

.comp-check { width: 16px; height: 16px; cursor: pointer; accent-color: #6c5ce7; }
.btn-danger { padding: 6px 14px; border: none; border-radius: 6px; background: #ff4757; color: #fff; cursor: pointer; font-size: 13px; }
.btn-danger:hover { background: #ff6b81; }
.comp-id { cursor: pointer; }
.comp-id:hover { background: #6c5ce7; color: #fff; }

/* 最新标签 - 卡片右上角角标 */
.component-card.is-new { position: relative; }
.badge-new {
    position: absolute;
    top: -2px;
    right: -2px;
    z-index: 10;
    font-size: 10px; font-weight: 700; line-height: 1;
    background: #ff4757; color: #fff;
    padding: 4px 8px; border-radius: 0 12px 0 8px;
    cursor: pointer;
    animation: badge-new-pulse 0.5s ease-out;
    transition: opacity 0.15s;
}
.badge-new:hover { opacity: 0.8; }
@keyframes badge-new-pulse {
    0% { transform: scale(1.4); opacity: 0.5; }
    100% { transform: scale(1); opacity: 1; }
}
