/* ============================================
   layout.css — 顶部栏 / 侧边栏 / 内容区 / 布局
   ============================================ */

#app { display: flex; flex-direction: column; height: 100vh; }

/* ---------- 顶部栏 ---------- */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
  padding: 0 20px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 16px; }

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--grad-accent);
  color: #fff;
  display: grid; place-items: center;
  font-size: 17px; font-weight: 700;
  box-shadow: 0 4px 14px var(--primary-glow);
}
.brand-text h1 { font-size: 17px; font-weight: 600; line-height: 1.2; letter-spacing: 0.5px; }
.brand-sub { font-size: 12px; color: var(--text-3); letter-spacing: 0.4px; }

.topbar-divider { width: 1px; height: 26px; background: var(--border); }

.current-module {
  font-size: 14px; color: var(--text-2);
  background: var(--surface-3);
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.topbar-right { display: flex; align-items: center; gap: 16px; }

.storage-status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-2);
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.storage-status.warn .status-dot { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.storage-status.error .status-dot { background: var(--err); box-shadow: 0 0 8px var(--err); }

/* 主题切换三态 */
.theme-switch {
  display: flex; gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
}
.theme-btn {
  width: 28px; height: 26px;
  border-radius: 7px;
  display: grid; place-items: center;
  color: var(--text-3);
  transition: all 0.2s ease;
}
.theme-btn:hover { color: var(--text-1); background: var(--surface-3); }
.theme-btn.active { color: var(--primary); background: var(--primary-soft); }

/* ---------- 主体 ---------- */
#body { display: flex; flex: 1; min-height: 0; }

/* ---------- 侧边栏 ---------- */
#sidebar {
  width: 268px;
  min-width: 268px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 14px;
  gap: 20px;
  overflow-y: auto;
}

.section-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 600; color: var(--text-3);
  letter-spacing: 0.6px;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.icon-btn {
  width: 24px; height: 24px; border-radius: 6px;
  display: grid; place-items: center;
  color: var(--text-3);
  transition: all 0.2s;
}
.icon-btn:hover { color: var(--primary); background: var(--primary-soft); }

/* API 凭证表单 */
.api-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}
.api-section .section-title { margin-bottom: 12px; }

.api-config-switch { margin-bottom: 10px; }
.field-label { display: block; font-size: 12px; color: var(--text-3); margin-bottom: 4px; font-weight: 500; }

.api-section select,
.api-section input[type="text"],
.api-section input[type="password"] {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 13px;
  color: var(--text-1);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.api-section select:focus,
.api-section input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.api-section select option { background: var(--surface); color: var(--text-1); }

.api-field { margin-bottom: 10px; }

.token-wrap { position: relative; }
.token-wrap input[type="password"], .token-wrap input[type="text"] { padding-right: 34px; }
.toggle-token {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px; border-radius: 6px;
  display: grid; place-items: center;
  color: var(--text-3);
}
.toggle-token:hover { color: var(--text-1); }

.api-actions { display: flex; gap: 6px; margin-top: 4px; }
.api-actions .btn { flex: 1; height: 32px; font-size: 13px; }

.api-notice {
  margin-top: 10px; font-size: 12px; color: var(--text-3);
  line-height: 1.5;
  padding: 8px;
  background: var(--surface-2);
  border-radius: 8px;
  border: 1px dashed var(--border);
}
.api-status { margin-top: 8px; font-size: 13px; min-height: 16px; }
.api-status.ok { color: var(--ok); }
.api-status.err { color: var(--err); }

/* 导航菜单 */
.nav-menu { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  color: var(--text-2);
  font-size: 14px; font-weight: 500;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}
.nav-item svg { color: var(--text-3); flex-shrink: 0; }
.nav-item:hover { background: var(--surface-2); color: var(--text-1); text-decoration: none; }
.nav-item:hover svg { color: var(--primary); }
.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary-strong);
  border-color: var(--primary-glow);
  box-shadow: inset 3px 0 0 var(--primary);
}
.nav-item.active svg { color: var(--primary-strong); }

/* ---------- 内容区 ---------- */
#content {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 20px 24px 40px;
}

.view { animation: viewIn 0.28s ease; }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.view-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.view-head h2 { font-size: 18px; font-weight: 600; }
.view-actions { display: flex; gap: 8px; }

/* 占位视图 */
.placeholder-view {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 60vh; text-align: center; color: var(--text-3); gap: 12px;
}
.placeholder-icon {
  width: 72px; height: 72px; border-radius: 20px;
  background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center;
}
.placeholder-view h3 { font-size: 17px; color: var(--text-2); }
.placeholder-view p { font-size: 14px; }

/* 翻译模块布局 */
.post-module {
  display: block;
}
.post-main { min-width: 0; display: flex; flex-direction: column; gap: 14px; }

/* 侧边栏可折叠区块（API 凭证 / 引擎配置） */
.sidebar-collapse {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.sidebar-collapse summary {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  list-style: none;
  user-select: none;
  color: var(--text-2);
  transition: color 0.2s;
}
.sidebar-collapse summary::-webkit-details-marker { display: none; }
.sidebar-collapse summary:hover { color: var(--primary-strong); }
.sidebar-collapse summary .collapse-title {
  display: flex; align-items: center; gap: 8px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-3);
}
.sidebar-collapse summary .collapse-title::before {
  content: "";
  width: 8px; height: 8px; border-right: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3);
  transform: rotate(-45deg); transition: transform 0.2s; margin-top: -3px;
}
.sidebar-collapse[open] summary .collapse-title::before { transform: rotate(45deg); }
.sidebar-collapse[open] summary .collapse-title { color: var(--primary-strong); }
.sidebar-collapse .collapse-body {
  padding: 4px 14px 14px;
  border-top: 1px solid var(--border);
}
.sidebar-collapse summary .icon-btn { flex-shrink: 0; }

