* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

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

header {
    text-align: center;
    color: white;
    margin-bottom: 40px;
}

header h1 {
    font-size: 3em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

header p {
    font-size: 1.2em;
    opacity: 0.9;
}

/* 主体区域：左图右文布局 */
.main-section {
    display: flex;
    gap: 24px;
    margin-bottom: 30px;
    align-items: stretch; /* 让左右卡片高度一致，上下对齐 */
}

.upload-section {
    background: white;
    border-radius: 15px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    flex: 3;
    display: flex;
    flex-direction: column;
}

.upload-area {
    border: 3px dashed #ddd;
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    /* 宽高比例 3:4，使上传区域更接近商品图比例 */
    aspect-ratio: 3 / 4;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.upload-area:hover {
    border-color: #667eea;
    background-color: #f8f9ff;
}

.upload-area.dragover {
    border-color: #667eea;
    background-color: #f0f4ff;
}

.upload-icon {
    font-size: 60px;
    margin-bottom: 20px;
}

.upload-area p {
    font-size: 1.1em;
    color: #666;
    margin-bottom: 5px;
}

.upload-hint {
    font-size: 0.9em !important;
    color: #999 !important;
}

.image-preview {
    position: relative;
    display: none; /* 默认隐藏，由 JavaScript 控制显示 */
    width: 100%;
    aspect-ratio: 3 / 4;
    flex: 1; /* 填充上传区域剩余空间 */
    background: #f5f5f5; /* 添加背景色，让容器更完整 */
    border-radius: 10px;
    align-items: center;
    justify-content: center;
    overflow: hidden; /* 确保图片不会超出容器 */
}

.image-preview img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain; /* 自适应大小，保持原始比例，不裁剪 */
    border-radius: 10px;
}

.remove-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.remove-btn:hover {
    background: #ff4444;
    color: white;
}

.form-section {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    flex: 4;
    display: flex;
    flex-direction: column;
}

.form-section h2 {
    margin-bottom: 25px;
    color: #333;
    font-size: 1.5em;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
}

.form-group input,
.form-group textarea {
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* 让产品卖点输入框填充剩余空间 */
#description {
    flex: 1;
    min-height: 200px;
}

/* 让产品卖点所在的表单组填充剩余空间 */
.form-group:last-child {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* 表单容器填充高度 */
#productForm {
    display: flex;
    flex-direction: column;
    flex: 1;
    height: 100%;
}

/* 让产品卖点输入框更高一些，使右侧卡片与左侧图片区域更协调 */
#description {
    min-height: 160px;
}

.action-section {
    text-align: center;
    margin-bottom: 30px;
}

.generate-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.1em;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.generate-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}

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

.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

.hidden {
    display: none !important;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.result-section {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.result-section h2 {
    margin-bottom: 25px;
    color: #333;
    font-size: 1.5em;
}

.result-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.result-item h3 {
    margin-bottom: 15px;
    color: #555;
}

.prompt-box {
    background: #f5f5f5;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    max-height: 300px;
    overflow-y: auto;
    white-space: pre-wrap;
    font-family: monospace;
    font-size: 0.9em;
    line-height: 1.5;
}

.view-btn,
.copy-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.view-btn:hover,
.copy-btn:hover {
    background: #5a6fd8;
}

/* 模态框样式 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 15px;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.modal-body pre {
    background: #f5f5f5;
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.9em;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 20px;
    }

    .main-section {
        flex-direction: column;
    }

    header h1 {
        font-size: 2em;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .result-content {
        grid-template-columns: 1fr;
    }

    .modal-content {
        width: 95%;
    }
}