/**
 * 瑙掕壊涓夎鍥?澶氭満浣嶅垎闀滄牱寮?- 娣辫壊涓婚
 * 澶嶇敤 AI 鍥惧儚缂栬緫鍣ㄧ殑鏍峰紡
 */

* { 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-x: hidden;
    overflow-y: auto;
    color: #444;
}

/* 婊氬姩鏉℃牱寮?*/
body::-webkit-scrollbar, .page-container::-webkit-scrollbar, .control-panel::-webkit-scrollbar { width: 4px; }
body::-webkit-scrollbar-track, .page-container::-webkit-scrollbar-track, .control-panel::-webkit-scrollbar-track { background: transparent; }
body::-webkit-scrollbar-thumb, .page-container::-webkit-scrollbar-thumb, .control-panel::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 4px; }
body::-webkit-scrollbar-thumb:hover, .page-container::-webkit-scrollbar-thumb:hover, .control-panel::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.18); }
body::-webkit-scrollbar-button, .page-container::-webkit-scrollbar-button, .control-panel::-webkit-scrollbar-button { display: none; height: 0; width: 0; }

.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;
}

.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; justify-content: space-between; }
.panel-title svg { flex-shrink: 0; opacity: 0.85; }

/* 管理员：预制提示词设置按钮 */
.admin-settings-btn {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px; font-size: 12px; font-weight: 500;
    background: #f3f4f6; color: #4b5563;
    border: 1px solid rgba(0,0,0,0.08); border-radius: 6px;
    cursor: pointer; transition: all 0.15s ease;
    flex-shrink: 0;
}
.admin-settings-btn:hover { background: #e5e7eb; color: #111827; border-color: rgba(0,0,0,0.15); }
.admin-settings-btn svg { opacity: 0.75; }

/* 管理员：预制提示词编辑弹窗 */
.admin-prompt-modal { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center; }
.admin-prompt-modal-mask { position: absolute; inset: 0; background: rgba(0,0,0,0.45); }
.admin-prompt-modal-dialog {
    position: relative; z-index: 1;
    width: min(720px, 92vw); max-height: 88vh;
    background: #fff; border-radius: 10px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
    display: flex; flex-direction: column;
    overflow: hidden;
}
.admin-prompt-modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid rgba(0,0,0,0.08); }
.admin-prompt-modal-header h3 { font-size: 15px; font-weight: 600; color: #111827; margin: 0; }
.admin-prompt-modal-close { background: transparent; border: none; font-size: 22px; line-height: 1; color: #9ca3af; cursor: pointer; padding: 0 4px; }
.admin-prompt-modal-close:hover { color: #111827; }
.admin-prompt-modal-body { padding: 16px 20px; overflow-y: auto; flex: 1; }
.admin-prompt-modal-tip { font-size: 12px; color: #6b7280; margin-bottom: 12px; padding: 8px 10px; background: #f9fafb; border-radius: 6px; border-left: 3px solid #6366f1; }
.admin-prompt-field { margin-bottom: 14px; }
.admin-prompt-field label { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 6px; }
.admin-prompt-field textarea {
    width: 100%; padding: 10px 12px; font-size: 13px; line-height: 1.6;
    border: 1px solid rgba(0,0,0,0.12); border-radius: 6px;
    resize: vertical; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #1f2937; background: #fff;
}
.admin-prompt-field textarea:focus { outline: none; border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.12); }
.admin-prompt-status { min-height: 18px; font-size: 12px; margin-top: 4px; }
.admin-prompt-modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid rgba(0,0,0,0.08); background: #fafafa; }
.admin-prompt-btn { padding: 7px 16px; font-size: 13px; font-weight: 500; border-radius: 6px; cursor: pointer; transition: all 0.15s ease; border: 1px solid transparent; }
.admin-prompt-btn-secondary { background: #fff; color: #4b5563; border-color: rgba(0,0,0,0.12); }
.admin-prompt-btn-secondary:hover { background: #f3f4f6; }
.admin-prompt-btn-primary { background: #4f46e5; color: #fff; }
.admin-prompt-btn-primary:hover { background: #4338ca; }
.admin-prompt-btn-primary:disabled { background: #a5b4fc; cursor: not-allowed; }
.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); }

.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; }

.supplementary-prompt-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    background: #ffffff;
    color: #444;
    resize: vertical;
    min-height: 60px;
    max-height: 150px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
    line-height: 1.5;
}
.supplementary-prompt-input:focus {
    outline: none;
    border-color: rgba(0,0,0,0.25);
    box-shadow: 0 0 0 3px rgba(0,0,0,0.04);
}
.supplementary-prompt-input::placeholder {
    color: rgba(0,0,0,0.3);
}
.prompt-char-count {
    text-align: right;
    font-size: 11px;
    color: rgba(0,0,0,0.35);
    margin-top: 4px;
}

.form-select {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 8px;
    font-size: 14px;
    background: #ffffff !important;
    color: #444;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23e0e0e0' d='M6 8L1 3h10z'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    padding-right: 35px;
}
.form-select option { background: #ffffff !important; color: #333 !important; }
.form-select:focus { outline: none; border-color: #3444fe; box-shadow: 0 0 0 2px rgba(52, 68, 254, 0.2); }

/* 涓婁紶鍖哄煙 */
.upload-label-wrapper { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.upload-label-wrapper label { margin: 0; font-weight: 600; color: rgba(0,0,0,0.8); }
.upload-hint-inline { font-size: 12px; 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: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    background: rgba(0,0,0,0.02);
}
.upload-area-compact:hover { border-color: #3444fe; background: rgba(52, 68, 254, 0.1); }
.upload-area-compact.drag-over { border-color: #3444fe; background: rgba(52, 68, 254, 0.15); }
.upload-area-compact.compressing { border-color: #3444fe; pointer-events: none; opacity: 0.7; }
.upload-area-compact.compressing .upload-plus-icon { animation: cvUploadPulse 0.9s ease-in-out infinite; }
@keyframes cvUploadPulse { 0%,100% { opacity: 0.35; } 50% { opacity: 1; } }
.upload-plus-icon { font-size: 32px; color: rgba(0,0,0,0.35); pointer-events: none; }

.uploaded-images { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 15px; align-items: center; }

.uploaded-image {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.1);
}
.uploaded-image img { width: 100%; height: 100%; object-fit: cover; }

.remove-image {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    transition: all 0.2s;
}
.remove-image:hover { background: #ff4444; transform: scale(1.1); }

/* 灏哄閫夋嫨鍣?*/
.size-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 8px; }

.size-option {
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 8px;
    padding: 8px 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: rgba(0,0,0,0.03);
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 8px;
    pointer-events: auto;
    user-select: none;
    color: rgba(0,0,0,0.65);
}
.size-option:hover { border-color: #3444fe; background: rgba(52, 68, 254, 0.1); }
.size-option.selected { border-color: #3444fe; background: linear-gradient(135deg, #3444fe 0%, #2a36cb 100%); color: white; }

.size-icon { font-size: 18px; display: inline-block; pointer-events: none; }
.size-label { font-size: 14px; font-weight: 600; display: inline-block; pointer-events: none; }

/* 视图模式切换（标准版 / 三视图增强版） */
.layout-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 8px; }
.layout-option {
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 8px;
    padding: 10px 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: rgba(0,0,0,0.03);
    font-size: 14px;
    font-weight: 500;
    color: rgba(0,0,0,0.65);
    user-select: none;
    pointer-events: auto;
}
.layout-option:hover { border-color: #3444fe; background: rgba(52, 68, 254, 0.1); color: #3444fe; }
.layout-option.selected { border-color: #3444fe; background: linear-gradient(135deg, #3444fe 0%, #2a36cb 100%); color: white; font-weight: 600; }

/* 视图模式悬浮预览图 */
.layout-preview-pop {
    position: fixed;
    z-index: 99999;
    padding: 6px;
    background: #fff;
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.22);
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px) scale(0.98);
    transition: opacity 0.18s ease, transform 0.18s ease;
    pointer-events: none;
}
.layout-preview-pop.visible { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }
.layout-preview-pop img { display: block; max-width: 360px; max-height: 420px; width: auto; height: auto; border-radius: 6px; }

/* 分镜网格切换 */
.grid-toggle-group { display: flex; gap: 8px; margin-top: 8px; }
.grid-toggle-btn {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 8px; border: 1px solid rgba(0,0,0,0.1); border-radius: 8px;
    background: #fff; color: #666; font-size: 13px; font-weight: 500;
    cursor: pointer; transition: all 0.2s;
}
.grid-toggle-btn:hover { border-color: #3444fe; color: #3444fe; background: rgba(52,68,254,0.04); }
.grid-toggle-btn.active { border-color: #3444fe; background: rgba(52,68,254,0.08); color: #3444fe; font-weight: 600; }
.grid-toggle-btn svg { flex-shrink: 0; }

/* 比例切换 */
.ratio-toggle-group { display: flex; gap: 8px; margin-top: 8px; }
.ratio-toggle-btn {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    padding: 12px 8px; border: 1px solid rgba(0,0,0,0.1); border-radius: 8px;
    background: #fff; color: #666; font-size: 12px; font-weight: 500;
    cursor: pointer; transition: all 0.2s;
}
.ratio-toggle-btn:hover { border-color: #3444fe; color: #3444fe; background: rgba(52,68,254,0.04); }
.ratio-toggle-btn.active { border-color: #3444fe; background: rgba(52,68,254,0.08); color: #3444fe; font-weight: 600; }
.ratio-toggle-btn svg { flex-shrink: 0; }

/* 鑷畾涔夊昂瀵歌緭鍏?*/
.custom-size-inputs { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.size-input-group { flex: 1; display: flex; align-items: center; gap: 4px; background: rgba(0,0,0,0.03); border: 1px solid rgba(0,0,0,0.1); border-radius: 8px; padding: 6px 8px; min-width: 0; }
.size-input-group label { font-size: 11px; font-weight: 600; color: rgba(0,0,0,0.5); margin: 0; flex-shrink: 0; }
.size-input-group input { flex: 1; border: none; outline: none; font-size: 13px; font-weight: 500; text-align: center; padding: 0; background: transparent; color: #444; width: 50px; min-width: 0; }
.size-input-group .size-unit { font-size: 10px; color: rgba(0,0,0,0.35); flex-shrink: 0; }
.size-link-icon { cursor: pointer; font-size: 16px; transition: all 0.2s ease; user-select: none; color: rgba(0,0,0,0.45); flex-shrink: 0; }
.size-link-icon:hover { transform: scale(1.1); }
.size-link-icon.locked { color: #3444fe; }

/* 鐢熸垚鎸夐挳 */
.generate-btn {
    width: 100%;
    background: linear-gradient(135deg, #3444fe 0%, #2a36cb 100%);
    color: white;
    border: none;
    padding: 16px 24px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.generate-btn:hover { opacity: 0.9; transform: translateY(-1px); }
.generate-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.generate-btn .btn-text { flex: 1; }
.generate-btn .btn-power { background: rgba(0,0,0,0.12); padding: 4px 12px; border-radius: 20px; font-size: 13px; font-weight: 500; white-space: nowrap; }

/* 棰勮闈㈡澘 */
.preview-panel {
    flex: 1;
    background: #ffffff;
    border-radius: 0;
    padding: 0;
    border: none;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 40px);
    overflow: hidden;
}
.preview-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; margin-bottom: 0; border-bottom: 1px solid rgba(0,0,0,0.06); flex-shrink: 0; }
.preview-header h3 { font-size: 16px; font-weight: 600; color: #333; }
.preview-actions { display: flex; gap: 10px; }
.action-btn { padding: 8px 16px; border: none; border-radius: 6px; background: rgba(0,0,0,0.08); color: rgba(0,0,0,0.65); font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.2s; }
.action-btn:hover { border-color: #3444fe; background: rgba(52, 68, 254, 0.1); }

.preview-content { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; border-radius: 0; background: #fafafa; overflow: hidden; }
.preview-content img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; border-radius: 0; }
.preview-placeholder { text-align: center; color: rgba(0,0,0,0.35); }
.placeholder-icon { font-size: 48px; display: block; margin-bottom: 15px; color: #ccc; }
.placeholder-icon svg { width: 48px; height: 48px; }
.placeholder-hint { font-size: 12px; color: rgba(0,0,0,0.18); margin-top: 8px; }

/* 杩涘害鏉?*/
.generation-progress-inline { display: flex; align-items: center; gap: 10px; flex: 1; max-width: 300px; margin: 0 20px; }
.progress-bar-inline { flex: 1; height: 6px; background: rgba(0,0,0,0.08); border-radius: 3px; overflow: hidden; }
.progress-fill-inline { height: 100%; background: linear-gradient(90deg, #3444fe 0%, #2a36cb 100%); width: 0%; transition: width 0.3s ease; }
.progress-text-inline { color: #3444fe; font-size: 13px; font-weight: 500; white-space: nowrap; }

/* 鐢熸垚鍘嗗彶闈㈡澘 - 极简线条风格 */
.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; margin-bottom: 15px; padding-bottom: 10px; border-bottom: 1px solid rgba(0,0,0,0.08); }
.history-header h3 { font-size: 16px; font-weight: 600; color: #333; margin: 0; }
.clear-history-btn { background: none; border: none; font-size: 18px; cursor: pointer; padding: 5px; transition: all 0.2s ease; color: rgba(0,0,0,0.45); }
.clear-history-btn:hover { color: #ff6b6b; transform: scale(1.1); }

.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-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(52, 68, 254, 0.15); color: #3444fe; }
.history-status.failed { background: rgba(239, 68, 68, 0.2); color: #ef4444; cursor: help; }
.history-delete-btn { background: transparent; border: none; padding: 2px 6px; border-radius: 4px; cursor: pointer; font-size: 12px; opacity: 0.5; transition: all 0.2s ease; margin-left: auto; }
.history-delete-btn:hover { opacity: 1; background: rgba(239, 68, 68, 0.2); }

.history-prompt { font-size: 12px; color: rgba(0,0,0,0.65); margin-bottom: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-params { font-size: 11px; color: rgba(0,0,0,0.45); margin-bottom: 8px; }
.history-image-wrapper { position: relative; margin-top: 8px; overflow: hidden; }
.history-image { width: 100%; height: auto; border-radius: 6px; object-fit: contain; content-visibility: auto; }
.history-send-btn { position: absolute; top: 6px; left: 6px; width: 28px; height: 28px; border-radius: 50%; border: none; background: rgba(0,0,0,0.8); backdrop-filter: blur(4px); cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; transition: all 0.2s ease; z-index: 10; opacity: 0.7; }
.history-send-btn:hover { opacity: 1; transform: scale(1.1); background: #3444fe; color: white; }
.history-actions { display: flex; gap: 6px; margin-top: 8px; position: relative; z-index: 100; }
.history-action-btn { flex: 1; padding: 6px; border: none; border-radius: 6px; background: rgba(0,0,0,0.08); color: rgba(0,0,0,0.65); cursor: pointer; font-size: 11px; transition: all 0.3s ease; pointer-events: auto !important; position: relative; z-index: 10; }
.history-action-btn:hover { background: rgba(52, 68, 254, 0.2); color: #3444fe; }

/* 鍝嶅簲寮忚璁?*/
@media (max-width: 900px) {
    body { overflow-x: hidden !important; }
    .page-container { width: 100%; height: auto; min-height: 100vh; padding: 2px; overflow-x: hidden; overflow-y: auto; }
    .editor-container { flex-direction: column; gap: 2px; height: auto; }
    .control-panel { width: 100%; order: 1; flex-shrink: 0; max-height: none; overflow-y: visible; }
    .preview-panel { width: 100%; order: 2; min-height: 300px; height: auto; }
    .history-panel { width: 100%; order: 3; max-height: 400px; height: auto; }
    .form-select { font-size: 16px; }
    .generate-btn { padding: 15px 20px; font-size: 16px; }
}

