/* ===== 全局样式 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background-color: #f5f7fb;
    color: #1e293b;
}

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===== 顶部栏 ===== */
.top-bar {
    background: linear-gradient(135deg, #1a472a 0%, #0f2b1a 100%);
    color: white;
    padding: 0 20px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo-area {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.logo-area h1 {
    font-size: 1.2rem;
    font-weight: 700;
}

.subtitle {
    font-size: 0.65rem;
    opacity: 0.8;
    background: rgba(255,255,255,0.2);
    padding: 2px 8px;
    border-radius: 20px;
}

.lang-switch {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    padding: 4px 12px;
    border-radius: 30px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.75rem;
}

.lang-switch:hover {
    background: rgba(255,255,255,0.3);
}

/* ===== 分类卡片容器 ===== */
.categories-container {
    padding: 16px 20px;
    background: #f1f5f9;
}

.categories-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: flex-start;
    align-items: stretch;
}

/* 分类卡片 */
.category-card {
    background: #ffffff;
    border: 1.5px solid #cbd5e1;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    width: auto;
    min-width: 140px;
    height: 100%;
}

.category-card:hover {
    border-color: #1e4a76;
    box-shadow: 0 4px 12px -8px rgba(0,0,0,0.15);
}

/* 图标区域 */
.card-icons-area {
    flex: 1;
    padding: 10px 8px;
}

/* 图标网格 - 4行固定 */
.card-icons-grid {
    display: grid;
    grid-template-rows: repeat(4, 1fr);
    gap: 6px;
    height: 100%;
}

/* 根据列数设置列宽 */
.card-icons-grid[data-columns="2"] { grid-template-columns: repeat(2, minmax(50px, 65px)); }
.card-icons-grid[data-columns="3"] { grid-template-columns: repeat(3, minmax(50px, 60px)); }
.card-icons-grid[data-columns="4"] { grid-template-columns: repeat(4, minmax(48px, 55px)); }
.card-icons-grid[data-columns="5"] { grid-template-columns: repeat(5, minmax(45px, 52px)); }
.card-icons-grid[data-columns="6"] { grid-template-columns: repeat(6, minmax(42px, 48px)); }

/* 图标项 */
.card-icon-item {
    text-align: center;
    cursor: pointer;
    padding: 4px 2px;
    border-radius: 6px;
    transition: all 0.15s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.card-icon-item:hover {
    background: #f1f5f9;
    transform: translateY(-1px);
}

/* 图标 - 24x24 固定 */
.card-icon-sprite {
    width: 24px;
    height: 24px;
    margin: 0 auto 4px;
    background-image: url('img/sprites/kangaroo_icons.png');
    background-repeat: no-repeat;
    background-size: 240px 264px;
    display: block;
}

.card-icon-name {
    font-size: 0.55rem;
    font-weight: 500;
    color: #475569;
    text-align: center;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

/* 分类标题 - 黑色背景，水平和垂直居中 */
.category-title {
    background: #1e293b;
    padding: 10px 8px;
    text-align: center;
    border-top: 1px solid #334155;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
}

.category-title span {
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    display: inline-block;
    text-align: center;
}

/* ===== 组件详情区域 ===== */
.detail-panel {
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    margin-top: 0;
}

.detail-header {
    padding: 12px 20px;
    font-weight: 600;
    font-size: 0.85rem;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #1e4a76;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 48px;
    z-index: 99;
}

.expand-btn {
    background: #eef2ff;
    border: none;
    color: #1e4a76;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.expand-btn:hover {
    background: #1e4a76;
    color: white;
}

.detail-content {
    padding: 20px;
}

.placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 20px;
    color: #94a3b8;
    gap: 12px;
    font-size: 0.85rem;
}

/* ===== 富文本详情样式 ===== */
.component-detail {
    animation: slideIn 0.2s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.component-detail h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: #0f2b3d;
    border-left: 3px solid #1e4a76;
    padding-left: 12px;
}

.detail-section {
    margin-bottom: 20px;
    border-bottom: 1px solid #eef2ff;
    padding-bottom: 16px;
    overflow-x: auto;
}

.detail-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.detail-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: #1e4a76;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.component-detail .desc {
    font-size: 0.85rem;
    line-height: 1.5;
    color: #334155;
    background: #f8fafc;
    padding: 12px;
    border-radius: 8px;
    border-left: 3px solid #1e4a76;
}

/* ===== 参数表格样式（带竖线）===== */
.params-table {
    width: 100%;
    font-size: 0.7rem;
    border-collapse: collapse;
    border: 1px solid #e2e8f0;
    min-width: 600px;
}

.params-table th,
.params-table td {
    padding: 8px 8px;
    text-align: left;
    border: 1px solid #e2e8f0;
    vertical-align: top;
}

.params-table th {
    background: #f1f5f9;
    font-weight: 600;
    color: #1e4a76;
    border: 1px solid #cbd5e1;
    white-space: nowrap;
}

.params-table td {
    background: #ffffff;
}

.params-table tr:hover td {
    background: #fafcff;
}

.params-table code {
    background: #eef2ff;
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 0.65rem;
    color: #1e4a76;
}

/* 滚动条样式 */
.detail-section::-webkit-scrollbar {
    height: 5px;
}

.detail-section::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

.detail-section::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

/* ===== 图片画廊 ===== */
.image-gallery {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 6px;
}

.gallery-item {
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    transition: transform 0.2s;
    width: 70%;
    max-width: 70%;
    margin: 0 auto;
}

.gallery-item:hover {
    transform: scale(1.01);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.gallery-item img,
.gallery-item video {
    width: 100%;
    height: auto;
    display: block;
}

.gallery-item .gif-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0,0,0,0.6);
    color: white;
    font-size: 0.6rem;
    padding: 2px 6px;
    border-radius: 4px;
}

/* 视频容器 */
.video-container video {
    width: 100%;
    border-radius: 8px;
}

/* 标签云 */
.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag {
    background: #eef2ff;
    color: #1e4a76;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 500;
}

/* 元信息 */
.meta {
    font-size: 0.7rem;
    color: #64748b;
    background: #f8fafc;
    padding: 10px;
    border-radius: 8px;
}

.meta div {
    margin-bottom: 4px;
}

/* 加载状态 */
.loading-detail {
    text-align: center;
    padding: 40px;
    color: #94a3b8;
}

.spinner {
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 3px solid #e2e8f0;
    border-top-color: #1e4a76;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== 模态框 ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.modal.active {
    display: flex;
}

.modal-content {
    max-width: 90%;
    max-height: 90%;
}

.modal-content img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 8px;
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 2rem;
    cursor: pointer;
}

