/* Agnes AI 创作工具 - 主样式 v3 */

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

:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --bg-color: #f5f5f5;
  --card-bg: #ffffff;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --border-color: #e5e7eb;
  --error-color: #dc2626;
  --success-color: #16a34a;
  --warning-color: #d97706;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  line-height: 1.5;
}

.app-container { display: flex; flex-direction: column; height: 100vh; }

/* 顶部 */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background-color: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}
.header-left { display: flex; align-items: center; gap: 12px; }
.app-title { font-size: 18px; font-weight: 600; }
.header-right { display: flex; align-items: center; gap: 8px; }

.credit-badge {
  font-size: 13px;
  padding: 4px 12px;
  background-color: #fef3c7;
  color: var(--warning-color);
  border-radius: 12px;
  font-weight: 600;
}

.user-badge {
  font-size: 12px;
  padding: 4px 10px;
  background-color: #dcfce7;
  color: var(--success-color);
  border-radius: 12px;
  font-weight: 500;
}

.icon-btn {
  width: 36px; height: 36px;
  border: none; background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  transition: background-color 0.2s;
}
.icon-btn:hover { background-color: var(--bg-color); }

/* 主内容 */
.main-content { display: flex; flex: 1; overflow: hidden; }
.sidebar {
  width: 220px;
  background-color: var(--card-bg);
  border-right: 1px solid var(--border-color);
  padding: 16px;
  display: flex; flex-direction: column; gap: 24px;
  overflow-y: auto;
}
.mode-nav { display: flex; flex-direction: column; gap: 8px; }
.mode-btn {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--card-bg);
  cursor: pointer; text-align: left;
  transition: all 0.2s;
}
.mode-btn:hover { border-color: var(--primary-color); background-color: #eff6ff; }
.mode-btn.active { border-color: var(--primary-color); background-color: #eff6ff; color: var(--primary-color); }
.mode-icon { font-size: 24px; }
.mode-text { font-weight: 500; font-size: 14px; }

.status-section {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
  display: flex; flex-direction: column; gap: 10px;
}
.status-item {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--text-secondary);
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background-color: #d1d5db; }
.status-dot.online { background-color: var(--success-color); }
.status-value {
  max-width: 120px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; color: var(--text-primary); font-weight: 500;
}

.workspace { flex: 1; padding: 20px; overflow-y: auto; background-color: var(--bg-color); }

.panel {
  display: none;
  background-color: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.panel.active { display: block; }
.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  background-color: #fafafa;
}
.panel-header h2 { font-size: 16px; font-weight: 600; }

.panel-content { padding: 20px; display: flex; flex-direction: column; gap: 20px; }

.section-label { font-size: 14px; font-weight: 500; color: var(--text-primary); }

/* 模型选择 */
.model-section { display: flex; flex-direction: column; gap: 10px; }
.model-options { display: flex; gap: 8px; }
.model-btn {
  padding: 10px 24px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--card-bg);
  cursor: pointer;
  font-size: 16px; font-weight: 700;
  color: var(--text-secondary);
  transition: all 0.2s;
  min-width: 60px;
}
.model-btn:hover { border-color: var(--primary-color); color: var(--primary-color); }
.model-btn.active {
  border-color: var(--primary-color);
  background-color: var(--primary-color);
  color: white;
}

.mode-toggle-section { display: flex; flex-direction: column; gap: 10px; }
.toggle-group { display: flex; gap: 8px; }
.toggle-btn {
  padding: 8px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--card-bg);
  cursor: pointer; font-size: 14px; font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.2s;
}
.toggle-btn:hover { border-color: var(--primary-color); color: var(--primary-color); }
.toggle-btn.active { border-color: var(--primary-color); background-color: var(--primary-color); color: white; }

.info-text {
  font-size: 12px; color: var(--text-secondary);
  display: flex; align-items: center; gap: 6px;
}
.info-text::before { content: 'ℹ️'; font-size: 14px; }