/* 引擎配置（侧边栏） */
.engine-section .collapse-body { padding-top: 12px; }
.engine-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.engine-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.engine-field select {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 13px;
  color: var(--text-1);
  white-space: nowrap;
  text-overflow: ellipsis;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.engine-field select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.engine-field select option { background: var(--surface); color: var(--text-1); white-space: nowrap; }

/* 策略面板 */
.strategy-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.strategy-group { margin-bottom: 14px; }
.strategy-group:last-child { margin-bottom: 0; }
.strategy-title { font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 8px; }

.radio-row { display: flex; flex-wrap: wrap; gap: 6px; }
.radio-pill {
  padding: 6px 12px; border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 13px; color: var(--text-2);
  transition: all 0.2s;
}
.radio-pill:hover { border-color: var(--primary); color: var(--primary-strong); }
.radio-pill.selected { background: var(--primary-soft); color: var(--primary-strong); border-color: var(--primary); font-weight: 500; }

.strategy-textarea {
  width: 100%; min-height: 56px;
  padding: 8px 10px;
  border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 13px; color: var(--text-1);
  resize: vertical;
}
.strategy-textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }

/* 操作按钮行 */
.action-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.action-row .spacer { flex: 1; }
.trans-table-toolbar { display: flex; align-items: center; gap: 8px; padding: 6px 0 6px; border-top: 1px solid var(--border); margin-top: 8px; }
.trans-table-toolbar .spacer { flex: 1; }

/* 进度区 */
.progress-area { display: flex; align-items: center; gap: 12px; }
.progress-bar {
  flex: 0 0 50%; max-width: 50%; height: 8px; border-radius: 6px;
  background: var(--surface-3);
  overflow: hidden;
  position: relative;
}
.progress-fill {
  height: 100%; width: 0%;
  background: var(--grad-accent);
  border-radius: 6px;
  transition: width 0.25s ease;
  box-shadow: 0 0 10px var(--primary-glow);
}
.progress-text { font-size: 13px; color: var(--text-2); min-width: 46px; text-align: right; font-variant-numeric: tabular-nums; }

/* 气泡浮层 */
.bubble-layer { position: fixed; z-index: 200; pointer-events: none; }
.bubble-layer[hidden] { display: none !important; }
.bubble {
  pointer-events: auto;
  max-width: 320px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: var(--shadow-lg);
  font-size: 13px; color: var(--text-1);
  animation: bubbleIn 0.18s ease;
}
.bubble-text {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}
.bubble-copy {
  display: block;
  margin-top: 10px;
  margin-left: auto;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.bubble-copy:hover { background: var(--surface-3); color: var(--text-1); }
.bubble::before {
  content: "";
  position: absolute; left: 14px; top: -6px;
  width: 10px; height: 10px;
  background: var(--surface);
  border-left: 1px solid var(--border-strong);
  border-top: 1px solid var(--border-strong);
  transform: rotate(45deg);
}
@keyframes bubbleIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* 弹窗浮层 */
.modal-layer { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; background: rgba(0,0,0,0.45); animation: fadeIn 0.2s; }
.modal-layer[hidden] { display: none !important; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  width: min(440px, 92vw);
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.22s ease;
  overflow: hidden;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.96) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-head { padding: 16px 18px 6px; font-size: 15px; font-weight: 600; }
.modal-body { padding: 8px 18px 14px; color: var(--text-2); font-size: 14px; }
.modal-foot { padding: 12px 18px 16px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--border); }
.modal-sm { width: min(320px, 88vw); }
.modal-sm .modal-head { padding: 14px 16px 4px; }
.modal-sm .modal-body { padding: 6px 16px 12px; }
.modal-sm .modal-foot { padding: 10px 16px 14px; }

/* ---------- 贴文助手 ---------- */
.post-assistant { display: flex; flex-direction: column; gap: 14px; }
.pa-scene-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pa-scene-label { font-size: 13px; color: var(--text-2); font-weight: 500; }
.pa-scene-desc { font-size: 12px; color: var(--text-3); }

.pa-io-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: stretch;
}
.pa-box {
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.pa-box-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  font-size: 13px; font-weight: 600; color: var(--text-2);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.pa-textarea {
  flex: 1;
  min-height: 320px;
  padding: 12px 14px;
  border: none;
  background: transparent;
  font-size: 14px; line-height: 1.6;
  color: var(--text-1);
  resize: vertical;
}
.pa-textarea:focus { outline: none; }
.pa-textarea::placeholder { color: var(--text-3); }

.pa-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pa-actions .spacer { flex: 1; }
.pa-status { font-size: 13px; }
.pa-status.ok { color: var(--ok); }
.pa-status.err { color: var(--err); }
.pa-status.info { color: var(--text-2); }

@media (max-width: 860px) {
  .pa-io-row { grid-template-columns: 1fr; }
}
