/**
 * 鏀ュ啓闀滃ご椤甸潰鏍峰紡 - 娣辫壊涓婚
 * 宸︿晶鎺у埗闈㈡澘 + 鍙充晶鑱婂ぉ缁撴灉闈㈡澘
 */

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background: #fafafa;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    overflow: hidden;
    color: #444;
}

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.18); }

.page-container {
    width: 100vw;
    height: 100vh;
    margin: 0;
    padding: 2px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fafafa;
}

.editor-container {
    flex: 1;
    display: flex;
    gap: 0;
    min-height: 0;
}

/* ===== 宸︿晶鎺у埗闈㈡澘 - 极简线条风格 ===== */
.control-panel {
    width: 350px;
    background: #ffffff;
    border-radius: 0;
    padding: 20px;
    border: none;
    border-right: 1px solid rgba(0,0,0,0.06);
    overflow-y: auto;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.panel-title { font-size: 18px; font-weight: 600; margin-bottom: 0; padding-bottom: 12px; border-bottom: 1px solid rgba(0,0,0,0.06); color: #333; display: flex; align-items: center; gap: 8px; }
.panel-title svg { flex-shrink: 0; opacity: 0.85; }
.panel-desc { font-size: 13px; color: rgba(0,0,0,0.5); margin-bottom: 0; padding: 12px 0; line-height: 1.5; border-bottom: 1px solid rgba(0,0,0,0.06); }

/* 🔥 模式切换 TAB */
.shot-mode-tabs {
    display: flex; gap: 6px; padding: 12px 0;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}
.shot-mode-tab {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 12px; border: 1.5px solid #e0e0e0; border-radius: 10px;
    background: #fafafa; color: #888; font-size: 13px; font-weight: 500;
    cursor: pointer; transition: all 0.25s ease;
}
.shot-mode-tab:hover { border-color: #bbb; color: #555; }
.shot-mode-tab.active {
    border-color: #3444fe; background: rgba(52,68,254,0.06);
    color: #3444fe; font-weight: 600;
}
.shot-mode-tab svg { opacity: 0.7; }
.shot-mode-tab.active svg { opacity: 1; stroke: #3444fe; }
.form-group { margin-bottom: 0; padding: 16px 0; border-bottom: 1px solid rgba(0,0,0,0.06); }
.form-group:last-child { border-bottom: none; }
.form-label { display: block; margin-bottom: 8px; font-weight: 600; color: rgba(0,0,0,0.8); font-size: 13px; }

.upload-label-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.upload-label-wrapper label { font-weight: 600; color: rgba(0,0,0,0.8); font-size: 13px; }
.upload-hint-inline { font-size: 11px; color: rgba(0,0,0,0.35); }

.upload-area-compact {
    width: 80px;
    height: 80px;
    border: 2px dashed rgba(0,0,0,0.12);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: rgba(0,0,0,0.02);
}
.upload-area-compact:hover { border-color: #3444fe; background: rgba(52,68,254,0.05); }
.upload-area-compact.drag-over { border-color: #3444fe; background: rgba(52,68,254,0.1); }
.upload-plus-icon { font-size: 24px; opacity: 0.6; }

.uploaded-images { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.uploaded-image {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.08);
}
.uploaded-image img { width: 100%; height: 100%; object-fit: cover; }
.uploaded-image-order {
    position: absolute;
    left: 4px;
    bottom: 4px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    background: rgba(52, 68, 254, 0.92);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}
.message-images--multi {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.message-image-item {
    position: relative;
    width: 72px;
    height: 72px;
    border-radius: 8px;
    overflow: hidden;
}
.message-image-item img { width: 100%; height: 100%; object-fit: cover; }
.message-image-order {
    position: absolute;
    left: 4px;
    bottom: 4px;
    min-width: 16px;
    height: 16px;
    padding: 0 3px;
    border-radius: 8px;
    background: rgba(0,0,0,0.65);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}
.remove-image {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0,0,0,0.7);
    color: #333;
    border: none;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.remove-image:hover { background: #ff4444; }

/* 🔥 首尾帧上传容器（与VEO 3.1一致） */
.frame-upload-container {
    display: flex;
    gap: 12px;
    align-items: center;
}
.frame-upload-item {
    flex: 1;
}
.frame-upload-item label {
    font-size: 12px;
    color: #666;
    margin-bottom: 6px;
    display: block;
}
.frame-swap-btn {
    background: rgba(52, 68, 254, 0.2);
    border: 1px solid rgba(52, 68, 254, 0.4);
    color: #3444fe;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-top: 20px;
}
.frame-swap-btn:hover {
    background: rgba(52, 68, 254, 0.4);
    border-color: #3444fe;
    transform: scale(1.1);
}
.frame-swap-btn:active { transform: scale(0.95); }
.uploaded-preview {
    display: none;
    position: relative;
    margin-top: 8px;
}
.uploaded-preview img {
    width: 100%;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.uploaded-preview img:hover {
    opacity: 0.9;
    box-shadow: 0 0 15px rgba(52, 68, 254, 0.3);
}
.uploaded-preview .remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.uploaded-preview .remove-btn:hover { background: #ff4444; }

.form-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 8px;
    font-size: 13px;
    background: #ffffff;
    color: #444;
    resize: vertical;
    min-height: 60px;
    max-height: 150px;
    font-family: inherit;
    line-height: 1.5;
    transition: border-color 0.2s;
}
.form-textarea:focus { outline: none; border-color: #3444fe; box-shadow: 0 0 0 2px rgba(52,68,254,0.2); }
.form-textarea::placeholder { color: rgba(0,0,0,0.18); }

.generate-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #3444fe 0%, #2a36cb 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s ease;
    margin-bottom: 12px;
}
.generate-btn:hover:not(:disabled) { opacity: 0.9; transform: translateY(-1px); }
.generate-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.generate-btn .btn-power {
    background: rgba(0,0,0,0.12);
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
}

.power-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 12px;
    color: #888;
}
.power-display .power-icon { font-size: 14px; }
.power-display .power-value { color: #ffd700; font-weight: 600; }

/* ===== 鍙充晶鑱婂ぉ闈㈡澘 ===== */
.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
    border-radius: 0;
    border: none;
    min-width: 0;
    overflow: hidden;
}

.chat-header {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    background: #ffffff;
}
.chat-model-info { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; }
.model-icon { font-size: 18px; }
.model-name { color: #444; }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

/* 娆㈣繋灞?*/
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 40px 20px;
    text-align: center;
}
.welcome-icon { font-size: 48px; margin-bottom: 16px; }
.welcome-screen h2 { font-size: 22px; font-weight: 600; margin-bottom: 8px; color: #444; }
.welcome-screen p { font-size: 14px; color: #888; margin-bottom: 24px; }
.welcome-features {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    max-width: 320px;
}
.feature-item {
    padding: 10px 16px;
    background: rgba(52,68,254,0.08);
    border: 1px solid rgba(52,68,254,0.15);
    border-radius: 8px;
    font-size: 13px;
    color: #aaa;
}

/* 娑堟伅姘旀场 */
.message {
    margin-bottom: 16px;
    max-width: 100%;
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.message.user {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}
.message.user .message-content {
    background: linear-gradient(135deg, #3444fe 0%, #2a36cb 100%);
    padding: 10px 16px;
    border-radius: 16px 16px 4px 16px;
    display: inline-block;
    max-width: 80%;
    font-size: 14px;
    line-height: 1.6;
    color: white;
}
.message.user .message-images {
    margin-bottom: 8px;
}
.message.user .message-images img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 12px;
    object-fit: cover;
}

.message.assistant .message-content {
    font-size: 14px;
    line-height: 1.7;
    color: #444;
}

/* Markdown娓叉煋鏍峰紡 */
.message-content p { margin-bottom: 8px; }
.message-content p:last-child { margin-bottom: 0; }
.message-content ul, .message-content ol { padding-left: 20px; margin-bottom: 8px; }
.message-content li { margin-bottom: 4px; }
.message-content strong { color: #333; }
.message-content h2, .message-content h3, .message-content h4 { color: #333; margin: 12px 0 6px; }
.message-content hr { border: none; border-top: 1px solid rgba(0,0,0,0.08); margin: 12px 0; }
.message-content blockquote {
    border-left: 3px solid #3444fe;
    padding-left: 12px;
    margin: 8px 0;
    color: #aaa;
}

/* 鎵撳瓧鎸囩ず鍣?*/
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 0;
}
.typing-indicator .typing-label {
    font-size: 13px;
    color: #888;
    margin-right: 4px;
}
.typing-indicator .typing-timer {
    font-size: 13px;
    color: #3444fe;
    margin-right: 4px;
    font-variant-numeric: tabular-nums;
}
.typing-indicator .dot {
    width: 6px;
    height: 6px;
    background: #888;
    border-radius: 50%;
    animation: blink 1.4s infinite both;
}
.typing-indicator .dot:nth-child(4) { animation-delay: 0.2s; }
.typing-indicator .dot:nth-child(5) { animation-delay: 0.4s; }
@keyframes blink { 0%,80%,100%{opacity:0.3} 40%{opacity:1} }

/* 閿欒娑堟伅 */
.message.error .message-content {
    background: rgba(255,68,68,0.1);
    border: 1px solid rgba(255,68,68,0.2);
    padding: 12px 16px;
    border-radius: 10px;
    color: #ff6b6b;
    font-size: 13px;
}

/* ===== 右侧历史面板 - 极简线条风格 ===== */
.history-panel {
    width: 300px;
    background: #ffffff;
    border-radius: 0;
    padding: 50px 20px 20px; /* 🔥 top 50px: 避开父页面固定 nav-right */
    border: none;
    border-left: 1px solid rgba(0,0,0,0.06);
    overflow-y: hidden !important;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 40px);
    position: relative;
    z-index: 100;
}

.history-header { display: flex; justify-content: space-between; align-items: center; padding-bottom: 12px; border-bottom: 1px solid rgba(0,0,0,0.06); margin-bottom: 12px; }
.history-header h3 { font-size: 15px; font-weight: 600; color: #333; margin: 0; }

.history-list { flex: 1; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; scrollbar-color: rgba(0,0,0,0.12) transparent; position: relative; z-index: 100; }
.history-list::-webkit-scrollbar { width: 4px; }
.history-list::-webkit-scrollbar-track { background: transparent; border-radius: 4px; }
.history-list::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 4px; }
.history-list::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.18); }
.history-list::-webkit-scrollbar-button { display: none; height: 0; width: 0; }

.history-item { background: rgba(0,0,0,0.03); border-radius: 8px; padding: 12px; margin-bottom: 10px; border: 1px solid transparent; transition: all 0.2s ease; cursor: pointer; }
.history-item:hover { background: rgba(52, 68, 254, 0.1); border-color: rgba(52, 68, 254, 0.3); }
.history-item.active { border-color: #3444fe; background: rgba(52, 68, 254, 0.08); }
.history-item-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.history-time { font-size: 11px; color: rgba(0,0,0,0.35); }
.history-status { font-size: 11px; padding: 2px 8px; border-radius: 4px; font-weight: 500; }
.history-status.success { background: rgba(16, 185, 129, 0.2); color: #10b981; }
.history-status.processing { background: rgba(52, 68, 254, 0.15); color: #3444fe; }
.history-status.queued { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.history-status.failed { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.history-thumb { margin-bottom: 8px; border-radius: 6px; overflow: hidden; }
.history-thumb img { width: 100%; height: auto; object-fit: contain; border-radius: 6px; display: block; }
.history-prompt { font-size: 12px; color: rgba(0,0,0,0.6); line-height: 1.4; margin-bottom: 6px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.history-content-preview { font-size: 11px; color: rgba(0,0,0,0.4); line-height: 1.3; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.history-model { font-size: 11px; color: rgba(0,0,0,0.35); }

.history-delete-btn {
    background: none; border: none; cursor: pointer; font-size: 12px; padding: 2px 4px;
    opacity: 0; transition: opacity 0.2s;
}
.history-item:hover .history-delete-btn { opacity: 0.6; }
.history-delete-btn:hover { opacity: 1 !important; }

.clear-history-btn {
    background: none; border: none; cursor: pointer; font-size: 14px;
    color: rgba(0,0,0,0.3); padding: 4px 6px; border-radius: 4px; transition: all 0.2s;
}
/* 全局隐藏「生成历史/处理历史」标题区（含标题文字 + 清空按钮） */
.history-header { display: none !important; }
.clear-history-btn:hover { background: rgba(239, 68, 68, 0.1); color: #ef4444; }

@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .editor-container { flex-direction: column; }
    .control-panel { width: 100%; max-height: 40vh; }
    .chat-panel { flex: 1; min-height: 50vh; }
    .history-panel { display: none; }
}