/* 上传 */
.upload-section { display: flex; flex-direction: column; gap: 10px; }
.upload-area {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center; cursor: pointer;
  transition: all 0.2s;
  background-color: #fafafa;
}
.upload-area:hover { border-color: var(--primary-color); background-color: #eff6ff; }
.upload-area.dragover { border-color: var(--primary-color); background-color: #dbeafe; }
.upload-placeholder {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  color: var(--text-secondary);
}
.upload-icon { font-size: 32px; }
.upload-text { font-size: 14px; }
.upload-preview-list { display: flex; flex-wrap: wrap; gap: 10px; }
.upload-preview-list:empty { display: none; }
.preview-item {
  position: relative; width: 80px; height: 80px;
  border-radius: var(--radius-sm); overflow: hidden;
  border: 1px solid var(--border-color); background-color: #f3f4f6;
}
.preview-item img { width: 100%; height: 100%; object-fit: cover; }
.preview-remove {
  position: absolute; top: 2px; right: 2px;
  width: 18px; height: 18px;
  background-color: rgba(0,0,0,0.7); color: white;
  border: none; border-radius: 50%; cursor: pointer;
  font-size: 11px; padding: 0; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.preview-remove:hover { background-color: var(--error-color); }
.preview-index {
  position: absolute; bottom: 2px; left: 2px;
  font-size: 10px;
  background-color: rgba(0,0,0,0.6); color: white;
  padding: 1px 5px; border-radius: 8px;
}

/* 提示词 */
.prompt-section { display: flex; flex-direction: column; gap: 8px; }
.prompt-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 14px; line-height: 1.5;
  resize: vertical; min-height: 80px;
  font-family: inherit;
}
.prompt-input:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.prompt-input::placeholder { color: #9ca3af; }

/* 清晰度/比例 */
.quality-section, .ratio-section { display: flex; flex-direction: column; gap: 10px; }
.quality-options, .ratio-options { display: flex; gap: 8px; flex-wrap: wrap; }
.quality-btn, .ratio-btn {
  padding: 8px 20px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--card-bg);
  cursor: pointer; font-size: 14px; font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.2s;
  position: relative;
}
.quality-btn:hover, .ratio-btn:hover { border-color: var(--primary-color); color: var(--primary-color); }
.quality-btn.active, .ratio-btn.active {
  border-color: var(--primary-color);
  background-color: var(--primary-color);
  color: white;
}
.cost-tag {
  display: inline-block;
  margin-left: 6px;
  font-size: 11px;
  padding: 1px 6px;
  background-color: rgba(0,0,0,0.08);
  border-radius: 8px;
  font-weight: 400;
}
.quality-btn.active .cost-tag { background-color: rgba(255,255,255,0.25); }

/* 进度 */
.progress-section { display: flex; flex-direction: column; gap: 10px; }
.progress-bar-container {
  width: 100%; height: 8px;
  background-color: #e5e7eb; border-radius: 4px; overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-color), #60a5fa);
  border-radius: 4px; width: 0%;
  transition: width 0.3s ease;
}
.progress-bar.animating { animation: progress-indeterminate 1.5s ease-in-out infinite; }
@keyframes progress-indeterminate {
  0% { transform: translateX(-100%); }
  50% { transform: translateX(0%); }
  100% { transform: translateX(100%); }
}
.progress-text { font-size: 13px; color: var(--text-secondary); text-align: right; }

/* 结果 */
.result-section { display: flex; flex-direction: column; gap: 10px; }
.result-header { display: flex; justify-content: space-between; align-items: center; }
.btn-save {
  background-color: var(--success-color);
  color: white;
  display: inline-flex; align-items: center; gap: 4px;
}
.btn-save:hover { background-color: #15803d; }

.result-container {
  width: 100%;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: #000;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative;
  aspect-ratio: 16 / 9;
  max-height: 480px;
  transition: aspect-ratio 0.3s ease;
}
.result-container[data-ratio="9:16"] {
  aspect-ratio: 9 / 16;
  max-height: 600px; max-width: 360px;
  margin: 0 auto;
}
.result-container[data-ratio="16:9"] { aspect-ratio: 16 / 9; }
.result-placeholder {
  display: flex; align-items: center; justify-content: center;
  padding: 40px; width: 100%;
}
.placeholder-text { color: #9ca3af; font-size: 14px; }
.result-image, .result-video { max-width: 100%; max-height: 100%; object-fit: contain; }

/* 错误 */
.error-message {
  padding: 10px 16px;
  background-color: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  color: var(--error-color);
  font-size: 13px; display: none;
  animation: slideIn 0.3s ease;
}
.error-message.show { display: block; }
.error-message.hiding { animation: fadeOut 0.5s ease forwards; }
@keyframes slideIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

/* 按钮 */
.action-buttons { display: flex; justify-content: flex-end; gap: 12px; padding-top: 10px; }
.btn {
  padding: 10px 24px;
  border: none; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: all 0.2s;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background-color: var(--primary-color); color: white; }
.btn-primary:hover:not(:disabled) { background-color: var(--primary-hover); }
.btn-cancel { background-color: var(--card-bg); color: var(--text-secondary); border: 1px solid var(--border-color); }
.btn-cancel:hover:not(:disabled) { background-color: var(--bg-color); }
.btn-secondary { background-color: var(--card-bg); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-secondary:hover { background-color: var(--bg-color); border-color: var(--primary-color); }
.btn-link { background: transparent; color: var(--primary-color); border: none; text-decoration: underline; cursor: pointer; font-size: 13px; padding: 6px; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; }

/* 弹窗 */
.modal {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  background-color: rgba(0,0,0,0.5);
  display: none;
  align-items: center; justify-content: center;
  z-index: 1000;
}
.modal.show { display: flex; }
.modal-content {
  background-color: var(--card-bg);
  border-radius: var(--radius-lg);
  width: 90%; max-width: 480px;
  box-shadow: var(--shadow-lg);
  animation: modalSlideIn 0.3s ease;
  max-height: 90vh; overflow: hidden;
  display: flex; flex-direction: column;
}
@keyframes modalSlideIn { from { opacity: 0; transform: scale(0.95) translateY(-20px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: 12px; padding: 16px 20px; border-top: 1px solid var(--border-color); flex-wrap: wrap; }

.login-modal { max-width: 420px; }
.login-header { text-align: center; padding: 32px 20px 20px; border-bottom: 1px solid var(--border-color); }
.login-logo { font-size: 48px; margin-bottom: 12px; }
.login-header h2 { font-size: 20px; font-weight: 600; margin-bottom: 6px; }
.login-subtitle { font-size: 14px; color: var(--text-secondary); }
.login-tips {
  margin-top: 12px; padding: 12px;
  background-color: #f9fafb; border-radius: var(--radius-sm);
  font-size: 12px; color: var(--text-secondary); line-height: 1.7;
}
.login-tips a { color: var(--primary-color); text-decoration: none; }
.login-tips a:hover { text-decoration: underline; }

/* 配置面板 */
.config-form { display: flex; flex-direction: column; gap: 24px; }
.config-block {
  padding: 16px;
  background-color: #f9fafb;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}
.config-block-title { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.form-group { margin-bottom: 12px; }
.form-group:last-child { margin-bottom: 0; }
.form-group label {
  display: block; font-size: 13px; font-weight: 500;
  color: var(--text-secondary); margin-bottom: 6px;
}
.form-group input[type="password"],
.form-group input[type="text"] {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.form-group input:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.input-with-button { display: flex; gap: 8px; }
.input-with-button input { flex: 1; }

.credit-display {
  font-size: 20px; font-weight: 700;
  color: var(--warning-color);
  padding: 8px 12px;
  background-color: #fef3c7;
  border-radius: var(--radius-sm);
  display: inline-block;
}

.model-info {
  background-color: var(--card-bg);
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-secondary);
  border: 1px solid var(--border-color);
}
.model-info p { margin-bottom: 6px; }
.model-info p:last-child { margin-bottom: 0; }

/* Toast */
#toastContainer {
  position: fixed; bottom: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 10000;
}
.toast {
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px; color: white;
  animation: slideInRight 0.3s ease;
  min-width: 200px;
  box-shadow: var(--shadow-md);
}
.toast.success { background-color: var(--success-color); }
.toast.error { background-color: var(--error-color); }
.toast.info { background-color: var(--primary-color); }
.toast.hiding { animation: fadeOut 0.3s ease forwards; }
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* 加载 */
.spinner {
  width: 40px; height: 40px;
  border: 3px solid #374151;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-state { text-align: center; color: #9ca3af; padding: 40px; }
.loading-state p { margin-top: 12px; font-size: 14px; }

@media (max-width: 900px) {
  .sidebar { width: 180px; }
  .mode-text { display: none; }
  .mode-btn { justify-content: center; padding: 12px; }
}
