/* 基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4285f4;
    --primary-light: #e8f0fe;
    --secondary-color: #34a853;
    --warning-color: #f9ab00;
    --grey-100: #f8f9fa;
    --grey-200: #e8eaed;
    --grey-300: #dadce0;
    --grey-400: #bdc1c6;
    --grey-500: #9aa0a6;
    --grey-600: #5f6368;
    --grey-700: #3c4043;
    --grey-800: #202124;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
    --radius: 12px;
    --radius-sm: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--grey-800);
}

.app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* 头部 */
.header {
    text-align: center;
    padding: 40px 20px;
    color: white;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* 搜索栏 */
.search-container {
    position: relative;
    max-width: 600px;
    margin: 0 auto 24px;
}

.search-input {
    width: 100%;
    padding: 16px 50px 16px 20px;
    border: none;
    border-radius: 30px;
    font-size: 16px;
    box-shadow: var(--shadow-lg);
    outline: none;
    transition: box-shadow 0.3s;
}

.search-input:focus {
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

.search-icon {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
}

/* 筛选器 */
.filters {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    align-items: center;
}

.filter-label {
    font-weight: 600;
    color: var(--grey-600);
    margin-right: 8px;
}

.filter-btn {
    padding: 8px 16px;
    border: 1px solid var(--grey-300);
    background: white;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.filter-btn:hover {
    background: var(--grey-100);
}

.filter-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* 统计信息 */
.stats {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    color: white;
}

.stat-item {
    font-size: 14px;
}

.stat-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 13px;
    background: rgba(255,255,255,0.2);
}

.stat-badge.high { background: rgba(52, 168, 83, 0.3); }
.stat-badge.medium { background: rgba(249, 171, 0, 0.3); }
.stat-badge.low { background: rgba(255,255,255,0.2); }

/* Widget 列表 */
.widget-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}

/* Widget 卡片 */
.widget-card {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    gap: 16px;
}

.widget-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.widget-card-content {
    flex: 1;
    min-width: 0;
}

.widget-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.widget-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--grey-800);
}

.usage-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.usage-badge.high {
    background: #e6f4ea;
    color: #1e8e3e;
}

.usage-badge.medium {
    background: #fef7e0;
    color: #b36b00;
}

.usage-badge.low {
    background: var(--grey-200);
    color: var(--grey-600);
}

