/* 占位符相关样式 */
.placeholder-header {
    margin-bottom: 16px;
    padding: 12px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.placeholder-header h5 {
    margin: 0 0 8px 0;
    color: #495057;
    font-size: 16px;
    font-weight: 600;
}

.placeholder-info {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.placeholder-info span {
    color: #6c757d;
    font-size: 13px;
    background: rgba(255, 255, 255, 0.7);
    padding: 4px 8px;
    border-radius: 4px;
}

/* 图片占位符网格 */
.image-placeholder-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

/* 占位符网格在不同数量下的布局优化，确保并排显示 */
.image-placeholder-grid.single-image {
    grid-template-columns: 1fr;
    justify-content: center;
    max-width: 400px;
    margin: 12px auto 0;
}

.image-placeholder-grid.two-images {
    grid-template-columns: 1fr 1fr;
}

.image-placeholder-grid.multiple-images {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

/* 单个图片占位符 */
.image-placeholder {
    position: relative;
    background: #ffffff;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    overflow: hidden;
    min-height: 200px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.image-placeholder:hover {
    border-color: #dee2e6;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* 占位符内容 */
.placeholder-content {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 200px;
}

/* 🔥 新增：骨架屏动画样式 */
.history-skeleton-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.75rem;
}

.history-skeleton-item {
    display: flex;
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 8px;
    gap: 10px;
    opacity: 0.8;
}

.skeleton-thumbnail {
    width: 48px;
    height: 48px;
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e0e0e0 50%,
        #f0f0f0 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 6px;
    flex-shrink: 0;
}

.skeleton-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    justify-content: center;
}

.skeleton-line {
    height: 12px;
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e0e0e0 50%,
        #f0f0f0 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 6px;
}

.skeleton-line.skeleton-title {
    width: 70%;
    height: 14px;
}

.skeleton-line.skeleton-text {
    width: 90%;
    height: 12px;
}

.skeleton-line.skeleton-meta {
    width: 50%;
    height: 10px;
    margin-top: 4px;
}

/* 骨架屏动画关键帧 */
@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* 骨架屏项目的显示动画 */
.history-skeleton-item:nth-child(1) {
    animation-delay: 0s;
}

.history-skeleton-item:nth-child(2) {
    animation-delay: 0.1s;
}

.history-skeleton-item:nth-child(3) {
    animation-delay: 0.2s;
}

.history-skeleton-item:nth-child(4) {
    animation-delay: 0.3s;
}

/* 骨架屏项目的显示动画 */
.history-skeleton-item {
    animation: fadeInSkeleton 0.3s ease-out;
}

@keyframes fadeInSkeleton {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 0.8;
        transform: translateY(0);
    }
}

/* 🔥 注释：原有的骨架屏样式已更新为上面的新样式 */

/* 占位符覆盖层 */
.placeholder-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(248, 249, 250, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    text-align: center;
    gap: 12px;
}

.placeholder-text {
    color: #495057;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
}

.placeholder-progress {
    width: 100%;
    max-width: 120px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
}

.placeholder-progress .progress-bar {
    width: 100%;
    height: 4px;
    background: #e9ecef;
    border-radius: 2px;
    overflow: hidden;
}

.placeholder-progress .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #28a745, #20c997);
    border-radius: 2px;
    transition: width 0.5s ease;
    min-width: 2px;
}

.placeholder-progress .progress-text {
    font-size: 11px;
    color: #6c757d;
    font-weight: 500;
}

/* 完成动画 */
.image-placeholder.completing {
    border-color: #e9ecef; /* 去掉绿色边框，保持中性边框 */
    animation: completing-pulse 1s ease-in-out;
}

.image-placeholder.completed {
    border-color: #e9ecef; /* 去掉绿色边框，保持中性边框 */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05); /* 与默认一致 */
}

.image-placeholder.completed .placeholder-overlay {
    display: none;
}

@keyframes completing-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1); /* 去掉绿色高亮 */
    }
}

