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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f8f9fa;
    color: #333;
    line-height: 1.6;
}

/* 导航栏 */
.navbar {
    background: linear-gradient(135deg, #ff6b9d, #ff8e9f);
    color: white;
    padding: 1rem 2rem;
    box-shadow: 0 2px 10px rgba(255, 107, 157, 0.3);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand h1 {
    font-size: 1.8rem;
    font-weight: 600;
    margin: 0;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.api-mode-indicator {
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.2);
    padding: 0.3rem 0.6rem;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.api-mode-indicator.mock {
    background: rgba(255, 193, 7, 0.9);
    color: #333;
    border-color: rgba(255, 193, 7, 1);
}

.api-mode-indicator.real {
    background: rgba(40, 167, 69, 0.9);
    color: white;
    border-color: rgba(40, 167, 69, 1);
}

.toggle-mode-btn {
    background: rgba(255, 255, 255, 0.2) !important;
    color: white !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    font-size: 0.8rem !important;
    padding: 0.4rem 0.8rem !important;
}

.toggle-mode-btn:hover {
    background: rgba(255, 255, 255, 0.3) !important;
}

/* 步骤条 */
.stepper {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    background: white;
    margin-bottom: 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.step {
    display: flex;
    align-items: center;
    margin: 0 1rem;
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.step.active {
    opacity: 1;
}

.step.completed {
    opacity: 0.8;
}

.step-number {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    margin-right: 0.5rem;
    transition: all 0.3s ease;
}

.step.active .step-number {
    background: linear-gradient(135deg, #ff6b9d, #ff8e9f);
    color: white;
}

.step.completed .step-number {
    background: #28a745;
    color: white;
}

.step-label {
    font-size: 0.9rem;
    font-weight: 500;
}

/* 页面容器 */
.page-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 1rem;
}

.page {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.page.active {
    display: block;
}

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

/* 卡片 */
.card {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
    margin-bottom: 1.5rem;
}

.card h2 {
    color: #333;
    margin-bottom: 1.5rem;
    text-align: center;
    font-weight: 600;
}

.card h3 {
    color: #555;
    margin: 1.5rem 0 1rem 0;
    font-weight: 500;
}

/* 按钮 */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: all 0.3s ease;
    min-width: 120px;
}

.btn-primary {
    background: linear-gradient(135deg, #ff6b9d, #ff8e9f);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #ff5a8c, #ff7d8e);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 107, 157, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #545b62;
    transform: translateY(-2px);
}

.btn-success {
    background: #28a745;
    color: white;
}

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

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    min-width: auto;
}

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

/* 按钮加载状态 - 简化版本 */
.btn.loading {
    opacity: 0.8;
    pointer-events: none;
    position: relative;
    transform: scale(0.98);
}

/* 按钮点击反馈 */
.btn:active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
}

.btn {
    transition: all 0.2s ease;
}

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

/* 表单元素 */
textarea, input, select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    font-family: inherit;
}

textarea:focus, input:focus, select:focus {
    outline: none;
    border-color: #ff6b9d;
}

textarea {
    resize: vertical;
    min-height: 120px;
}

.form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px 12px;
    padding-right: 40px;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #555;
}

/* 输入提示 */
.input-tips {
    text-align: right;
    font-size: 0.8rem;
    color: #6c757d;
    margin-top: 0.5rem;
    margin-bottom: 1.5rem;
}

/* 标签 */
.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tag {
    background: linear-gradient(135deg, #ff6b9d20, #ff8e9f20);
    color: #ff6b9d;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.9rem;
    border: 1px solid #ff6b9d40;
}

/* 意境描述框 */
.description-box {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border: 1px solid #dee2e6;
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.description-text {
    color: #495057;
    font-size: 0.95rem;
    line-height: 1.5;
    margin: 0;
    font-style: italic;
}

/* 提示词显示 */
.prompt-display {
    margin: 1rem 0;
}

.prompt-section {
    margin-bottom: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
}

.prompt-section label {
    font-weight: 600;
    color: #555;
    margin-bottom: 0.5rem;
    display: block;
}

/* 提示词编辑容器 */
.prompt-edit-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.prompt-textarea {
    width: 100%;
    min-height: 120px;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #495057;
    background: white;
    resize: vertical;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.prompt-textarea:focus {
    border-color: #ff6b9d;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(255, 107, 157, 0.25);
}

.prompt-textarea::placeholder {
    color: #6c757d;
    opacity: 0.8;
}

.prompt-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.prompt-text {
    background: white;
    padding: 1rem;
    border-radius: 6px;
    border: 1px solid #e9ecef;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* 加载动画 */
.loading {
    text-align: center;
    padding: 3rem 0;
    background: linear-gradient(135deg, #f8f9fa, #ffffff);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    margin: 1rem 0;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #ff6b9d;
    border-right: 4px solid #ff8e9f;
    border-radius: 50%;
    animation: spin 1.2s linear infinite;
    margin: 0 auto 1.5rem;
    box-shadow: 0 2px 10px rgba(255, 107, 157, 0.3);
}

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

/* 进度条 */
.progress-bar {
    width: 100%;
    height: 6px;
    background-color: #e9ecef;
    border-radius: 3px;
    margin-top: 1rem;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff6b9d, #ff8e9f);
    border-radius: 3px;
    animation: progress 3s ease-in-out infinite;
}

@keyframes progress {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

/* 图片轮播 */
.image-carousel {
    position: relative;
    margin: 1.5rem 0;
}

.carousel-container {
    overflow: hidden;
    border-radius: 12px;
}

.images-grid {
    display: flex;
    transition: transform 0.3s ease;
}

.image-item {
    min-width: 100%;
    position: relative;
}

.image-item img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
}

.carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    padding: 1rem;
    font-size: 1.2rem;
    cursor: pointer;
    border-radius: 50%;
    transition: background 0.3s ease;
    z-index: 10;
}

.carousel-btn:hover {
    background: rgba(0, 0, 0, 0.7);
}

.carousel-btn.prev {
    left: 1rem;
}

.carousel-btn.next {
    right: 1rem;
}

.image-actions {
    text-align: center;
    margin-top: 1rem;
}

/* 历史导航 */
.history-navigation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.btn-history {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    color: #495057;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-history:hover {
    background: #ff6b6b;
    color: white;
    border-color: #ff6b6b;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn-history:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.history-indicator {
    font-size: 14px;
    color: #6c757d;
    font-weight: 500;
    min-width: 60px;
    text-align: center;
    padding: 0 0.5rem;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* 模板选择 */
.template-selector {
    margin-bottom: 2rem;
}

.template-options {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.template-btn {
    padding: 0.8rem 1.5rem;
    border: 2px solid #e9ecef;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.template-btn:hover {
    border-color: #ff6b9d;
    color: #ff6b9d;
}

.template-btn.active {
    background: linear-gradient(135deg, #ff6b9d, #ff8e9f);
    color: white;
    border-color: transparent;
}

/* 预览容器 */
.preview-container {
    display: flex;
    justify-content: center;
    margin: 2rem 0;
}

.preview-canvas {
    width: 100%;
    max-width: 490px; /* 450 + 40px padding */
    height: auto;
    min-height: 640px; /* 600 + 40px padding */
    border: 1px solid #e9ecef;
    border-radius: 12px;
    overflow: visible;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    position: relative;
    margin: 0 auto;
}

/* 模板样式 */
.template-big-title {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
}

.template-big-title img {
    width: 100%;
    height: 70%;
    object-fit: cover;
    border-radius: 12px 12px 0 0;
}

.template-big-title .title-overlay {
    height: 30%;
    padding: 1rem;
    background: linear-gradient(135deg, #ff6b9d, #ff8e9f);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    border-radius: 0 0 12px 12px;
}

.template-big-title .title-overlay h1 {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
    margin: 0;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.template-horizontal {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: row;
}

.template-horizontal .title-section {
    width: 40%;
    padding: 1rem;
    background: linear-gradient(135deg, #ff6b9d, #ff8e9f);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.template-horizontal .title-section h1 {
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.3;
    margin: 0;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
}

.template-horizontal img {
    width: 60%;
    height: 100%;
    object-fit: cover;
}

.template-card {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 12px;
    overflow: hidden;
}

.template-card img {
    width: 100%;
    height: 75%;
    object-fit: cover;
}

.template-card .card-content {
    height: 25%;
    padding: 0.8rem;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.template-card .card-content h1 {
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.3;
    margin: 0;
    color: #333;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* 图片轮播优化 */
.image-item {
    min-width: 100%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f8f9fa;
    min-height: 300px;
}

.image-item img {
    max-width: 100%;
    max-height: 400px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* 重试选项 */
.retry-options {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    padding: 1.5rem;
    margin: 1rem 0;
    text-align: center;
}

.retry-message h3 {
    color: #856404;
    margin-bottom: 0.5rem;
}

.retry-message p {
    color: #856404;
    margin-bottom: 1rem;
}

.retry-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.retry-tips {
    font-size: 0.9rem;
    color: #6c757d;
    font-style: italic;
}

/* 加载状态优化 */
.loading-tips {
    margin-top: 1rem;
    text-align: center;
}

.loading-tips p {
    color: #6c757d;
    font-size: 0.9rem;
    margin: 0.3rem 0;
    opacity: 0.8;
}

/* 分析步骤进度点动画 */
.loading-progress {
    margin: 1.5rem 0;
    text-align: center;
}

.progress-dots {
    display: inline-flex;
    gap: 0.5rem;
    align-items: center;
}

.progress-dots .dot {
    width: 8px;
    height: 8px;
    background: #ff6b9d;
    border-radius: 50%;
    display: inline-block;
    animation: dotPulse 1.5s ease-in-out infinite;
}

.progress-dots .dot:nth-child(2) {
    animation-delay: 0.3s;
}

.progress-dots .dot:nth-child(3) {
    animation-delay: 0.6s;
}

@keyframes dotPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
    }
}

@keyframes stepPulse {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(255, 107, 157, 0.3);
        transform: scale(1.05);
    }
    50% {
        box-shadow: 0 8px 25px rgba(255, 107, 157, 0.5);
        transform: scale(1.08);
    }
}

@keyframes iconBounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-3px);
    }
    60% {
        transform: translateY(-1px);
    }
}

/* 生成步骤指示器 */
.loading-steps {
    margin: 2rem 0;
    padding: 0 1rem;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem 1rem;
    margin: 0.5rem 0;
    border-radius: 8px;
    transition: all 0.3s ease;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    opacity: 0.6;
}

.loading-steps .step-item.active,
#analyze-loading-steps .step-item.active,
#loading-steps .step-item.active {
    background: linear-gradient(135deg, #ff6b9d30, #ff8e9f30) !important;
    border: 2px solid #ff6b9d !important;
    opacity: 1 !important;
    transform: scale(1.05) !important;
    box-shadow: 0 4px 12px rgba(255, 107, 157, 0.3) !important;
    animation: stepPulse 2s ease-in-out infinite !important;
}

.loading-steps .step-item.active .step-icon,
#analyze-loading-steps .step-item.active .step-icon,
#loading-steps .step-item.active .step-icon {
    animation: iconBounce 1.5s ease-in-out infinite !important;
    transform-origin: center !important;
}

.loading-steps .step-item.active .step-text,
#analyze-loading-steps .step-item.active .step-text,
#loading-steps .step-item.active .step-text {
    color: #ff6b9d !important;
    font-weight: 700 !important;
}

.loading-steps .step-item.completed,
#analyze-loading-steps .step-item.completed,
#loading-steps .step-item.completed {
    background: linear-gradient(135deg, #28a74530, #20c99730) !important;
    border: 2px solid #28a745 !important;
    opacity: 0.9 !important;
    transform: scale(1.0) !important;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.25) !important;
    animation: none !important;
}

.loading-steps .step-item.completed .step-icon,
#analyze-loading-steps .step-item.completed .step-icon,
#loading-steps .step-item.completed .step-icon {
    animation: none !important;
}

.loading-steps .step-item.completed .step-text,
#analyze-loading-steps .step-item.completed .step-text,
#loading-steps .step-item.completed .step-text {
    color: #28a745 !important;
    font-weight: 600 !important;
}

.step-icon {
    font-size: 1.2rem;
    min-width: 24px;
    text-align: center;
}

.step-text {
    font-size: 0.9rem;
    font-weight: 500;
    color: #495057;
}

/* 加载消息动态效果 */
.loading-message {
    display: inline-block;
    margin: 1rem 0;
    font-weight: 500;
    color: #495057;
}

/* 增强转场动画 */
.loading {
    transition: opacity 0.3s ease-in-out;
}

.loading.hidden {
    opacity: 0;
    pointer-events: none;
}

/* 导出设置 */
.export-options {
    margin-bottom: 2rem;
}

.export-preview {
    text-align: center;
    margin: 2rem 0;
    min-height: 400px;
}

/* 导出预览容器样式 */
.export-preview-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    padding: 2rem;
    background: #fafbfc;
    border-radius: 12px;
    border: 2px solid #e9ecef;
}

.export-info {
    text-align: center;
}

.export-info h3 {
    margin: 0 0 0.5rem 0;
    color: #2c3e50;
    font-size: 1.2rem;
}

.export-info p {
    margin: 0;
    color: #6c757d;
    font-size: 0.9rem;
}

.export-iframe-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.export-actions {
    text-align: center;
    margin-top: 1rem;
}

.export-note {
    font-size: 0.85rem;
    color: #6c757d;
    margin: 0;
    font-style: italic;
}

.export-error {
    text-align: center;
    padding: 2rem;
    background: #fff5f5;
    border: 2px solid #feb2b2;
    border-radius: 12px;
    color: #c53030;
}

.export-error h3 {
    margin: 0 0 1rem 0;
    color: #c53030;
}

.export-error p {
    margin: 0.5rem 0;
}

/* 操作按钮组 */
.action-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid #e9ecef;
}

/* Toast 消息 */
.toast {
    position: fixed;
    top: 2rem;
    right: 2rem;
    background: #333;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
}

.toast.success {
    background: #28a745;
}

.toast.error {
    background: #dc3545;
}

.toast.warning {
    background: #ffc107;
    color: #333;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

#toast-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
}

/* 工具类 */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mb-1 {
    margin-bottom: 1rem;
}

.mt-1 {
    margin-top: 1rem;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .page-container {
        padding: 0 0.5rem;
    }
    
    .card {
        padding: 1.5rem;
        margin-bottom: 1rem;
    }
    
    .stepper {
        padding: 1rem;
        flex-wrap: wrap;
    }
    
    .step {
        margin: 0.5rem;
    }
    
    .step-label {
        font-size: 0.8rem;
    }
    
    .template-options {
        flex-wrap: wrap;
    }
    
    .action-buttons {
        flex-wrap: wrap;
    }
    
    .btn {
        min-width: auto;
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .toast {
        right: 1rem;
        left: 1rem;
        top: 1rem;
    }
}