@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

body {
    font-family: 'Inter', 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background-color: #f8f9fa; /* 极淡灰白背景 */
    color: #2d3748;
    min-height: 100vh;
    padding: 20px;
    line-height: 1.6;
}

.container {
    max-width: 1280px; /* 缩小最大宽度，留出更多空白 */
    margin: 0 auto;
    padding: 0 40px; /* 增加两侧内边距 */
}

/* 顶部标题 */
.header-section {
    text-align: center;
    margin-bottom: 40px;
    padding: 40px 0;
}

h1 {
    font-size: 2.5rem;
    font-weight: 800;
    color: #1a202c;
    margin-bottom: 10px;
    letter-spacing: -0.025em;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: #718096;
    font-size: 1.1rem;
}

/* 主布局：左右分栏 */
.main-content {
    display: grid;
    grid-template-columns: 500px 1fr; /* 黄金比例调整，加宽左侧面板 */
    gap: 35px;
    margin-bottom: 40px;
    align-items: start;
}

.left-panel {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.right-panel {
    min-width: 0;
}

/* 卡片通用样式 */
.card {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    border: 1px solid #e2e8f0;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
}

.card h3 {
    font-size: 0.95rem; /* 稍微调小标题字体 */
    font-weight: 700;
    color: #2d3748;
    padding: 16px 20px; /* 减小内边距 */
    margin: 0;
    border-bottom: 1px solid #f7fafc;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #ffffff;
}

.card-body {
    padding: 24px;
}

/* 图标盒子 */
.icon-box {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* 徽章 */
.badge {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 4px;
    background: #edf2f7;
    color: #718096;
    margin-left: auto;
    font-weight: 500;
}
.badge-blue { background: #ebf8ff; color: #4299e1; }

/* 表单元素 */
.input-group { margin-bottom: 20px; }
.input-group:last-child { margin-bottom: 0; }

.input-group label {
    display: block;
    font-size: 0.85rem; /* 调小字体 */
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 6px; /* 减小间距 */
}

.input-group input,
.input-group textarea,
.input-group select,
#customImageModelInput,
#customVideoModelInput,
#imageUrls,
#customOptimizerModelInput,
#customNInput {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    font-size: 13px; /* 统一小字体 */
    color: #2d3748;
    transition: all 0.2s;
    background: #f7fafc;
}

.input-group input:focus,
.input-group textarea:focus,
.input-group select:focus,
#customImageModelInput:focus,
#customVideoModelInput:focus,
#imageUrls:focus,
#customOptimizerModelInput:focus,
#customNInput:focus {
    background: #fff;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
    outline: none;
}

/* 单独针对创意描述文本域优化 */
#prompt {
    font-size: 13px !important;
    line-height: 1.6;
}

.input-group textarea { resize: vertical; min-height: 100px; font-family: inherit; }

.highlight-group textarea {
    border-color: #e2e8f0;
    background: #fff;
    font-size: 1rem;
}
.highlight-group textarea:focus {
    border-color: #667eea;
}

/* 模型选择 */
.model-selection-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
/* 强制让多选框有足够高度 */
#imageModels {
    height: 150px !important;
    background: #fff;
}
#videoModels {
    height: 100px !important; /* 视频模型较少，减小高度 */
    background: #fff;
}

.model-column {
    display: flex;
    flex-direction: column;
}
.model-column label {
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
}

/* 参数网格 */
.param-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-top: 20px;
}

/* 上传区域 */
.upload-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.file-upload { position: relative; width: 100%; }

.file-upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 80px;
    border: 2px dashed #cbd5e0;
    border-radius: 12px;
    background: #f7fafc;
    cursor: pointer;
    transition: all 0.2s;
    color: #718096;
    font-size: 0.9rem;
    text-align: center;
    padding: 10px;
}

.file-upload-label:hover {
    border-color: #667eea;
    background: #ebf4ff;
    color: #5a67d8;
}

.upload-icon { font-size: 1.5rem; margin-bottom: 4px; display: block; }

.file-upload input[type="file"] { 
    position: absolute; 
    top: 0; left: 0; width: 100%; height: 100%; 
    opacity: 0; cursor: pointer; 
}

.url-input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.url-input-wrapper textarea {
    min-height: 40px;
    height: 40px;
    padding: 8px 12px;
}
.btn-url-load {
    width: 100%;
    padding: 6px;
    background: #e2e8f0;
    border: none;
    border-radius: 6px;
    color: #4a5568;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}
.btn-url-load.active {
    background: #667eea;
    color: white;
}

/* 图片预览 */
.image-preview-container {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}
.image-preview-container > div {
    position: relative;
    width: 60px;
    height: 60px;
}
.image-preview-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}
.delete-image-btn {
    position: absolute; top: -6px; right: -6px;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: #e53e3e; color: white;
    border: 2px solid white;
    font-size: 10px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
}

