/* 模板库样式 */

/* 模态框遮罩 */
.template-library-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.template-library-overlay.show {
    display: flex;
}

/* 模板库主体 */
.template-library {
    width: 90%;
    max-width: 1200px;
    max-height: 85vh;
    background: var(--bg-panel);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 头部 */
.template-library-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.template-library-header h2 {
    margin: 0;
    font-size: 20px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.template-preview-header .close-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    transition: background 0.2s;
}

.template-preview-header .close-btn:hover {
    background: var(--bg-hover);
}

.template-library-header .close-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    transition: background 0.2s;
}

.template-library-header .close-btn:hover {
    background: var(--bg-hover);
}

/* 分类筛选 */
.template-library-categories {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.template-category-item {
    padding: 8px 16px;
    border-radius: 20px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.template-category-item:hover {
    background: var(--bg-hover);
}

.template-category-item.active {
    background: #ff6b35;
    color: #fff;
}

/* 模板列表 */
.template-library-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 10px;
}

/* 模板卡片 */
.template-card {
    background: var(--bg-secondary);
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.template-card .template-preview {
    width: 100%;
    height: 140px;
    background: var(--bg-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.template-card .template-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.template-card .no-preview {
    color: var(--text-secondary);
    font-size: 12px;
}

.template-card .template-info {
    padding: 16px;
}

.template-card .template-name {
    margin: 0 0 8px;
    font-size: 16px;
    color: var(--text-primary);
}

.template-card .template-desc {
    margin: 0 0 12px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.template-card .template-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.template-card .template-category {
    font-size: 12px;
    color: #ff6b35;
    background: rgba(255, 107, 53, 0.15);
    padding: 4px 8px;
    border-radius: 4px;
}

.template-card .template-price {
    font-size: 14px;
    color: #ffd700;
    font-weight: 500;
}

.template-card .template-actions {
    display: flex;
    gap: 8px;
}

.template-buy-btn,
.template-download-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s;
}

.template-buy-btn:hover,
.template-download-btn:hover {
    opacity: 0.9;
}

.template-buy-btn {
    background: #ff6b35;
    color: #fff;
}

.template-buy-btn.purchased {
    background: #9e9e9e;
    cursor: not-allowed;
    opacity: 0.7;
}

.template-buy-btn.purchased:hover {
    opacity: 0.7;
}

.template-download-btn {
    background: var(--accent-color);
    color: #fff;
}

/* 空状态 */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

/* 预览弹窗 */
.template-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1001;
}

.template-preview-modal.show {
    display: flex;
}

.template-preview-content {
    background: var(--bg-panel);
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.template-preview-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.template-preview-header h3 {
    margin: 0;
    color: var(--text-primary);
}

.template-preview-body {
    padding: 24px;
}

.template-preview-body h3 {
    color: var(--text-primary);
    margin: 0 0 5px;
}

.template-preview-body p {
    color: var(--text-secondary);
    margin: 0 0 10px;
    line-height: 1.6;
}

.template-preview-body .preview-image {
    width: 100%;
    height: 340px;
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 20px;
}

.template-preview-body .preview-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.template-preview-body .preview-info {
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 6px;
}

.template-preview-body .preview-info div {
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.template-preview-body .preview-info div:last-child {
    margin-bottom: 0;
}

.template-preview-action {
    display: flex;
    gap: 12px;
    padding: 0 24px 24px 24px;
}

.template-preview-action button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

/* 模板库底部 */
.template-library-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-panel);
}

/* 分页样式 */
.template-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
}

.pagination-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--bg-hover);
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-info {
    font-size: 14px;
    color: var(--text-secondary);
}

/* 项目库模板按钮样式 */
.btn-template-library {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    background: #6c5ce7;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
    margin-right: 10px;
}

.btn-template-library:hover {
    background: #5b4cdb;
}

/* 购买成功弹窗 */
.purchase-success-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10001;
}

.purchase-success-content {
    background: var(--bg-panel);
    border-radius: 16px;
    padding: 40px 50px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: scaleIn 0.3s ease;
}

@keyframes scaleIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.purchase-success-content .success-icon {
    font-size: 60px;
    margin-bottom: 16px;
}

.purchase-success-content h3 {
    margin: 0 0 12px;
    font-size: 24px;
    color: var(--text-primary);
}

.purchase-success-content p {
    margin: 0 0 24px;
    font-size: 14px;
    color: var(--text-secondary);
}

.purchase-success-content .btn-confirm {
    padding: 12px 40px;
    border: none;
    border-radius: 8px;
    background: #6c5ce7;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.purchase-success-content .btn-confirm:hover {
    background: #5b4cdb;
}
