/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --header-height: 56px;
    --footer-height: 160px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background: radial-gradient(1200px 600px at 10% 0%, #0b1020 0%, #111827 45%, #0a0f1e 100%);
    min-height: 100vh;
    color: #cbd5e1;
    overflow: hidden; /* 仅让中间区域滚动 */
}

.container {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0; /* 外围不留空 */
}

/* 头部样式 */
.header {
    background: rgba(17, 24, 39, 0.92);
    backdrop-filter: blur(10px);
    border-radius: 0; /* 贴边无圆角 */
    padding: 8px 0; /* 左右不留空 */
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 900;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    width: 100%;
    margin: 0; /* 自适应全宽 */
    padding: 0 12px; /* 内部少量留白，非外围 */
}

.title {
    font-size: 20px; /* 更紧凑字号 */
    font-weight: 700;
    color: #a78bfa;
    display: flex;
    align-items: center;
    gap: 10px;
}

.title i {
    font-size: 24px; /* 更紧凑图标 */
    background: linear-gradient(45deg, #7c3aed, #06b6d4);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.api-config {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.config-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.config-item label {
    font-weight: 600;
    color: #cbd5e1;
    font-size: 12px; /* 更紧凑字号 */
}

.config-item input {
    padding: 8px 12px; /* 更紧凑内边距 */
    border: 1px solid #334155;
    background: #0f172a;
    color: #e5e7eb;
    border-radius: 8px;
    font-size: 13px;
    transition: all 0.3s ease;
    min-width: 180px;
}

.config-item input:focus {
    outline: none;
    border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
}

/* 主要内容区域 */
.main-content {
    display: block;
    margin-top: calc(var(--header-height) + 12px);
    margin-bottom: calc(var(--footer-height));
}

/* 生成记录区域 */
.gallery-section {
    background: rgba(17, 24, 39, 0.92);
    backdrop-filter: blur(10px);
    border-radius: 0; /* 贴边无圆角 */
    padding: 16px; /* 内部留白 */
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
    position: fixed;
    top: var(--header-height);
    bottom: var(--footer-height);
    left: 0;
    right: 0;
    overflow-y: auto; /* 历史记录滚动 */
    z-index: 800;
}

.section-title {
    font-size: 20px;
    font-weight: 600;
    color: #e5e7eb;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    min-height: 200px;
}

.empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #94a3b8;
    text-align: center;
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.gallery-item {
    background: #0b1220;
    border: 1px solid #1f2937;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    transition: all 0.3s ease;
    cursor: pointer;
}

.gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

.gallery-item img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.gallery-item-info {
    padding: 16px;
}

.gallery-item-prompt {
    font-size: 14px;
    color: #94a3b8;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.gallery-item-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    font-size: 12px;
    color: #64748b;
}

/* 输入区域 */
.input-section {
    background: rgba(17, 24, 39, 0.92);
    backdrop-filter: blur(10px);
    border-radius: 0; /* 贴边无圆角 */
    padding: 12px 16px; /* 更紧凑 */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 900; /* 置底固定 */
}

.input-container {
    display: flex;
    flex-direction: column;
    gap: 12px; /* 更紧凑 */
    width: 100%;
    margin: 0; /* 全宽自适应 */
}

/* 参数设置行 */
.params-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px; /* 更紧凑 */
    flex-wrap: wrap;
}

/* 尺寸选择器 */
.size-selector {
    display: flex;
    align-items: center;
    gap: 8px; /* 更紧凑 */
}

.size-selector label {
    font-weight: 600;
    color: #cbd5e1;
    min-width: 60px;
    font-size: 12px; /* 更紧凑字号 */
}

.size-options {
    display: flex;
    gap: 4px; /* 更紧凑 */
}

.size-btn {
    padding: 4px 10px; /* 更紧凑 */
    border: 1px solid #334155;
    background: #0b1220;
    color: #e5e7eb;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 13px;
}

.size-btn:hover {
    border-color: #7c3aed;
    color: #7c3aed;
}

.size-btn.active {
    background: #7c3aed;
    border-color: #7c3aed;
    color: white;
}

/* 水印开关 */
.watermark-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
}

.watermark-toggle label {
    font-weight: 600;
    color: #cbd5e1;
    min-width: 70px;
    font-size: 14px;
}

.toggle-switch {
    position: relative;
}

.toggle-switch input {
    display: none;
}