/* 错误状态 */
.image-placeholder.error {
    border-color: #dc3545;
    background: #fff5f5;
}

.placeholder-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #dc3545;
    font-size: 14px;
    gap: 8px;
}

.placeholder-error i {
    font-size: 24px;
    margin-bottom: 8px;
}

/* 超时状态 */
.image-placeholder.timeout {
    border-color: #ffc107;
    background: #fffaf0;
}

.placeholder-timeout {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #856404;
    font-size: 14px;
    gap: 8px;
}

.placeholder-timeout i {
    font-size: 24px;
    margin-bottom: 8px;
}

/* 生成完成状态 */
.generation-completed {
    opacity: 1;
}

.generation-completed .placeholder-header {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border-color: #c3e6cb;
}

.generation-completed .placeholder-header h5 {
    color: #155724;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .image-placeholder-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 12px;
    }
    
    .image-placeholder {
        min-height: 150px;
    }
    
    .placeholder-content {
        min-height: 150px;
    }
    
    .skeleton-image {
        min-height: 80px;
    }
    
    .placeholder-header {
        padding: 8px;
        margin-bottom: 12px;
    }
    
    .placeholder-info {
        gap: 8px;
    }
    
    .placeholder-info span {
        font-size: 12px;
        padding: 3px 6px;
    }
}

@media (max-width: 480px) {
    .image-placeholder-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .image-placeholder {
        min-height: 120px;
    }
    
    .placeholder-content {
        min-height: 120px;
    }
    
    .placeholder-overlay {
        padding: 12px;
        gap: 8px;
    }
    
    .placeholder-text {
        font-size: 13px;
    }
}

/* 加载消息样式 */
.loading-message {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 12px;
    border: 1px solid #e9ecef;
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e9ecef;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    flex-shrink: 0;
    margin-top: 2px;
}

.loading-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.loading-text {
    color: #495057;
    font-size: 14px;
    line-height: 1.4;
}

.progress-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: #e9ecef;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #007bff, #0056b3);
    border-radius: 3px;
    transition: width 0.3s ease;
    min-width: 2px;
}

.progress-text {
    font-size: 12px;
    color: #6c757d;
    min-width: 35px;
    text-align: right;
}

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

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

/* 响应式调整 */
@media (max-width: 480px) {
    .loading-message {
        padding: 12px;
        gap: 8px;
    }

    .loading-spinner {
        width: 16px;
        height: 16px;
    }

    .loading-text {
        font-size: 13px;
    }

    .progress-text {
        font-size: 11px;
        min-width: 30px;
    }
}

.image-edit-chat-container {
    height: 100vh;
    /* 使用全视口高度 */
    max-height: 100vh;
    /* 确保不超过视口高度 */
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow: hidden;
    /* 防止容器本身产生滚动条 */
    position: fixed;
    /* 固定定位，避免受body padding影响 */
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    padding-top: 64px;
    /* 为导航栏留出空间 */
    box-sizing: border-box;
    /* 确保padding包含在总高度内 */
}

/* 主内容区域 */
.main-content-wrapper {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-height: 0;
    /* 确保在flex容器中正确收缩 */
    max-height: 100%;
    /* 限制最大高度 */
    width: 100%;
}

/* 左侧历史记录面板 */
.history-sidebar {
    width: 90px;
    background: white;
    border-right: 1px solid #e9ecef;
    display: none; /* 默认隐藏，通过JavaScript控制显示 */
    flex-direction: column;
    transition: width 0.3s ease;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
}

/* 当用户已登录时显示侧边栏 */
.history-sidebar.visible {
    display: flex;
}


/* 新建对话按钮区域 */
.new-chat-section {
    padding: 0.75rem;
    border-bottom: 1px solid #e9ecef;
}

.new-chat-btn {
    width: 58px;
    height: 58px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    color: #6c757d;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    cursor: pointer;
    font-size: 20px;
    transition: all 0.2s ease;
}

