/* 全局样式 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Noto Sans SC', 'Microsoft YaHei', sans-serif;
}

body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

/* 头部样式 */
header {
    background: linear-gradient(90deg, #4a6fa5 0%, #2c4a76 100%);
    color: white;
    padding: 25px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    background: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm29 22c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zM32 63c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm57-13c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-9-21c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM60 91c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM35 41c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM12 60c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2z' fill='%23ffffff' fill-opacity='0.05' fill-rule='evenodd'/%3E%3C/svg%3E");
    z-index: 0;
    opacity: 0.6;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    position: relative;
    z-index: 1;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.2);
}

.app-description {
    font-size: 1.1rem;
    opacity: 0.9;
    position: relative;
    z-index: 1;
    max-width: 800px;
    margin: 0 auto;
}

/* 主内容区域 */
.main-content {
    display: flex;
    flex-wrap: wrap;
    padding: 25px;
    gap: 25px;
}

.upload-section, .controls-section, .preview-section, .layers-section {
    flex: 1;
    min-width: 320px;
    padding: 25px;
    background: #f8f9fa;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

.layers-section {
    min-width: 280px;
    max-width: 350px;
}

.section-title {
    font-size: 1.4rem;
    margin-bottom: 18px;
    color: #4a6fa5;
    padding-bottom: 10px;
    border-bottom: 2px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.subsection-title {
    font-size: 1.1rem;
    margin: 20px 0 12px 0;
    color: #4a6fa5;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 上传区域 */
.upload-area {
    border: 2px dashed #4a6fa5;
    border-radius: 10px;
    padding: 35px;
    text-align: center;
    margin-bottom: 20px;
    background: #edf2f7;
    transition: all 0.3s;
    cursor: pointer;
}

.upload-area:hover {
    background: #e2e8f0;
    transform: translateY(-2px);
}

.upload-area p {
    margin: 12px 0;
    color: #64748b;
}

.upload-btn {
    background: #4a6fa5;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s;
    margin-top: 12px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
}

.upload-btn:hover {
    background: #385785;
    transform: translateY(-2px);
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.15);
}

/* 图片预览 */
.uploaded-images, .saved-images-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 20px;
}

.image-preview {
    width: 90px;
    height: 90px;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
}

.image-preview:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 12px rgba(0, 0, 0, 0.15);
}

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

.image-tooltip {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px;
    font-size: 0.7rem;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 搜索功能 */
.search-container {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.search-input {
    flex: 1;
    padding: 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.95rem;
}

.clear-search-btn {
    background: #ef4444;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
}

.clear-search-btn:hover {
    background: #dc2626;
}

/* 控制组 */
.control-group {
    margin-bottom: 22px;
}

label {
    display: block;
    margin-bottom: 10px;
    font-weight: 500;
    color: #475569;
}

input, select, textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 1rem;
    transition: all 0.3s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #4a6fa5;
    box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.2);
}

/* 颜色选项 */
.color-options {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.color-option {
    width: 42px;
    height: 42px;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.color-option:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.color-option.selected {
    border-color: #4a6fa5;
    box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.3);
}

.custom-color-picker {
    height: 42px;
    cursor: pointer;
}

/* 比例按钮 */
.ratio-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.ratio-btn {
    flex: 1;
    min-width: 70px;
    padding: 10px;
    border: 2px solid #cbd5e1;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.ratio-btn:hover {
    border-color: #4a6fa5;
    background: #f1f5f9;
}

.ratio-btn.active {
    background: #4a6fa5;
    color: white;
    border-color: #4a6fa5;
}

/* 文字控制 */
.text-controls {
    display: flex;
    gap: 10px;
    margin: 10px 0;
}

.text-controls input,
.text-controls select {
    flex: 1;
}

/* 操作按钮 */
.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.action-btn {
    background: #64748b;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.3s;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.15);
}

.action-btn.primary {
    background: #10b981;
    grid-column: 1 / -1;
}

.action-btn.primary:hover {
    background: #059669;
}

/* 七牛云Logo区域 */
.qiniu-logo-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #e2e8f0;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.qiniu-logo {
    height: 40px;
    width: auto;
    object-fit: contain;
}

.logo-text {
    font-size: 0.9rem;
    color: #64748b;
}

/* 画布容器 */
.canvas-container {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
}

#canvas {
    max-width: 100%;
    border: 2px solid #cbd5e1;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    background: white;
}

/* 图层列表 */
.layers-list {
    max-height: 500px;
    overflow-y: auto;
}

.layer-item {
    background: white;
    padding: 12px;
    margin-bottom: 10px;
    border-radius: 8px;
    border: 2px solid #e2e8f0;
    cursor: pointer;
    transition: all 0.3s;
}

.layer-item:hover {
    border-color: #4a6fa5;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
}

.layer-item.active {
    border-color: #4a6fa5;
    background: #f0f4f8;
}

.layer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.layer-name {
    font-weight: 500;
    color: #334155;
}

.layer-controls {
    display: flex;
    gap: 6px;
}

.layer-btn {
    background: #e2e8f0;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.layer-btn:hover {
    background: #cbd5e1;
}