/* ===== 底部栏 ===== */
.footer {
    background: #f1f5f9;
    border-top: 1px solid #e2e8f0;
    padding: 8px 20px;
    font-size: 0.6rem;
    color: #64748b;
    text-align: center;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-links {
    display: flex;
    gap: 16px;
}

.footer a {
    color: #64748b;
    text-decoration: none;
}

.footer a:hover {
    color: #1e4a76;
}

/* ===== 响应式设计 ===== */
@media (max-width: 768px) {
    .categories-container {
        padding: 12px;
    }
    
    .categories-grid {
        gap: 12px;
    }
    
    .category-card {
        min-width: 120px;
    }
    
    .card-icons-grid[data-columns="2"] { grid-template-columns: repeat(2, minmax(45px, 55px)); }
    .card-icons-grid[data-columns="3"] { grid-template-columns: repeat(3, minmax(45px, 52px)); }
    .card-icons-grid[data-columns="4"] { grid-template-columns: repeat(4, minmax(42px, 48px)); }
    .card-icons-grid[data-columns="5"] { grid-template-columns: repeat(5, minmax(40px, 45px)); }
    .card-icons-grid[data-columns="6"] { grid-template-columns: repeat(6, minmax(38px, 42px)); }
    
    .card-icon-name {
        font-size: 0.5rem;
    }
    
    .category-title {
        padding: 8px 6px;
        min-height: 40px;
    }
    
    .category-title span {
        font-size: 0.65rem;
    }
    
    .detail-header {
        padding: 10px 16px;
        top: 48px;
    }
    
    .detail-content {
        padding: 16px;
    }
    
    .component-detail h3 {
        font-size: 1rem;
    }
    
    .component-detail .desc {
        font-size: 0.75rem;
        padding: 10px;
    }
    
    .params-table {
        font-size: 0.65rem;
        min-width: 500px;
    }
    
    .params-table th,
    .params-table td {
        padding: 6px 6px;
    }
    
    .footer {
        padding: 6px 12px;
        font-size: 0.55rem;
    }
    
    .footer-links {
        gap: 8px;
    }
}

@media (max-width: 550px) {
    .category-card {
        min-width: 105px;
    }
    
    .card-icon-name {
        font-size: 0.45rem;
    }
    
    .category-title span {
        font-size: 0.6rem;
    }
    
    .params-table {
        min-width: 450px;
        font-size: 0.6rem;
    }
    
    .params-table th,
    .params-table td {
        padding: 5px 4px;
    }
    
    .image-gallery {
        grid-template-columns: repeat(auto-fill, minmax(70px, 75px));
    }
    
    .gallery-item img,
    .gallery-item video {
        height: 50px;
    }
}
