/**
 * chat.css - 聊天/灵感创作视图样式
 * 侧边栏、聊天消息、输入框等
 */

/* === 视图1: 灵感 (聊天) === */
#view-inspiration {
    width: 100%;
    height: 100%;
}

/* 左侧边栏 */
.sidebar {
    width: 280px;
    background-color: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    border-right: 1px solid #333;
    flex-shrink: 0;
    overflow: hidden;
}

.new-chat-btn {
    margin: 10px;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    background: transparent;
    color: white;
    cursor: pointer;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: 0.2s;
    font-size: 0.9rem;
}
.new-chat-btn:hover { background-color: #2b2c2f; }

.prominent-config {
    padding: 0 10px 10px 10px;
    border-bottom: 1px solid var(--border-color);
    background-color: #1a1b1e;
}

.config-item { margin-top: 10px; }
.config-item label {
    display: block;
    font-size: 0.75rem;
    color: #aaa;
    margin-bottom: 4px;
    font-weight: 600;
}
.config-item input, .config-item textarea, .config-item select {
    width: 100%;
    background: #40414f;
    border: 1px solid var(--border-color);
    color: white;
    padding: 8px;
    border-radius: 4px;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 0.9rem;
}
.config-item input:focus, .config-item textarea:focus, .config-item select:focus {
    outline: none;
    border-color: var(--accent-color);
}

/* 历史列表 */
.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-height: 0;
}

.history-item {
    padding: 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    color: #ccc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    min-height: 24px;
}
.history-item span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}
.history-item.active { background-color: #343541; color: white; }

.delete-icon {
    opacity: 0;
    color: #888;
    padding: 2px 5px;
    font-size: 14px;
    border-radius: 3px;
    transition: all 0.2s;
}
.history-item:hover .delete-icon { opacity: 1; }
.delete-icon:hover { color: #ff6b6b; background: rgba(255, 107, 107, 0.1); }

/* Session Item */
.session-item {
    padding: 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    color: #ccc;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}
.session-item:hover { background: rgba(255,255,255,0.05); }
.session-item.active { background: #343541; color: white; }

/* 🌟 有任务进行中的会话样式 */
.session-item.has-running-task {
    border-left: 3px solid var(--accent-color);
    background: rgba(16, 163, 127, 0.1);
}
.session-item.has-running-task:not(.active) {
    animation: task-pulse 2s ease-in-out infinite;
}
@keyframes task-pulse {
    0%, 100% { background: rgba(16, 163, 127, 0.1); }
    50% { background: rgba(16, 163, 127, 0.2); }
}
.running-task-badge {
    display: inline-block;
    margin-right: 6px;
    font-size: 0.85em;
    animation: badge-spin 1.5s linear infinite;
}
@keyframes badge-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.session-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.session-actions {
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.2s;
}
.session-item:hover .session-actions { opacity: 1; }
.action-btn {
    background: transparent;
    border: none;
    padding: 2px 5px;
    cursor: pointer;
    font-size: 12px;
    border-radius: 3px;
}
.action-btn:hover { background: rgba(255,255,255,0.1); }

/* 主聊天区域 */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background-color: var(--bg-color);
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: auto;
    padding-bottom: 180px;
}

.message-row { width: 100%; border-bottom: 1px solid rgba(0,0,0,0.1); }
.message-row.ai { background-color: var(--ai-msg-bg); }
.message-row.user { background-color: var(--user-msg-bg); }

.message-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 24px;
    display: flex;
    gap: 20px;
    line-height: 1.6;
    align-items: flex-start;
    overflow: visible !important; /* 强制不产生滚动条 */
}

.content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-width: 0;
    overflow: visible !important; /* 强制不产生滚动条 */
}

.avatar {
    width: 30px; height: 30px; border-radius: 2px;
    flex-shrink: 0; display: flex; align-items: center;
    justify-content: center; font-weight: bold; font-size: 0.8rem;
}
.user .avatar { background: #5436da; color: white; }
.ai .avatar { background: #10a37f; color: white; }

/* 🎨 画师头像样式（头像 + 名字水平排列，放在内容上方） */
.avatar-painter {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-shrink: 0;
    gap: 8px;
    margin-bottom: 6px;
}

.avatar-painter img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent-color);
    box-shadow: 0 2px 6px rgba(16, 163, 127, 0.3);
    flex-shrink: 0;
}

.avatar-painter .avatar-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10a37f, #0d8a6a);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    border: 2px solid rgba(16, 163, 127, 0.5);
    flex-shrink: 0;
}

.avatar-painter .avatar-name {
    font-size: 0.8rem;
    color: var(--accent-color);
    font-weight: 600;
    white-space: nowrap;
}

.text-content { 
    flex: 1; 
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    overflow: visible !important; /* 强制不产生滚动条 */
}

