/* 样式库模板管理 - CSS样式 */

/* ==================== 样式模板容器 ==================== */
.style-templates-section {
    padding: 20px;
    background: var(--bg-color);
    border-radius: 12px;
    margin-bottom: 20px;
}

.style-templates-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.style-templates-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.templates-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.refresh-btn {
    padding: 8px 16px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.refresh-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

/* ==================== 模板网格布局 ==================== */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

/* ==================== 模板卡片 ==================== */
.template-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

.template-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    border-color: var(--accent-color);
}

.template-card.selected {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(75, 108, 183, 0.2);
}

/* ==================== 模板封面 ==================== */
.template-cover {
    width: 100%;
    height: 180px;
    overflow: hidden;
    background: var(--bg-secondary);
    position: relative;
}

.template-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.template-card:hover .template-cover img {
    transform: scale(1.05);
}

/* ==================== 模板信息 ==================== */
.template-info {
    padding: 16px;
}

.template-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 8px 0;
    line-height: 1.2;
}

.template-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0 0 12px 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ==================== 模板标签 ==================== */
.template-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.template-tags .tag {
    background: var(--accent-color);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

/* ==================== 模板元信息 ==================== */
.template-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.template-meta .category {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}

.template-meta .status {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}

.template-meta .status.active {
    background: #10b981;
    color: white;
}

.template-meta .status.inactive {
    background: #ef4444;
    color: white;
}

/* ==================== 模板操作按钮 ==================== */
.template-actions {
    display: flex;
    gap: 8px;
    padding: 0 16px 16px;
}

.template-actions button {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-preview {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-preview:hover {
    background: var(--bg-hover);
    border-color: var(--accent-color);
}

.btn-select {
    background: var(--accent-color);
    color: white;
}

.btn-select:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

/* ==================== 已选择模板显示 ==================== */
.selected-template-container {
    background: var(--card-bg);
    border: 2px solid var(--accent-color);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
}

.selected-template-header {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.selected-template-header::before {
    content: "✓";
    background: var(--accent-color);
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.selected-template-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.template-thumbnail {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid var(--border-color);
}

.selected-template-info .template-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.selected-template-info .template-category {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 4px 0 0 0;
}

/* ==================== 加载和错误状态 ==================== */
.loading, .no-data, .error {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 16px;
}

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.loading::before {
    content: "";
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.error {
    color: #ef4444;
}

/* ==================== 模态框样式 ==================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--card-bg);
    border-radius: 16px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    margin: 0;
    color: var(--text-primary);
    font-size: 20px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.template-preview {
    text-align: center;
    margin-bottom: 20px;
}

.template-preview img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.template-details p {
    margin: 8px 0;
    line-height: 1.5;
}

.template-details ul {
    margin: 8px 0;
    padding-left: 20px;
}

.template-details li {
    margin: 4px 0;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--accent-color);
}

.btn-primary {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

/* ==================== 动画效果 ==================== */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 768px) {
    .templates-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .template-card {
        margin: 0 10px;
    }
    
    .modal-content {
        width: 95%;
        margin: 20px;
    }
    
    .template-actions {
        flex-direction: column;
    }
    
    .selected-template-info {
        flex-direction: column;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .style-templates-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
    
    .templates-controls {
        width: 100%;
        justify-content: flex-end;
    }
}