/* 操作栏 */
.action-bar {
    position: sticky;
    bottom: 20px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-primary {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 20px -10px rgba(102, 126, 234, 0.5);
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px -10px rgba(102, 126, 234, 0.6);
}
.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.mode-badge {
    text-align: center;
    font-size: 0.85rem;
    color: #718096;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    padding: 8px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* 右侧结果区域 - 增加空状态 */
.result-body {
    min-height: 600px; /* 加高 */
    display: flex;
    flex-direction: column;
    position: relative;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); /* 自适应填充，避免留白 */
    gap: 20px;
    flex-grow: 1;
    min-height: 300px;
}

/* 空状态样式 */
.empty-state {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #cbd5e0;
    pointer-events: none; /* 让点击穿透 */
}
.empty-state svg {
    width: 80px;
    height: 80px;
    margin-bottom: 15px;
    opacity: 0.5;
}
.empty-state p { font-size: 1.1rem; font-weight: 500; }

.generated-image {
    width: 100%;
    height: 100%; /* 撑满容器 */
    object-fit: cover; /* 保持比例裁剪填充 */
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: transform 0.2s;
    display: block;
}
.generated-image:hover { transform: scale(1.02); }

/* 结果中的分组容器 */
.result-prompt-info {
    background: #f8fafc;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    color: #4a5568;
    margin-bottom: 15px;
    border: 1px solid #edf2f7;
    word-break: break-all;
}

.btn-result-action {
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
}
.btn-result-action:hover {
    background: #f7fafc;
    border-color: #cbd5e0;
}

/* 日志区域优化 */
.log-section {
    margin-top: 20px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #4a5568;
    background: #edf2f7;
    border-bottom: 1px solid #e2e8f0;
}

.log-panel {
    background: #ffffff;
    color: #4a5568;
    padding: 16px;
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 0.85rem;
    height: 450px; /* 增加高度 */
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.5;
    resize: vertical; /* 允许垂直拖拽调整高度 */
    min-height: 200px;
}
.log-line { margin: 4px 0; border-bottom: 1px dashed #f0f0f0; padding-bottom: 2px; }
.log-info { color: #3182ce; }
.log-warn { color: #d69e2e; }
.log-error { color: #e53e3e; }

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}
.btn-icon:hover { background: #e2e8f0; }

/* 历史记录全宽卡片 */
.history-card { margin-top: 0; }
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #f7fafc;
}
.card-header h3 { border: none; padding: 0; }

.history-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 强制每行4个 */
    gap: 15px;
    padding: 20px;
}

@media (max-width: 1100px) {
    .history-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 800px) {
    .history-grid { grid-template-columns: repeat(2, 1fr); }
}

.history-item {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s;
    cursor: pointer;
    position: relative;
}
.history-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    border-color: #cbd5e0;
}
.history-item.selected {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
}

.history-image {
    width: 100%;
    height: 160px;
    object-fit: cover;
}
.history-prompt {
    padding: 8px 10px;
    font-size: 12px; /* 更小的字体 */
    color: #4a5568;
    line-height: 1.4;
}
.history-prompt strong {
    font-size: 12px; /* 标题也变小 */
}
.history-time {
    padding: 0 10px 8px;
    font-size: 11px; /* 更小的字体 */
    color: #a0aec0;
}

.history-logs {
    padding: 0 10px 10px;
}

.history-logs summary {
    font-size: 11px;
    cursor: pointer;
    color: #718096;
    margin-bottom: 4px;
    outline: none;
    font-weight: 500;
}

.history-logs pre {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 8px;
    font-size: 10px; /* 更小的字体 */
    color: #4a5568;
    max-height: 120px; /* 固定高度 */
    overflow-y: auto; /* 支持滚动 */
    white-space: pre-wrap;
    word-break: break-all;
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    margin: 0;
}

/* 自定义滚动条样式 */
.history-logs pre::-webkit-scrollbar {
    width: 4px;
}
.history-logs pre::-webkit-scrollbar-track {
    background: transparent;
}
.history-logs pre::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 2px;
}
.history-logs pre::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

.history-item-checkbox {
    position: absolute;
    top: 8px; left: 8px;
    transform: scale(1.1);
    z-index: 10;
}

.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    gap: 15px;
    border-top: 1px solid #f0f0f0;
}
.page-btn {
    padding: 6px 12px;
    border: 1px solid #e2e8f0;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    color: #4a5568;
    transition: all 0.2s;
}
.page-btn:hover:not(:disabled) {
    background: #f7fafc;
    border-color: #cbd5e0;
    color: #2d3748;
}
.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.page-info {
    font-size: 0.85rem;
    color: #718096;
}

