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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Open Sans', 'Helvetica Neue', sans-serif;
    line-height: 1.6;
    background: #f5f7fa;
    height: 100vh;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: white;
    box-shadow: none;
    border-radius: 0;
}

/* 头部样式 */
header {
    background: white;
    color: #333;
    text-align: center;
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

header h1 {
    font-size: 1.5rem;
    margin-bottom: 5px;
    font-weight: 600;
    color: #1f2937;
}

header p {
    font-size: 0.9rem;
    color: #6b7280;
    opacity: 1;
}

/* 主体内容 */
main {
    flex: 1;
    display: flex;
    overflow: hidden;
    padding: 0;
}

/* 网格布局 */
.main-grid {
    display: grid;
    grid-template-columns: 300px 1fr 300px;
    gap: 0;
    height: 100%;
    width: 100%;
}

/* 控制面板 */
.control-panel {
    background: #f8f9fb;
    border-radius: 0;
    padding: 16px;
    box-shadow: none;
    border-right: 1px solid #e5e7eb;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 结果面板 */
.result-panel {
    background: #f8f9fb;
    border-radius: 0;
    padding: 16px;
    box-shadow: none;
    border-right: 1px solid #e5e7eb;
    overflow-y: auto;
    overflow-x: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* 结果面板内的section需要占满剩余高度 */
.result-panel .section-compact {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* 图库面板 */
.gallery-panel {
    background: #f8f9fb;
    border-radius: 0;
    padding: 16px;
    box-shadow: none;
    overflow-y: auto;
    overflow-x: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* 图库面板内的section需要占满剩余高度 */
.gallery-panel .section-compact {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.gallery-panel .section-compact .image-gallery {
    flex: 1;
}

/* 紧凑章节样式 */
.section-compact {
    margin-bottom: 0;
    background: white;
    border-radius: 8px;
    padding: 16px;
    border: 1px solid #e5e7eb;
}

.section-compact h3 {
    font-size: 0.95rem;
    margin-bottom: 12px;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

/* 输入行布局 */
.input-row {
    display: flex;
    gap: 10px;
}

.input-compact {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    background: #fafbfc;
}

.input-compact:focus {
    outline: none;
    border-color: #0B5345;
    background: white;
    box-shadow: 0 0 0 3px rgba(11, 83, 69, 0.1);
}

/* 表单组件 */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
    font-size: 0.95rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 10px;
    font-size: 16px;
    transition: all 0.3s ease;
    background: #fafbfc;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 紧凑表单组件 */
.section-compact textarea {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    background: #fafbfc;
    resize: vertical;
    min-height: 120px;
    font-family: inherit;
}

.section-compact textarea:focus {
    outline: none;
    border-color: #0B5345;
    background: white;
    box-shadow: 0 0 0 3px rgba(11, 83, 69, 0.1);
}

/* 提示词提示 */
.prompt-tip {
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 6px;
    font-style: italic;
}

/* 用时显示 */
.time-info {
    margin-top: 12px;
    padding: 8px 12px;
    background: #f3f4f6;
    border-radius: 6px;
    font-size: 0.85rem;
    color: #374151;
    text-align: center;
}

/* 历史图库 */
.image-gallery {
    height: 100%;
    overflow-y: auto;
}

.gallery-placeholder {
    text-align: center;
    color: #9ca3af;
    font-size: 0.85rem;
    padding: 20px;
}

.gallery-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-height: 100%;
    overflow-y: auto;
}

.gallery-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.gallery-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-color: #0B5345;
}

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

.gallery-item .gallery-time {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    color: white;
    font-size: 11px;
    padding: 6px 8px;
    text-align: center;
    font-weight: 500;
}

/* 设置齿轮按钮 */
.settings-gear {
    position: absolute;
    bottom: 20px;
    left: 20px;
}

.gear-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: #0B5345;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(11, 83, 69, 0.3);
}

.gear-btn:hover {
    background: #16A085;
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 4px 12px rgba(11, 83, 69, 0.4);
}

.gear-btn svg {
    transition: inherit;
}

/* API设置弹窗样式 */
.settings-input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.3s ease;
    background: white;
}

.settings-input:focus {
    outline: none;
    border-color: #0B5345;
    box-shadow: 0 0 0 3px rgba(11, 83, 69, 0.1);
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    justify-content: flex-end;
}

.primary-btn {
    padding: 10px 20px;
    background: linear-gradient(45deg, #0B5345, #16A085);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.primary-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(11, 83, 69, 0.3);
}

.secondary-btn {
    padding: 10px 20px;
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.secondary-btn:hover {
    background: #e5e7eb;
}

/* 立即获取按钮样式 */
.get-api-key-btn {
    margin-top: 8px;
    padding: 6px 12px;
    background: #f3f4f6;
    color: #0B5345;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.get-api-key-btn:hover {
    background: #0B5345;
    color: white;
    border-color: #0B5345;
    transform: translateY(-1px);
}

/* 模式选择按钮 */
.mode-buttons {
    display: flex;
    gap: 10px;
}

.mode-btn {
    flex: 1;
    padding: 10px 16px;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mode-btn:hover {
    background: #e9ecef;
    transform: translateY(-1px);
}

.mode-btn.active {
    background: linear-gradient(45deg, #0B5345, #16A085);
    color: white;
    border-color: #0B5345;
}

/* 文件上传区域 */
.upload-area {
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fafbfc;
    margin-bottom: 15px;
}

.upload-area:hover {
    border-color: #0B5345;
    background: rgba(11, 83, 69, 0.05);
}

.upload-area.dragover {
    border-color: #0B5345;
    background: rgba(11, 83, 69, 0.1);
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.upload-icon {
    font-size: 2rem;
    opacity: 0.7;
}

.upload-area p {
    color: #6b7280;
    font-size: 14px;
    margin: 0;
    line-height: 1.4;
}

.upload-area small {
    opacity: 0.8;
    font-size: 12px;
}

/* 上传图片计数 */
.upload-count {
    font-size: 0.9rem;
    color: #0B5345;
    font-weight: normal;
}

/* 已上传图片列表 */
.uploaded-images {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    margin-top: 15px;
}

.uploaded-image {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: #f8f9fa;
    border: 1px solid #e1e5e9;
}

.uploaded-image img {
    width: 100%;
    height: 80px;
    object-fit: cover;
}

.uploaded-image .remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(255, 0, 0, 0.8);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    line-height: 1;
    transition: all 0.3s ease;
}

.uploaded-image .remove-btn:hover {
    background: rgba(255, 0, 0, 1);
    transform: scale(1.1);
}

/* 生成按钮 */
.generate-btn {
    width: 100%;
    padding: 16px 32px;
    background: linear-gradient(45deg, #0B5345, #16A085);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.generate-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(11, 83, 69, 0.3);
}

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

/* 加载动画 */
.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

    100% {
        transform: rotate(360deg);
    }
}

/* 结果区域 */
.result-container {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

.result-placeholder {
    color: #6b7280;
    font-size: 16px;
}

.result-content {
    width: 100%;
}

.result-content img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    margin-bottom: 20px;
}

.result-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.result-actions button {
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.result-actions button:hover {
    background: #5a6fd8;
    transform: translateY(-2px);
}

.result-text {
    margin-top: 20px;
    padding: 20px;
    background: #f1f3f4;
    border-radius: 12px;
    border-left: 4px solid #667eea;
}

.result-text h3 {
    margin-bottom: 10px;
    color: #333;
}

.result-text p {
    color: #555;
    line-height: 1.6;
}

/* 模态框样式 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

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

@keyframes modalShow {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

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

.close {
    font-size: 24px;
    font-weight: bold;
    color: #999;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close:hover {
    color: #333;
}

.modal-body {
    padding: 25px;
}

.modal-body p {
    margin: 0;
    color: #555;
    line-height: 1.6;
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .main-grid {
        grid-template-columns: 280px 1fr 220px;
    }

    .control-panel,
    .result-panel,
    .gallery-panel {
        padding: 14px;
    }
}

@media (max-width: 768px) {
    body {
        overflow: auto;
    }

    .container {
        height: auto;
        min-height: 100vh;
    }

    header {
        padding: 16px;
    }

    header h1 {
        font-size: 1.4rem;
    }

    header p {
        font-size: 0.85rem;
    }

    .main-grid {
        grid-template-columns: 1fr;
        height: auto;
        min-height: auto;
        grid-template-areas:
            "control"
            "result"
            "gallery";
    }

    .control-panel {
        grid-area: control;
        order: 1;
        max-height: none;
        overflow-y: visible;
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
    }

    .result-panel {
        grid-area: result;
        order: 2;
        max-height: none;
        overflow-y: visible;
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
    }

    .gallery-panel {
        grid-area: gallery;
        order: 3;
        max-height: none;
        overflow-y: visible;
    }

    .image-gallery {
        max-height: 300px;
    }

    .section-compact {
        margin-bottom: 15px;
    }

    .input-row {
        flex-direction: column;
        gap: 8px;
    }

    .mode-buttons {
        gap: 8px;
    }

    .mode-btn {
        padding: 8px 12px;
        font-size: 13px;
    }

    .result-actions {
        flex-direction: column;
        gap: 10px;
    }

    .result-actions button {
        width: 100%;
    }

    .result-container {
        padding: 20px;
        min-height: 150px;
    }

    .uploaded-images {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 8px;
    }

    .uploaded-image img {
        height: 60px;
    }

    .upload-area {
        padding: 15px;
        margin-bottom: 10px;
    }

    .upload-icon {
        font-size: 1.5rem;
    }

    .upload-area p {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 5px;
    }

    header {
        padding: 15px 10px;
    }

    header h1 {
        font-size: 1.6rem;
    }

    header p {
        font-size: 1rem;
    }

    main {
        padding: 10px;
    }

    .control-panel,
    .result-panel {
        padding: 12px;
    }

    .section-compact h3 {
        font-size: 1rem;
        margin-bottom: 8px;
    }

    .input-compact,
    .section-compact textarea {
        padding: 6px 10px;
        font-size: 13px;
    }

    .section-compact textarea {
        min-height: 60px;
    }

    .mode-btn {
        padding: 6px 10px;
        font-size: 12px;
    }

    .generate-btn {
        padding: 12px 20px;
        font-size: 16px;
    }

    .upload-area {
        padding: 12px;
    }

    .upload-icon {
        font-size: 1.2rem;
    }

    .upload-area p {
        font-size: 12px;
    }

    .uploaded-images {
        grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
        gap: 6px;
    }

    .uploaded-image img {
        height: 50px;
    }

    .uploaded-image .remove-btn {
        width: 16px;
        height: 16px;
        font-size: 10px;
        top: 2px;
        right: 2px;
    }

    .result-container {
        padding: 15px;
        min-height: 120px;
    }

    .result-actions button {
        padding: 8px 16px;
        font-size: 14px;
    }

    .modal-content {
        width: 95%;
    }

    .modal-header,
    .modal-body {
        padding: 15px;
    }
}

@media (max-width: 360px) {
    header h1 {
        font-size: 1.4rem;
    }

    .section-compact {
        margin-bottom: 12px;
    }

    .section-compact h3 {
        font-size: 0.9rem;
    }

    .input-compact,
    .section-compact textarea {
        font-size: 12px;
    }

    .mode-btn {
        font-size: 11px;
    }

    .generate-btn {
        font-size: 14px;
    }
}