/* 基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

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

h1, h2 {
    color: #2c3e50;
    margin-bottom: 20px;
}

h1 {
    text-align: center;
    font-size: 2.2rem;
    background: linear-gradient(135deg, #3498db, #9b59b6);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    padding: 10px 0;
    margin-bottom: 30px;
}

h2 {
    font-size: 1.5rem;
    border-bottom: 2px solid #eaeaea;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

/* 工作区布局 */
.workspace {
    display: flex;
    flex-direction: row;
    gap: 20px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    padding: 20px;
    min-height: 70vh;
}

/* 主内容区在左侧 */
.main-area {
    order: 1;
    flex: 1;
}

/* 边栏在右侧 */
.sidebar {
    order: 2;
    flex: 0 0 280px;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    overflow-y: auto;
    max-height: 80vh;
    border-left: 1px solid #eaeaea;
    margin-left: 20px;
}

/* 边框分类按钮 */
.border-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.category-btn {
    flex: 1 0 calc(50% - 4px);
    padding: 10px;
    background: #eaeaea;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

.category-btn:hover {
    background: #ddd;
}

.category-btn.active {
    background: #3498db;
    color: white;
}

/* 边框缩略图 */
.border-thumbnails {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.border-thumb {
    background: white;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 2px solid transparent;
}

.border-thumb:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
}

.border-thumb.selected {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.3);
}

.border-thumb img {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
}

.border-name {
    padding: 8px;
    font-size: 0.8rem;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.no-borders {
    grid-column: 1 / -1;
    text-align: center;
    padding: 20px;
    color: #7f8c8d;
}

/* 上传区域 */
.upload-section {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.upload-label {
    display: block;
    margin-bottom: 20px;
    cursor: pointer;
    height: 150px;
}

.upload-box {
    border: 2px dashed #4ab742;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    transition: all 0.3s ease;
    background: #f8f9fa;
    height: 80%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
}

.upload-box.has-image {
    border-color: #3498db;
    background: rgba(52, 152, 219, 0.05);
    min-height: 150px;
}

.upload-icon {
    font-size: 2rem;
    color: #7f8c8d;
    margin-bottom: 10px;
    display: block;
    transition: all 0.3s ease;
}

.upload-box p {
    color: #7f8c8d;
    font-weight: 500;
    margin: 0;
}

.upload-box:hover {
    border-color: #3498db;
    background: rgba(52, 152, 219, 0.1);
}

.upload-box:hover .upload-icon {
    color: #3498db;
    transform: translateY(-3px);
}

.upload-box:hover p {
    color: #3498db;
}

.upload-box.has-image::after {
    content: "点击更换图片";
    position: absolute;
    bottom: 10px;
    left: 0;
    right: 0;
    color: #3498db;
    font-size: 0.8rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.upload-box.has-image:hover::after {
    opacity: 1;
}

#image-upload {
    display: none;
}

/* 预览区域 */
.preview-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.frame-wrapper {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f8f9fa;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

.frame-container {
    max-width: 100%;
    max-height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.frame-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* 加载动画 */
.loading-spinner {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid rgba(52, 152, 219, 0.2);
    border-radius: 50%;
    border-top-color: #3498db;
    animation: spin 1s ease-in-out infinite;
    z-index: 10;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* 控制区域 */
.controls {
    margin-top: 20px;
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
}

.format-options {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
    flex: 1;
}

#quality-container {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    max-width: 200px;
}

#quality {
    flex: 1;
}

#quality-value {
    width: 40px;
    text-align: center;
    font-weight: bold;
}

.high-quality {
    color: #27ae60;
}

.medium-quality {
    color: #f39c12;
}

.low-quality {
    color: #e74c3c;
}

#download-btn {
    background: #3498db;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

#download-btn:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(52, 152, 219, 0.3);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .workspace {
        flex-direction: column;
    }
    
    .sidebar {
        order: 1;
        flex: 0 0 auto;
        max-height: 300px;
        border-left: none;
        border-top: 1px solid #eaeaea;
        margin-left: 0;
        margin-top: 20px;
        padding-top: 20px;
    }
    
    .main-area {
        order: 2;
    }
    
    .border-thumbnails {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .border-categories {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 10px;
    }
    
    .category-btn {
        flex: 0 0 auto;
        white-space: nowrap;
    }
}

@media (max-width: 480px) {
    .border-thumbnails {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    #quality-container {
        max-width: none;
    }
    
    .upload-label {
        height: 120px;
    }
    
    .upload-icon {
        font-size: 1.8rem;
    }
}
/* 下载格式和质量控制样式 */
.format-options {
    background-color: #f5f5f5;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.format-options label {
    display: inline-block;
    margin-right: 10px;
    font-weight: bold;
    color: #333;
}

.format-options select {
    padding: 6px 10px;
    border-radius: 4px;
    border: 1px solid #ddd;
    background-color: white;
    font-size: 14px;
    margin-right: 15px;
    cursor: pointer;
    transition: all 0.3s;
}

.format-options select:hover {
    border-color: #aaa;
}

#quality-container {
    display: inline-block;
    margin-top: 10px;
    width: 100%;
}

#quality-container label {
    display: inline-block;
    width: 60px;
    font-weight: bold;
    color: #333;
}

#quality {
    width: calc(100% - 150px);
    height: 8px;
    margin: 0 10px;
    -webkit-appearance: none;
    background: #ddd;
    border-radius: 4px;
    outline: none;
    vertical-align: middle;
}

#quality::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: #4CAF50;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
}

#quality::-webkit-slider-thumb:hover {
    background: #45a049;
    transform: scale(1.1);
}

#quality-value {
    display: inline-block;
    width: 40px;
    text-align: center;
    font-weight: bold;
    padding: 3px 6px;
    border-radius: 4px;
    background-color: #f0f0f0;
    border: 1px solid #ddd;
}

/* 质量值颜色指示 */
#quality-value.high-quality {
    color: #4CAF50;
    background-color: #e8f5e9;
}

#quality-value.medium-quality {
    color: #FFC107;
    background-color: #fff8e1;
}

#quality-value.low-quality {
    color: #F44336;
    background-color: #ffebee;
}

/* 下载按钮样式 */
#download-btn {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    width: 100%;
    transition: all 0.3s;
    margin-top: 10px;
}

#download-btn:hover {
    background-color: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

#download-btn:active {
    transform: translateY(0);
    box-shadow: none;
}