.toggle-label {
    display: block;
    width: 50px;
    height: 26px;
    background: #334155;
    border-radius: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.toggle-slider {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: #f8fafc;
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.toggle-switch input:checked + .toggle-label {
    background: #7c3aed;
}

.toggle-switch input:checked + .toggle-label .toggle-slider {
    right: 3px;
    left: auto;
}

/* 提示词容器 */
.prompt-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 提示词输入包装器 */
.prompt-input-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 6px; /* 更紧凑 */
    background: #0b1220;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 10px; /* 更紧凑 */
    transition: all 0.3s ease;
}

.prompt-input-wrapper:focus-within {
    border-color: #7c3aed;
    box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.2);
}

/* 图片上传区域 */
.image-upload-area {
    width: 40px; /* 更紧凑 */
    height: 40px; /* 更紧凑 */
    border: 2px dashed #334155;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    background: #0f172a;
}

.image-upload-area:hover {
    border-color: #7c3aed;
    background: rgba(124, 58, 237, 0.06);
}

.upload-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #94a3b8;
    font-size: 18px;
}

.uploaded-thumbnails {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    background: #0f172a;
    border-radius: 6px;
}

.image-upload-area.has-images .upload-placeholder {
    display: none;
}

.image-upload-area.has-images .uploaded-thumbnails {
    display: flex;
}

.thumbnail-item {
    width: 100%;
    height: 100%;
    position: relative;
    border-radius: 6px;
    overflow: hidden;
}

.thumbnail-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

.thumbnail-count {
    position: absolute;
    bottom: 2px;
    right: 2px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 10px;
    padding: 1px 4px;
    border-radius: 8px;
    min-width: 16px;
    text-align: center;
}

.remove-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    background: rgba(255, 0, 0, 0.8);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.thumbnail-item:hover .remove-btn {
    opacity: 1;
}

.remove-btn:hover {
    background: rgba(255, 0, 0, 1);
}

/* 提示词输入框 */
#promptInput {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    background: transparent;
    color: #e5e7eb;
    line-height: 1.5;
    min-height: 32px; /* 更紧凑 */
}

#promptInput::placeholder {
    color: #64748b;
}

/* 生成按钮 */
.generate-btn {
    background: linear-gradient(135deg, #7c3aed 0%, #06b6d4 100%);
    color: white;
    border: none;
    border-radius: 8px;
    width: 36px; /* 更紧凑 */
    height: 36px; /* 更紧凑 */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.generate-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.45);
}

.generate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}



/* 输入操作区域 */
.input-actions {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-top: 8px;
}

.mode-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    color: #6b7280;
    font-size: 14px;
}

/* 加载遮罩 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-overlay.show {
    display: flex;
}

.loading-content {
    background: rgba(17, 24, 39, 0.96);
    color: #e5e7eb;
    padding: 40px;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 16px 64px rgba(0, 0, 0, 0.6);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #334155;
    border-top: 4px solid #7c3aed;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    z-index: 1001;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: rgba(17, 24, 39, 0.96);
    color: #e5e7eb;
    border-radius: 16px;
    padding: 24px;
    max-width: 90vw;
    max-height: 90vh;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    box-shadow: 0 16px 64px rgba(0, 0, 0, 0.6);
}

.close {
    position: absolute;
    top: 16px;
    right: 20px;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    color: #94a3b8;
    transition: color 0.3s ease;
}

.close:hover {
    color: #e5e7eb;
}

#modalImage {
    max-width: 100%;
    max-height: 60vh;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.modal-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.action-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.download-btn {
    background: #10b981;
    color: white;
}

.download-btn:hover {
    background: #059669;
    transform: translateY(-2px);
}

.regenerate-btn {
    background: #f59e0b;
    color: white;
}

.regenerate-btn:hover {
    background: #d97706;
    transform: translateY(-2px);
}

.edit-btn {
    background: #6366f1;
    color: white;
}

.edit-btn:hover {
    background: #4f46e5;
    transform: translateY(-2px);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 12px;
    }
    
    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .api-config {
        width: 100%;
    }
    
    .config-item input {
        min-width: 100%;
    }
    
    .size-selector,
    .watermark-toggle {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .input-actions {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
    
    .generate-btn {
        justify-content: center;
    }
    
    .modal-actions {
        flex-direction: column;
        width: 100%;
    }
    
    .action-btn {
        justify-content: center;
    }
}
/* 提示词输入框拖拽高亮 */
#promptInput.drop-target {
    outline: 2px dashed #6c63ff;
    background: #f7f6ff;
}