.new-chat-btn:hover {
    border-color: #007bff;
    color: #007bff;
    background: rgba(0, 123, 255, 0.05);
}

.new-chat-btn i {
    font-size: 18px;
}

.new-chat-btn span {
    display: none;
    /* 隐藏文字，只显示加号图标 */
}

/* 历史记录列表 */
.history-list {
    flex: 1;
    overflow-y: auto; /* 🔥 保持auto以支持程序化滚动 */
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    /* 🔥 自适应高度：支持无滚动条滚动 */
    min-height: 0; /* 确保flex子项可以收缩 */
    scrollbar-width: none; /* Firefox: 隐藏滚动条 */
    -ms-overflow-style: none; /* IE/Edge: 隐藏滚动条 */
    /* 🔥 启用平滑滚动 */
    scroll-behavior: smooth;
    /* 🔥 支持触摸滚动 */
    -webkit-overflow-scrolling: touch;
}

/* 🔥 Webkit 浏览器：完全隐藏滚动条 */
.history-list::-webkit-scrollbar {
    width: 0px;
    background: transparent;
    display: none;
}

/* 🔥 添加滚动提示样式 */
.history-list::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 2px;
    height: 100%;
    background: linear-gradient(to bottom, transparent, rgba(0,123,255,0.1), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 1;
}

.history-list:hover::before {
    opacity: 1;
}

/* 历史记录项 */
.history-item {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

/* 缩略图样式的历史记录项 */
.history-item.thumbnail-style {
    padding: 0 !important;
    overflow: hidden;
    width: 58px !important;
    height: 58px !important;
    margin: 0 auto !important;
    /* 水平居中 */
    border: 2px solid #e9ecef !important;
    background: #f8f9fa;
    display: flex !important;
    flex-direction: column;
    flex-shrink: 0;
    /* 防止收缩 */
    border-radius: 8px !important;
}

.history-item.thumbnail-style:hover {
    border-color: #007bff;
}

.history-item.thumbnail-style.selected {
    border-color: #007bff;
    border-width: 2px;
}

.history-item.thumbnail-style .history-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
    display: block;
    margin: 0;
    padding: 0;
}

.history-item.thumbnail-style video.history-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
    pointer-events: none;
    /* 防止video元素拦截点击事件 */
}

.history-item.thumbnail-style .history-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    color: #6c757d;
    border-radius: 6px;
}

/* 移除info区域，因为58x58太小无法容纳文字 */
.history-item.thumbnail-style .history-info {
    display: none;
}

/* Tooltip 样式 */
.history-tooltip {
    position: absolute;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    max-width: 250px;
    word-wrap: break-word;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.history-tooltip.show {
    opacity: 1;
}

.history-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: rgba(0, 0, 0, 0.9) transparent transparent transparent;
}

/* 删除了所有旧的文本显示样式 */

/* 调整历史记录项的样式 */
/* 删除重复的基础历史记录项样式 */

/* 删除了旧的悬停样式 */


.history-loading,
.history-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #6c757d;
    text-align: center;
}

.history-loading i {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.history-empty i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: #adb5bd;
}

.history-empty p {
    margin: 0.5rem 0;
    font-weight: 500;
    color: #495057;
}

.history-empty small {
    color: #6c757d;
}

/* 删除了重复的旧历史记录项样式，使用新的缩略图样式 */

/* 页面标题 */
.page-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: white;
    border-bottom: 1px solid #e9ecef;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.header-icon {
    width: 40px;
    height: 40px;
    background: #6c757d;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    color: white;
    font-size: 18px;
}

.page-header h1 {
    font-size: 28px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
}

/* 聊天内容区域 */
.chat-content-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
    min-height: 0;
    /* 确保flex子项可以收缩 */
}

.chat-content-area.with-fixed-input {
    padding-bottom: 160px;
    /* 为固定底部的输入框留出更多空间，确保内容不被遮挡 */
    margin-bottom: 0;
    /* 输入框固定在底部时移除底部空间 */
}

