/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

/* 容器布局 */
.container {
    display: grid;
    grid-template-columns: 300px 1fr 300px;
    min-height: 100vh;
    max-width: 1800px;
    margin: 0 auto;
    background-color: #fff;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

/* 左侧控制面板 */
.control-panel {
    padding: 20px;
    background-color: #f9f9f9;
    border-right: 1px solid #eee;
    overflow-y: auto;
    height: 100vh;
}

.control-panel h2 {
    margin-bottom: 15px;
    font-size: 18px;
    color: #444;
    border-bottom: 1px solid #ddd;
    padding-bottom: 8px;
}

/* 上传区域样式 */
.upload-section {
    margin-bottom: 25px;
}

.upload-area {
    position: relative;
    border: 2px dashed #ccc;
    border-radius: 5px;
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 15px;
}

.upload-area:hover {
    border-color: #999;
    background-color: #f0f0f0;
}

.upload-area.drag-over {
    border-color: #4CAF50;
    background-color: rgba(76, 175, 80, 0.1);
}

.file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.upload-placeholder {
    pointer-events: none;
}

.upload-placeholder p {
    margin-bottom: 5px;
}

.sub-text {
    font-size: 12px;
    color: #888;
}

.url-input-area {
    display: flex;
    margin-top: 10px;
}

.url-input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px 0 0 4px;
    font-size: 14px;
}

/* 网格设置样式 */
.grid-settings {
    margin-bottom: 25px;
}

.setting-item {
    margin-bottom: 12px;
    display: flex;
    align-items: center;
}

.action-buttons {
    margin-top: 20px;
    text-align: center;
}

.action-buttons .btn {
    width: 100%;
    margin: 0 auto;
    padding: 12px 20px;
    font-weight: 500;
}

.setting-item label {
    width: 120px;
    font-size: 14px;
}

.setting-item input[type="number"] {
    width: 60px;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.setting-item input[type="range"] {
    flex: 1;
}

.setting-item input[type="color"] {
    width: 40px;
    height: 25px;
    border: none;
    cursor: pointer;
}

/* 图片编辑区域 */
.image-edit {
    margin-bottom: 25px;
}

.edit-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* 中央预览区域 */
.preview-section {
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #fff;
    overflow: auto;
}

.preview-container {
    position: relative;
    max-width: 100%;
    max-height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#previewCanvas {
    max-width: 100%;
    max-height: 80vh;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

/* 右侧输出面板 */
.output-panel {
    padding: 20px;
    background-color: #f9f9f9;
    border-left: 1px solid #eee;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
}

.slices-preview {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.slice-item {
    position: relative;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s;
}

.slice-item:hover {
    transform: scale(1.05);
}

.slice-item img {
    width: 100%;
    height: auto;
    display: block;
}

.slice-number {
    position: absolute;
    top: 0;
    left: 0;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    font-size: 10px;
    padding: 2px 5px;
}

.download-options {
    text-align: center;
}

.download-tip {
    font-size: 12px;
    color: #888;
    margin-top: 10px;
}

/* 按钮样式 */
.btn {
    padding: 8px 12px;
    background-color: #e0e0e0;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
}

.btn:hover {
    background-color: #d0d0d0;
}

.btn-primary {
    background-color: #4CAF50;
    color: white;
    padding: 10px 15px;
    font-size: 16px;
}

.btn-primary:hover {
    background-color: #45a049;
}

/* 加载状态指示器 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    display: none;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #4CAF50;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    margin-top: 15px;
    font-size: 18px;
    color: #333;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 按钮内加载动画 */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
    margin-right: 5px;
    vertical-align: middle;
}

/* 下载面板样式 */
#downloadPanel {
    display: none;
    margin-top: 20px;
    padding: 15px;
    background-color: #f0f0f0;
    border-radius: 5px;
    border: 1px solid #ddd;
}

#downloadPanel.active {
    display: block;
}

/* 下载进度样式 */
.download-progress {
    margin-top: 15px;
    padding: 10px;
    background-color: #fff;
    border-radius: 4px;
    display: none;
}

.download-progress.active {
    display: block;
}

.progress-text {
    text-align: center;
    color: #666;
    font-size: 14px;
}

/* 禁用状态下的按钮样式 */
.btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    opacity: 0.7;
}