.layer-info {
    font-size: 0.85rem;
    color: #64748b;
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .main-content {
        flex-direction: column;
    }
    
    .layers-section {
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    h1 {
        font-size: 1.8rem;
    }
    
    .app-description {
        font-size: 0.95rem;
    }
    
    .action-buttons {
        grid-template-columns: 1fr;
    }
}

/* 滚动条样式 */
.layers-list::-webkit-scrollbar {
    width: 8px;
}

.layers-list::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.layers-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.layers-list::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* 弹窗样式 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s;
}

.modal.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    border-radius: 15px;
    max-width: 900px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 20px 25px;
    background: linear-gradient(90deg, #4a6fa5 0%, #2c4a76 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.modal-body {
    padding: 25px;
    max-height: calc(80vh - 80px);
    overflow-y: auto;
}

.modal-search {
    margin-bottom: 20px;
}

.modal-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e2e8f0;
}

.modal-tab {
    padding: 12px 20px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 1rem;
    color: #64748b;
    transition: all 0.3s;
}

.modal-tab:hover {
    color: #4a6fa5;
}

.modal-tab.active {
    color: #4a6fa5;
    border-bottom-color: #4a6fa5;
    font-weight: 500;
}

.modal-tab-content {
    display: none;
}

.modal-tab-content.active {
    display: block;
}

.modal-images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    max-height: 400px;
    overflow-y: auto;
}

.modal-image-item {
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s;
    background: white;
}

.modal-image-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
    border-color: #4a6fa5;
}

.modal-image-item img {
    width: 100%;
    height: 120px;
    object-fit: cover;
}

.modal-image-name {
    padding: 8px;
    font-size: 0.75rem;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #64748b;
}

.modal-upload-area {
    border: 2px dashed #4a6fa5;
    border-radius: 10px;
    padding: 40px;
    text-align: center;
    background: #edf2f7;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 20px;
}

.modal-upload-area:hover {
    background: #e2e8f0;
    transform: translateY(-2px);
}

.modal-empty {
    text-align: center;
    padding: 60px 20px;
    color: #94a3b8;
}

.modal-empty-icon {
    font-size: 4rem;
    margin-bottom: 15px;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .modal-images-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
    
    .modal-tabs {
        flex-wrap: wrap;
    }
    
    .modal-tab {
        font-size: 0.9rem;
        padding: 10px 15px;
    }
}

/* 图片缩放控制样式 - 增强版 */
.scale-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
}

.scale-slider {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: #e2e8f0;
    outline: none;
    -webkit-appearance: none;
}

.scale-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #4a6fa5;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.scale-slider::-webkit-slider-thumb:hover {
    background: #385785;
    transform: scale(1.2);
}

.scale-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #4a6fa5;
    cursor: pointer;
    border: none;
    transition: all 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.scale-slider::-moz-range-thumb:hover {
    background: #385785;
    transform: scale(1.2);
}

.scale-slider:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.scale-input-group {
    display: flex;
    align-items: center;
    gap: 4px;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    padding: 4px 8px;
    min-width: 80px;
    transition: all 0.3s;
}

.scale-input-group:focus-within {
    border-color: #4a6fa5;
    box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.1);
}

.scale-input {
    width: 50px;
    border: none;
    outline: none;
    font-weight: 600;
    color: #4a6fa5;
    font-size: 1rem;
    text-align: right;
    padding: 0;
    background: transparent;
}

.scale-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 移除number input的上下箭头 */
.scale-input::-webkit-outer-spin-button,
.scale-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.scale-input[type=number] {
    -moz-appearance: textfield;
}

.scale-unit {
    font-weight: 600;
    color: #64748b;
    font-size: 0.9rem;
}

.scale-reset-btn {
    background: #e2e8f0;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.scale-reset-btn:hover:not(:disabled) {
    background: #cbd5e1;
    transform: rotate(180deg);
}

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

.scale-presets {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.scale-preset-btn {
    padding: 6px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    background: white;
    color: #64748b;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

.scale-preset-btn:hover:not(:disabled) {
    border-color: #4a6fa5;
    color: #4a6fa5;
    background: #f8f9fa;
}

.scale-preset-btn.active {
    border-color: #4a6fa5;
    background: #4a6fa5;
    color: white;
}

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

.scale-tips {
    margin-top: 10px;
    font-size: 0.85rem;
    color: #64748b;
    line-height: 1.5;
    padding: 10px 12px;
    background: #f1f5f9;
    border-radius: 6px;
    border-left: 3px solid #4a6fa5;
}

#scaleControl:has(.scale-slider:disabled) {
    opacity: 0.6;
}

#scaleControl:has(.scale-slider:disabled) .scale-tips {
    background: #f8fafc;
    color: #94a3b8;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .scale-controls {
        flex-wrap: wrap;
    }
    
    .scale-slider {
        width: 100%;
        order: 2;
        margin-top: 8px;
    }
    
    .scale-input-group {
        order: 1;
    }
    
    .scale-reset-btn {
        order: 3;
    }
}