/* 图片网格 */
.image-grid { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 15px; 
    margin-top: 15px; 
    align-items: flex-start; 
    justify-content: flex-start;
    width: 100%;
    margin-left: 0;
    overflow: visible !important; /* 强制不产生滚动条 */
}
.image-card {
    border-radius: 8px; overflow: hidden; border: 1px solid #555;
    background: #222; flex: 0 1 auto; max-width: 100%;
    display: flex; flex-direction: column; transition: transform 0.2s;
}
.image-card:hover { transform: scale(1.02); border-color: #aaa; box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
.image-card img { width: auto; height: auto; max-width: 100%; max-height: 400px; display: block; cursor: pointer; object-fit: contain; }
.image-card .meta { padding: 8px; font-size: 0.7em; color: #888; font-family: monospace; word-break: break-all; background: #1a1a1a; border-top: 1px solid #333; }

/* 内联提示 */
.inline-hint {
    text-align: center;
    padding: 10px 15px;
    color: #888;
    font-size: 0.85rem;
    background: rgba(0,0,0,0.3);
    border-bottom: 1px solid #444;
    display: none;
    transition: all 0.3s;
}

.inline-hint.info {
    background: rgba(16, 163, 127, 0.15);
    border-bottom-color: rgba(16, 163, 127, 0.3);
    color: #10a37f;
}

.inline-hint.success {
    background: rgba(16, 163, 127, 0.2);
    border-bottom-color: rgba(16, 163, 127, 0.4);
    color: #10a37f;
}

.inline-hint.error {
    background: rgba(245, 108, 108, 0.15);
    border-bottom-color: rgba(245, 108, 108, 0.3);
    color: #f56c6c;
}

.inline-hint.warning {
    background: rgba(230, 162, 60, 0.15);
    border-bottom-color: rgba(230, 162, 60, 0.3);
    color: #e6a23c;
}

/* 底部输入区 */
.input-area-wrapper {
    position: absolute; bottom: 0; left: 0; width: 100%;
    background-image: linear-gradient(180deg,rgba(53,55,64,0),#353740 58.85%);
    padding-bottom: 30px; padding-top: 20px;
}

.input-box {
    max-width: 800px; margin: 0 auto; position: relative;
    background: #40414f; border-radius: 12px;
    box-shadow: 0 0 15px rgba(0,0,0,0.1); border: 1px solid rgba(32,33,35,.5);
    display: flex; flex-direction: column; transition: all 0.3s;
    min-height: 52px;
}
.input-box.disabled { opacity: 0.7; border-color: #666; background-color: #2d2d35; }
.input-box.drag-over { border-color: var(--accent-color); background: rgba(16, 163, 127, 0.1); }

textarea {
    background: transparent; border: none; color: white;
    padding: 14px 50px 14px 16px; resize: none;
    height: 52px; line-height: 24px;
    max-height: 200px; outline: none; font-family: inherit; font-size: 1rem;
    width: 100%; box-sizing: border-box;
}
textarea:disabled { cursor: not-allowed; color: #aaa; }

.send-btn {
    background: transparent; border: none; color: #ececf1;
    cursor: pointer; padding: 8px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.send-btn:hover { background: rgba(255,255,255,0.1); }
.send-btn:disabled { color: #555; cursor: not-allowed; }

/* 上传图片按钮 */
.upload-img-btn {
    background: linear-gradient(135deg, rgba(16, 163, 127, 0.1), rgba(16, 163, 127, 0.05));
    border: 1px solid rgba(16, 163, 127, 0.3);
    color: #10a37f;
    cursor: pointer; 
    padding: 10px;
    border-radius: 10px;
    display: flex; 
    align-items: center; 
    justify-content: center;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}
.upload-img-btn::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, rgba(16, 163, 127, 0.2), rgba(16, 163, 127, 0.05));
    opacity: 0;
    transition: opacity 0.25s;
}
.upload-img-btn:hover { 
    background: linear-gradient(135deg, rgba(16, 163, 127, 0.25), rgba(16, 163, 127, 0.15));
    border-color: var(--accent-color);
    color: #fff;
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(16, 163, 127, 0.3);
}
.upload-img-btn:hover::before {
    opacity: 1;
}
.upload-img-btn:active {
    transform: scale(0.98);
}
.upload-img-btn svg {
    position: relative;
    z-index: 1;
}

.upload-preview-bar { padding: 10px; display: flex; gap: 10px; border-bottom: 1px solid #555; overflow-x: auto; }
.preview-item { position: relative; flex-shrink: 0; }
.mini-preview { width: 80px; height: 80px; border-radius: 12px; object-fit: cover; border: 1px solid #666; }

.remove-img-btn {
    position: absolute; top: -8px; right: -8px; width: 22px; height: 22px;
    background: #ff4d4f; color: white; border-radius: 50%; border: none;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; cursor: pointer; box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 10;
}
.remove-img-btn:hover { background: #ff7875; }

/* 上传预览 */
.upload-preview-item {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
}
.upload-preview-item img {
    width: 60px;
    height: 60px;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid #555;
}
.upload-preview-item .upload-status {
    font-size: 0.7rem;
    color: #10a37f; /* 🌟 修改为绿色 */
    margin-top: 3px;
    font-weight: bold;
}
.upload-preview-item .remove-btn {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 18px;
    height: 18px;
    background: #f56c6c;
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