.btn-outline {
    padding: 6px 16px;
    border: 1px solid #cbd5e0;
    background: white;
    color: #4a5568;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-outline:hover {
    border-color: #a0aec0;
    background: #f7fafc;
}
.btn-outline.danger { color: #e53e3e; border-color: #feb2b2; }
.btn-outline.danger:hover { background: #fff5f5; border-color: #fc8181; }

/* Loading */
.loading { display: none; padding: 40px; text-align: center; color: #718096; }
.loading.show { display: block; }
.spinner {
    border: 3px solid #edf2f7;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* 公告弹窗样式 (还原备份版并优化) */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.8); /* 增加透明度 */
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    color: #1a1a1a;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1); /* 柔和阴影 */
    padding: 20px 25px;
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    border-radius: 16px;
    max-width: 380px; /* 恢复原有宽度 */
    font-size: 14px;
    opacity: 0;
    transform: translateX(100%);
    transition: opacity 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94), transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    visibility: hidden;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
    visibility: visible;
}

.toast-content p { margin: 0; }
.toast-content strong { color: #434190; }
.toast-content a { color: #667eea; text-decoration: none; font-weight: 600;}
.toast-content a:hover { text-decoration: underline; }

.toast-header { font-size: 1.1em; font-weight: 600; color: #333; margin-bottom: 15px; border-bottom: none; padding-bottom: 0; display: block; }
.toast-section { margin-bottom: 12px; }
.toast-section > strong { display: block; margin-bottom: 8px; font-size: 1em; color: #434190; }
.toast-section ul { list-style: none; padding: 5px 0 0 5px; margin: 0; }
.toast-section code {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 3px 8px;
    border-radius: 6px;
    font-family: 'Segoe UI', sans-serif;
    font-weight: 500;
    margin: 4px 2px;
    display: inline-block;
    transition: transform 0.3s ease;
}

.toast-section code:hover {
    transform: scale(1.1) rotate(-2deg);
}

.toast-tips {
    background: rgba(102, 126, 234, 0.1); padding: 8px 12px; border-radius: 8px; font-size: 0.9em; margin-top: 10px; border-left: none; color: inherit;
}
.toast-tips strong { color: #667eea; }

.toast button {
    background: rgba(0,0,0,0.05);
    border: none;
    cursor: pointer;
    color: #888;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 15px;
    flex-shrink: 0;
    transition: background-color 0.3s, color 0.3s;
    position: static; /* 恢复静态定位 */
}

.toast button:hover {
    background-color: rgba(0,0,0,0.1);
    color: #333;
}

/* 新模型公告的特殊样式 */
.toast-section .new-model {
    background: linear-gradient(135deg, #f97794 0%, #623aa2 100%);
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(249, 119, 148, 0.4);
    transform: scale(1.05);
    transform-origin: left center;
    display: inline-block;
    transition: transform 0.3s ease;
    border: none; /* 移除边框 */
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 1em;
}

.toast-section .new-model:hover {
    transform: scale(1.2) rotate(-2deg);
}

.link-card {
    background: linear-gradient(to right, #f8f9fa, #e9ecef);
    padding: 8px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: #2d3748;
    font-size: 0.85rem;
    transition: all 0.2s;
    border: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.link-card:hover {
    background: #fff;
    border-color: #667eea;
    color: #667eea;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(102, 126, 234, 0.15);
}

.wechat-id {
    font-weight: 800;
    color: #2d3748;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    background: #f0fff4;
    border: 1px dashed #9ae6b4;
    transition: all 0.2s;
    margin-left: 5px;
}
.wechat-id:hover {
    background: #c6f6d5;
    border-color: #48bb78;
}
.wechat-id:active {
    transform: scale(0.95);
}

/* 提示信息 */
.toast-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: 50px;
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    z-index: 3000;
    display: none;
}
.toast-notification.show { display: block; animation: fadeInDown 0.3s; }
.toast-notification.success { background: #48bb78; }
.toast-notification.error { background: #f56565; }

@keyframes fadeInDown {
    from { opacity: 0; transform: translate(-50%, -20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* 响应式 */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    .action-bar {
        position: static;
    }
}

.custom-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 0.9rem;
    color: #4a5568;
    cursor: pointer;
}
.custom-checkbox input { margin: 0; }