.messages-container {
    flex: 1;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

/* 欢迎消息 */
.welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}

.welcome-message .message-content p {
    font-size: 16px;
    margin: 0;
    line-height: 1.5;
}

/* 消息项 */
.message-item {
    margin-bottom: 24px;
    animation: fadeInUp 0.3s ease-out;
}

.user-message {
    display: flex;
    justify-content: flex-end;
}

.ai-message {
    display: flex;
    justify-content: flex-start;
}

.message-bubble {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
}

.user-message .message-bubble {
    background: #007bff;
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-message .message-bubble {
    background: white;
    color: #2c3e50;
    border: 1px solid #e9ecef;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 当包含占位符网格时，气泡采用更宽布局，避免占位符竖排 */
.ai-message .message-bubble.wide-bubble {
    flex: 1 1 70%;
    max-width: 70%;
}

/* 图片消息 */
.image-message {
    margin: 16px 0;
}

.generated-images {
    display: grid;
    gap: 16px;
    margin-top: 12px;
    justify-content: start; /* 左对齐，避免图片过度拉伸 */
    max-width: 100%;
}

/* 单张图片时居中显示 */
.generated-images.single-image {
    grid-template-columns: 1fr;
    justify-content: center;
    max-width: 400px;
    margin: 12px auto 0;
}

/* 两张图片时并排显示 */
.generated-images.two-images {
    grid-template-columns: 1fr 1fr;
}

/* 三张或更多图片时自适应显示 */
.generated-images.multiple-images {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.generated-image {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease;
}

.generated-image:hover {
    transform: scale(1.02);
}

.generated-image img {
    width: 100%;
    height: auto;
    display: block;
    max-width: 100%; /* 图片宽度不超过容器 */
    object-fit: contain; /* 保持图片比例，不拉伸变形 */
}

.image-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.generated-image:hover .image-actions {
    opacity: 1;
}

.image-action-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background 0.2s ease;
}

.image-action-btn:hover {
    background: rgba(0, 0, 0, 0.9);
}

/* 加载状态 */
.loading-message {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: white;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    max-width: 70%;
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e9ecef;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

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

/* 底部输入区域 */
.input-area {
    background: white;
    border-top: 1px solid #e9ecef;
    padding: 20px;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
    /* 默认在中间位置，提供更好的视觉焦点 */
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    border-radius: 20px;
    z-index: 100;
    box-sizing: border-box;
}

/* 带动画效果的输入框 - 保留用于平滑过渡 */
.input-area.with-transition {
    transition: all 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* 点击生成按钮后固定在底部 */
.input-area.fixed-bottom {
    position: fixed !important;
    bottom: 0 !important;
    top: auto !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 100% !important;
    max-width: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
}

.chat-input-form {
    max-width: 800px;
    margin: 0 auto;
}

/* 图片上传区域 */
.image-upload-section {
    padding: 1rem;
    background: white;
    border-radius: 8px;
    margin-bottom: 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: none;
}

.uploaded-image-preview {
    position: relative;
    display: inline-block;
    max-width: 100%;
}

#previewImage {
    max-width: 100%;
    max-height: 200px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.remove-image-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background: #ff4757;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.remove-image-btn:hover {
    background: #ff2e43;
    transform: scale(1.1);
}

/* 主输入容器 */
.main-input-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 文本输入区域 */
.text-input-wrapper {
    display: flex;
    align-items: flex-end;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 24px;
    padding: 12px 16px;
    transition: border-color 0.2s ease;
    gap: 8px;
}

.text-input-wrapper:focus-within {
    border-color: #007bff;
}

.text-input-wrapper textarea {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    outline: none;
    font-size: 16px;
    line-height: 1.4;
    min-height: 24px;
    max-height: 120px;
    font-family: inherit;
    color: #2c3e50;
}

.text-input-wrapper textarea::placeholder {
    color: #adb5bd;
}

/* 输入框内的按钮组 */
.input-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 输入框内的按钮基础样式 */
.input-action-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* 上传按钮样式 */
.input-action-btn.upload-btn {
    color: #6c757d;
    padding: 6px;
    font-size: 16px;
}

.input-action-btn.upload-btn:hover {
    color: #007bff;
    background: rgba(0, 123, 255, 0.1);
}


/* 生成按钮样式 */
.input-action-btn.generate-btn {
    background: #007bff;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
}

.input-action-btn.generate-btn:hover {
    background: #0056b3;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

.input-action-btn.generate-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.input-action-btn.generate-btn i {
    font-size: 12px;
}

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

/* 平板端优化 */
@media (max-width: 1024px) and (min-width: 769px) {
    .generated-images.single-image {
        max-width: 350px;
    }
    
    .generated-images.two-images {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
    
    .generated-images.multiple-images {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        gap: 10px;
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .text-input-wrapper {
        padding: 10px 12px;
    }

    .input-actions {
        gap: 6px;
    }

    .input-action-btn.generate-btn {
        padding: 6px 12px;
        font-size: 13px;
    }

    .input-action-btn.generate-btn span {
        font-size: 13px;
    }

    .input-action-btn.upload-btn {
        padding: 4px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .input-action-btn.generate-btn span {
        display: none;
        /* 在很小的屏幕上只显示图标 */
    }

    .input-action-btn.generate-btn {
        padding: 6px 8px;
    }
}

/* 保留原上传按钮样式作为备用 */
.upload-btn:not(.input-action-btn) {
    border: none;
    background: transparent;
    color: #6c757d;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: color 0.2s ease;
    margin-left: 8px;
}

.upload-btn:not(.input-action-btn):hover {
    color: #007bff;
}


/* 参数按钮组 */
.params-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.param-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: 1px solid #e9ecef;
    background: white;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    color: #6c757d;
    transition: all 0.2s ease;
}

.param-btn:hover {
    border-color: #007bff;
    color: #007bff;
}

.param-btn.active {
    background: #007bff;
    border-color: #007bff;
    color: white;
}

.param-btn i {
    font-size: 12px;
}

/* 原生成按钮样式（已移到输入框内，保留作为备用） */
.generate-btn:not(.input-action-btn) {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: background 0.2s ease;
    align-self: flex-end;
}

.generate-btn:not(.input-action-btn):hover {
    background: #0056b3;
}

.generate-btn:not(.input-action-btn):disabled {
    background: #6c757d;
    cursor: not-allowed;
}

/* 参数面板 */
.params-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e9ecef;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    max-height: 60vh;
    overflow-y: auto;
    pointer-events: auto !important;
    /* 确保面板可交互 */
    display: block;
    /* 确保面板可见 */
}

/* 当输入框固定在底部时，参数面板需要更高的z-index */
.input-area.fixed-bottom~.params-panel {
    z-index: 1001;
}

.params-panel.show {
    transform: translateY(0);
    pointer-events: auto !important;
    /* 确保显示时可交互 */
    display: block;
    /* 确保显示时可见 */
}

/* 确保参数面板内容可见 */
.params-content {
    position: relative;
    z-index: 1001;
    pointer-events: auto !important;
    /* 确保内容可交互 */
}

.params-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.param-section {
    margin-bottom: 20px;
}

.param-section h6 {
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 12px;
}

/* 选项按钮样式 */
.style-options,
.template-options,
.image-style-options,
.ratio-options,
.quality-options,
.num-images-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.template-options {
    max-height: 400px;
    /* 模板选项更多，需要更大的高度 */
}

.style-option,
.template-option,
.image-style-option,
.ratio-option,
.quality-option,
.num-images-option {
    padding: 8px 16px;
    border: 1px solid #e9ecef;
    background: white;
    border-radius: 16px;
    cursor: pointer;
    font-size: 14px;
    color: #6c757d;
    transition: all 0.2s ease;
    white-space: nowrap;
    user-select: none;
}

.template-option {
    font-size: 13px;
    /* 模板选项字体稍小 */
    padding: 8px 12px;
    /* 增加内边距提高点击区域 */
    pointer-events: auto !important;
    /* 确保可点击 */
    z-index: 999 !important;
    /* 确保在最上层 */
    position: relative !important;
    /* 确保定位正确 */
    min-height: 32px;
    /* 确保最小点击区域 */
    display: inline-flex;
    /* 使用flex布局 */
    align-items: center;
    /* 垂直居中 */
    justify-content: center;
    /* 水平居中 */
}

.style-option:hover,
.template-option:hover,
.image-style-option:hover,
.ratio-option:hover,
.quality-option:hover,
.num-images-option:hover {
    border-color: #007bff;
    color: #007bff;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.2);
}

.style-option.active,
.template-option.active,
.image-style-option.active,
.ratio-option.active,
.quality-option.active,
.num-images-option.active {
    background: #007bff;
    border-color: #007bff;
    color: white;
}

/* 模板选项的滚动条样式 */
.template-options::-webkit-scrollbar {
    width: 4px;
}

.template-options::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 2px;
}

.template-options::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 2px;
}

.template-options::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 高级选项 */
.advanced-options {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.option-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.option-item label {
    font-size: 14px;
    color: #2c3e50;
    min-width: 80px;
}

.option-item input[type="range"] {
    flex: 1;
    max-width: 200px;
}

.option-item select {
    padding: 4px 8px;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    font-size: 14px;
}

.option-item input[type="checkbox"] {
    margin-right: 8px;
}

/* 动画效果 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

/* 响应式设计 */
@media (max-width: 768px) {
    .image-edit-chat-container {
        /* 移动端保持相同的固定定位方式 */
        height: 100vh;
        max-height: 100vh;
        padding-top: 64px;
        box-sizing: border-box;
    }

    .page-header {
        padding: 16px;
    }

    .page-header h1 {
        font-size: 24px;
    }

    .chat-content-area {
        padding: 16px;
    }

    .input-area {
        padding: 16px;
    }

    .params-buttons {
        justify-content: center;
    }

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

    .generate-btn {
        align-self: stretch;
        justify-content: center;
    }

    .message-bubble {
        max-width: 85%;
    }

    .generated-images.single-image {
        max-width: 280px;
        margin: 12px auto 0;
    }
    
    .generated-images.two-images {
        grid-template-columns: 1fr 1fr;
        justify-content: center;
        gap: 8px;
    }
    
    .generated-images.multiple-images {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        justify-content: center;
        gap: 8px;
    }
    
    .generated-image img {
        max-width: 100%; /* 移动端最大宽度为容器宽度 */
    }
}

/* 滚动条样式 */
.chat-content-area::-webkit-scrollbar {
    width: 6px;
}

.chat-content-area::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-content-area::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.chat-content-area::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 拖拽效果 */
.text-input-wrapper.drag-over {
    border-color: #007bff;
    background: rgba(0, 123, 255, 0.05);
}

/* 用户消息中的图片样式 */
.user-image img {
    max-width: 120px;
    border-radius: 8px;
    margin-bottom: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.user-prompt {
    font-size: 14px;
    line-height: 1.4;
}

/* 生成信息样式 */
.generation-info {
    margin-top: 12px;
    font-size: 12px;
    color: #6c757d;
    line-height: 1.3;
}

.generation-info div {
    margin-bottom: 4px;
}

/* 改进的按钮悬停效果 */
.param-btn:hover i,
.generate-btn:hover i {
    transform: scale(1.1);
}

/* 改进的消息动画 */
.message-item {
    animation: slideInUp 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

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

/* 改进的加载动画 */
.loading-spinner {
    animation: spin 1.2s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
}

/* ===================== 任务状态指示器样式 ===================== */

/* 任务状态覆盖层 */
.history-item.task-pending .history-task-overlay,
.history-item.task-processing .history-task-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 123, 255, 0.1);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

/* 转圈动画 */
.history-task-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid rgba(0, 123, 255, 0.3);
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* 任务状态边框 */
.history-item.task-pending {
    border-color: #ffc107;
    /* 黄色边框表示等待中 */
    border-width: 2px;
}

.history-item.task-processing {
    border-color: #007bff;
    /* 蓝色边框表示处理中 */
    border-width: 2px;
    animation: task-pulse 2s ease-in-out infinite;
}

/* 处理中的脉冲动画 */
@keyframes task-pulse {

    0%,
    100% {
        border-color: #007bff;
        box-shadow: 0 0 0 0 rgba(0, 123, 255, 0.7);
    }

    50% {
        border-color: #0056b3;
        box-shadow: 0 0 0 4px rgba(0, 123, 255, 0);
    }
}

/* 任务状态角标 - 去掉完成状态的对勾 */
.history-task-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid white;
    font-size: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    z-index: 3;
}

.history-task-badge.pending {
    background: #ffc107;
    color: white;
}

.history-task-badge.processing {
    background: #007bff;
    color: white;
}

/* 任务完成时不显示角标，避免显示对勾 */
.history-task-badge.completed {
    background: #28a745;
    color: white;
}

.history-task-badge.failed {
    background: #dc3545;
    color: white;
}

/* 进度指示器（环形进度条） */
.history-task-progress {
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 3px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 1.5px;
    overflow: hidden;
    z-index: 3;
}

.history-task-progress-fill {
    height: 100%;
    background: #007bff;
    border-radius: 1.5px;
    transition: width 0.3s ease;
    width: 0%;
}

/* 任务计数徽章（显示任务数量） */
.task-count-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 10px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4;
    border: 2px solid white;
}

/* 悬停效果增强 */
.history-item.task-pending:hover,
.history-item.task-processing:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
    transition: all 0.2s ease;
}

/* 任务完成状态 */
.history-item.task-completed {
    border-color: #28a745;
}

.history-item.task-failed {
    border-color: #dc3545;
}

/* 改进的图片悬停效果 */
.generated-image {
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.generated-image:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

/* 参数面板动画优化 */
.params-panel {
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* 输入框聚焦效果 */
.text-input-wrapper:focus-within {
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

/* 按钮点击效果 */
.generate-btn:active {
    transform: scale(0.98);
}

.param-btn:active,
.style-option:active,
.template-option:active,
.image-style-option:active,
.ratio-option:active,
.quality-option:active,
.num-images-option:active {
    transform: scale(0.95);
}

/* 复制链接对话框样式 */
.copy-url-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
}

.copy-dialog-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.copy-dialog-content {
    background: white;
    border-radius: 12px;
    padding: 0;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideInUp 0.3s ease;
}

.copy-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
}

.copy-dialog-header h4 {
    margin: 0;
    color: #333;
    font-size: 1.1rem;
    font-weight: 600;
}

.copy-dialog-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #6c757d;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.copy-dialog-close:hover {
    background: #e9ecef;
    color: #495057;
}

.copy-dialog-body {
    padding: 1.5rem;
}

.copy-dialog-body p {
    margin: 0 0 1rem 0;
    color: #6c757d;
    font-size: 0.9rem;
}

.copy-url-input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    background: #f8f9fa;
    color: #495057;
    margin-bottom: 1rem;
    word-break: break-all;
    resize: none;
    min-height: 80px;
}

.copy-url-input:focus {
    outline: none;
    border-color: #007bff;
    background: white;
}

.copy-dialog-actions {
    display: flex;
    gap: 0.75rem;
}

.copy-dialog-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 2px solid transparent;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.copy-dialog-btn.primary {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

.copy-dialog-btn.primary:hover {
    background: #0056b3;
    border-color: #0056b3;
    transform: translateY(-1px);
}

.copy-dialog-btn.secondary {
    background: white;
    color: #6c757d;
    border-color: #e9ecef;
}

.copy-dialog-btn.secondary:hover {
    background: #f8f9fa;
    border-color: #ced4da;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* 🔥 新增：加载更多指示器样式 */
.loading-more-indicator {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    margin: 10px 0;
    background: rgba(248, 249, 250, 0.8);
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.loading-more-content {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #6c757d;
}

.loading-spinner-small {
    width: 16px;
    height: 16px;
    border: 2px solid #e9ecef;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* 🔥 注释：历史记录无限滚动样式已合并到.history-list中 */

/* 历史记录项滑动动画 */
.history-item {
    transition: all 0.3s ease;
    transform: translateY(0);
    opacity: 1;
}

/* 新加载的历史记录项动画 */
.history-item.newly-loaded {
    animation: slideInFromBottom 0.5s ease-out;
}

@keyframes slideInFromBottom {
    0% {
        transform: translateY(20px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

/* 无更多内容提示 */
.no-more-content {
    text-align: center;
    padding: 15px;
    color: #9ca3af;
    font-size: 13px;
    border-top: 1px solid #e5e7eb;
    margin-top: 10px;
}

.no-more-content i {
    margin-right: 5px;
}

/* ========== 多图上传预览样式 ========== */

/* 多图预览网格容器 */
.multi-image-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 8px;
    max-height: 200px;
    overflow-y: auto;
}

/* 响应式布局：2张图片时并排显示 */
.multi-image-preview-grid.two-images {
    grid-template-columns: 1fr 1fr;
}

/* 响应式布局：3张及以上图片时使用网格 */
.multi-image-preview-grid.multiple-images {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
}

/* 单个多图预览项 */
.multi-image-preview-item {
    position: relative;
    background: white;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #e9ecef;
    transition: all 0.2s ease;
    aspect-ratio: 1;
}

.multi-image-preview-item:hover {
    border-color: #1890FF;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(24, 144, 255, 0.15);
}

/* 多图预览中的图片 */
.multi-image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* 多图移除按钮 */
.multi-image-remove-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease;
    font-size: 10px;
    z-index: 2;
}

.multi-image-preview-item:hover .multi-image-remove-btn {
    opacity: 1;
}

.multi-image-remove-btn:hover {
    background: rgba(220, 53, 69, 0.9);
    transform: scale(1.1);
}

/* 多图序号标识 */
.multi-image-index {
    position: absolute;
    bottom: 2px;
    left: 2px;
    background: rgba(24, 144, 255, 0.9);
    color: white;
    font-size: 10px;
    padding: 1px 4px;
    border-radius: 2px;
    font-weight: 500;
    line-height: 1;
}

/* 多图上传信息区域 */
.multi-upload-info {
    background: #f0f8ff;
    border: 1px solid #d4edda;
    border-radius: 6px;
    padding: 8px 12px;
    margin-top: 8px;
}

/* 上传统计信息 */
.upload-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.current-count, .max-limit {
    font-size: 12px;
    color: #495057;
}

.current-count strong, .max-limit strong {
    color: #1890FF;
    font-weight: 600;
}

/* 上传提示 */
.upload-tip {
    display: flex;
    align-items: center;
    font-size: 11px;
    color: #6c757d;
    gap: 4px;
}

.upload-tip i {
    color: #1890FF;
    font-size: 12px;
}

/* 单图和多图模式切换 */
.single-image-preview {
    display: block;
}

.image-upload-section.multi-mode .single-image-preview {
    display: none;
}

.image-upload-section.multi-mode .multi-image-preview-grid {
    display: grid !important;
}

.image-upload-section.multi-mode .multi-upload-info {
    display: block !important;
}

/* 兼容原有单图样式 */
.single-image-preview {
    position: relative;
    display: inline-block;
    max-width: 100%;
}

/* 优化移动端显示 */
@media (max-width: 768px) {
    .multi-image-preview-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }
    
    .multi-image-preview-grid.two-images {
        grid-template-columns: 1fr 1fr;
    }
    
    .upload-stats {
        flex-direction: column;
        gap: 4px;
        align-items: flex-start;
    }
    
    .upload-tip {
        font-size: 10px;
    }
}