.widget-meta {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.category-chip {
    background: var(--primary-light);
    color: var(--primary-color);
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
}

.package-chip {
    background: #fce8e6;
    color: #c5221f;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
}

.props-count {
    color: var(--grey-500);
    font-size: 12px;
}

.widget-description {
    color: var(--grey-600);
    font-size: 14px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 预览卡片 */
.widget-preview {
    width: 100px;
    height: 70px;
    background: var(--grey-100);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: white;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.8;
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: var(--radius);
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalSlide 0.3s ease;
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border: none;
    background: var(--grey-200);
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    color: var(--grey-600);
    z-index: 10;
    transition: background 0.2s;
}

.modal-close:hover {
    background: var(--grey-300);
}

/* 模态框头部 */
.modal-header {
    padding: 30px;
    background: linear-gradient(135deg, var(--primary-color), #8ab4f8);
    color: white;
}

.modal-title-section {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.modal-title-section h2 {
    font-size: 24px;
}

.modal-description {
    opacity: 0.95;
    line-height: 1.6;
    margin-bottom: 16px;
}

.modal-meta {
    display: flex;
    gap: 12px;
    align-items: center;
}

.modal-meta .category-chip {
    background: rgba(255,255,255,0.25);
    color: white;
}

.modal-meta .props-count {
    color: rgba(255,255,255,0.8);
}

/* 预览区 */
.preview-section {
    padding: 24px 30px;
    background: linear-gradient(135deg, var(--primary-light), #e8f5e9);
}

.preview-label {
    font-size: 12px;
    color: var(--grey-500);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.preview-container {
    background: white;
    border-radius: var(--radius);
    padding: 40px;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.05);
}

/* Tab 导航 */
.modal-tabs {
    display: flex;
    border-bottom: 1px solid var(--grey-300);
    padding: 0 30px;
}

.tab-btn {
    padding: 16px 24px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--grey-600);
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--primary-color);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* Tab 内容 */
.tab-content {
    padding: 24px 30px 30px;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

/* 属性列表 */
.properties-list {
    display: grid;
    gap: 12px;
}

.property-card {
    border: 1px solid var(--grey-200);
    border-radius: var(--radius-sm);
    padding: 16px;
    background: var(--grey-50);
}

.property-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.property-name {
    font-weight: 600;
    font-size: 15px;
}

.property-type {
    background: var(--primary-light);
    color: var(--primary-color);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-family: monospace;
}

.property-required {
    background: #fce8e6;
    color: #c5221f;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.property-description {
    color: var(--grey-700);
    font-size: 14px;
    margin-bottom: 8px;
}

.property-extra {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.property-default,
.property-example {
    background: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-family: monospace;
}

.property-default {
    border-left: 3px solid var(--warning-color);
}

.property-example {
    border-left: 3px solid var(--secondary-color);
}

/* 代码块 */
.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.code-header span {
    font-weight: 600;
    color: var(--grey-700);
}

.copy-btn {
    padding: 6px 14px;
    border: 1px solid var(--grey-300);
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.copy-btn:hover {
    background: var(--grey-100);
}

pre {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 20px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.6;
}

code {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

/* 提示内容 */
.tips-content {
    background: #fef7e0;
    border-left: 4px solid var(--warning-color);
    padding: 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
}

.tips-content h4 {
    color: #b36b00;
    margin-bottom: 8px;
}

.tips-content p {
    color: #666;
    line-height: 1.6;
}

/* 详细介绍内容 */
.detail-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.detail-section {
    background: var(--grey-50);
    border-radius: var(--radius-sm);
    padding: 20px;
}

.detail-section h4 {
    color: var(--grey-800);
    margin-bottom: 12px;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-section p {
    color: var(--grey-700);
    line-height: 1.8;
    font-size: 14px;
}

.use-case-list,
.pitfall-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.use-case-list li,
.pitfall-list li {
    padding: 10px 14px;
    background: white;
    border-radius: 6px;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--grey-700);
    border-left: 3px solid var(--primary-color);
}

.pitfall-list li {
    border-left-color: var(--warning-color);
    background: #fff8e1;
}

.pattern-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pattern-item {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--grey-200);
}

.pattern-title {
    background: var(--primary-light);
    color: var(--primary-color);
    padding: 10px 14px;
    font-weight: 600;
    font-size: 14px;
}

.pattern-code {
    margin: 0;
    padding: 14px;
    background: #1e1e1e;
    font-size: 12px;
    line-height: 1.6;
}

.pattern-code code {
    color: #d4d4d4;
}

/* 相关 Widget */
.related-widgets h4 {
    margin-bottom: 12px;
    color: var(--grey-700);
}

.related-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.related-chip {
    background: var(--primary-light);
    color: var(--primary-color);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.related-chip:hover {
    background: var(--primary-color);
    color: white;
}

/* 预览组件样式 */
.preview-row {
    display: flex;
    gap: 4px;
}

.preview-col {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.preview-box {
    width: 24px;
    height: 24px;
    border-radius: 4px;
}

.preview-stack {
    position: relative;
    width: 60px;
    height: 40px;
}

.preview-stack .preview-box {
    position: absolute;
}

.preview-chip {
    display: inline-block;
    padding: 4px 10px;
    background: var(--grey-200);
    border-radius: 12px;
    font-size: 11px;
    margin: 2px;
}

.preview-button {
    padding: 6px 14px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 12px;
}

.preview-card {
    background: white;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    max-width: 150px;
}

.preview-input {
    padding: 6px 10px;
    border: 1px solid var(--grey-300);
    border-radius: 6px;
    font-size: 12px;
    width: 120px;
}

.preview-slider {
    width: 100px;
}

/* 响应式 */
@media (max-width: 768px) {
    .header h1 {
        font-size: 1.8rem;
    }

    .widget-list {
        grid-template-columns: 1fr;
    }

    .widget-card {
        flex-direction: column;
    }

    .widget-preview {
        width: 100%;
        height: 80px;
    }

    .filters {
        padding: 16px;
    }

    .filter-group {
        gap: 6px;
    }

    .filter-btn {
        padding: 6px 12px;
        font-size: 13px;
    }

    .modal-content {
        width: 95%;
    }

    .modal-header,
    .preview-section,
    .modal-tabs,
    .tab-content {
        padding-left: 20px;
        padding-right: 20px;
    }

    .modal-tabs {
        overflow-x: auto;
    }

    .tab-btn {
        padding: 14px 16px;
    }
}
