/* 基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* 头部样式 */
.header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 700;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* 搜索区域 */
.search-section {
    margin-bottom: 30px;
}

.search-container {
    display: flex;
    gap: 10px;
    max-width: 700px;
    margin: 0 auto;
}

.sort-select {
    padding: 10px 15px;
    border: none;
    border-radius: 8px;
    background-color: white;
    font-size: 14px;
    color: #333;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    outline: none;
    flex: 0 0 auto;
}

.search-input {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.search-input:focus {
    outline: none;
    background: white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.clear-btn {
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

.clear-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 模板网格 */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

/* 模板卡片 */
.template-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.template-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.15);
}

.template-preview {
    width: 100%;
    height: 200px;
    background: linear-gradient(45deg, #f0f0f0, #e0e0e0);
    border-radius: 12px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 14px;
    position: relative;
    overflow: hidden;
}

.template-preview::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--preview-gradient, linear-gradient(45deg, #667eea, #764ba2));
    opacity: 0.1;
}

.template-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: #2d3748;
}

.template-description {
    color: #666;
    margin-bottom: 12px;
    font-size: 14px;
    line-height: 1.5;
}

.template-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 12px;
    color: #888;
}

.template-meta .uploader {
    color: #667eea;
    font-weight: 500;
}

.template-meta .download-count {
    color: #28a745;
    font-weight: 500;
}

.template-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}

.tag {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.download-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
}

.download-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 无结果提示 */
.no-results {
    text-align: center;
    padding: 60px 20px;
    color: white;
    font-size: 1.1rem;
}

/* 分页样式 */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 40px;
}

.pagination button {
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

.pagination button:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination button.active {
    background: rgba(255, 255, 255, 0.3);
    font-weight: 600;
}

.pagination-info {
    color: white;
    font-size: 14px;
    margin: 0 16px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 16px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .templates-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .search-container {
        flex-direction: column;
    }
    
    .pagination {
        flex-wrap: wrap;
        gap: 4px;
    }
    
    .pagination-info {
        width: 100%;
        text-align: center;
        margin: 8px 0;
    }
}

@media (max-width: 480px) {
    .template-card {
        padding: 16px;
    }
    
    .template-preview {
        height: 150px;
    }
    
    .header h1 {
        font-size: 1.75rem;
    }
}

/* 加载动画 */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
    color: white;
    font-size: 1.1rem;
}

.loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.upload-btn, .admin-btn {
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

.upload-btn:hover, .admin-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.upload-btn {
    background: linear-gradient(135deg, #28a745, #20c997);
    border: none;
}

.upload-btn:hover {
    background: linear-gradient(135deg, #218838, #1ea080);
}

.admin-btn {
    background: linear-gradient(135deg, #dc3545, #fd7e14);
    border: none;
}

.admin-btn:hover {
    background: linear-gradient(135deg, #c82333, #e8650e);
}

/* 模态框样式 */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    animation: modalSlideIn 0.3s ease-out;
}

/* 上传模态框专用样式 - 更宽 */
#uploadModal .modal-content {
    max-width: 800px;
    width: 90vw;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    padding: 20px 30px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.5rem;
}

.close {
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: white;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.close:hover {
    opacity: 1;
}

.modal-body {
    padding: 30px;
    max-height: 70vh;
    overflow-y: auto;
}

/* 预览大图模态框 */
.modal-preview {
    width: 80vw;
    height: 60vh;
    max-width: 1200px;
    max-height: 800px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    background: white;
}

.modal-preview iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* 表单样式 */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s ease;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

.form-actions button {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.form-actions button[type="button"] {
    background: #6c757d;
    color: white;
}

.form-actions button[type="button"]:hover {
    background: #5a6268;
}

.form-actions button[type="submit"] {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.form-actions button[type="submit"]:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
}

/* 管理员面板样式 */
.admin-login {
    text-align: center;
    padding: 20px;
}

.admin-login .form-group {
    max-width: 300px;
    margin: 0 auto 20px auto;
}

.admin-login button {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.admin-login button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
}

.pending-template {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    background: #f8f9fa;
}

.pending-template h5 {
    margin: 0 0 10px 0;
    color: #333;
}

.pending-template p {
    margin: 5px 0;
    color: #666;
}

.pending-template .template-preview-small {
    width: 100%;
    height: 200px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin: 10px 0;
    overflow: hidden;
}

.pending-template .template-preview-small iframe {
    width: 100%;
    height: 100%;
    border: none;
    transform: scale(0.5);
    transform-origin: top left;
}

.pending-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.approve-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.reject-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.approve-btn:hover {
    background: #218838;
}

.reject-btn:hover {
    background: #c82333;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .search-container {
        flex-direction: column;
        gap: 10px;
    }
    
    .modal-content {
        margin: 20px;
        max-width: calc(100vw - 40px);
    }

    #uploadModal .modal-content {
        max-width: calc(100vw - 40px);
        width: calc(100vw - 40px);
    }
    
    .modal-preview {
        width: 100%;
        height: 50vh;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions button {
        width: 100%;
    }
}

/* 成功/错误消息样式 */
.message {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
}

.message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.message.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}