/**
 * lawdiffusion.com — API 配置面板样式
 * 纸墨金配色 · 面板从左滑出 · 480px 宽
 */

/* ================================================================
 * 齿轮入口按钮 — 左上角固定
 * ================================================================ */
.api-gear-btn {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 9998;
  width: 36px;
  height: 36px;
  border: 1.5px solid #e0d4c0;
  border-radius: 8px;
  background: #fefcf7;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 2px 8px rgba(60, 40, 20, .08);
  transition: background .15s, border-color .15s, box-shadow .15s;
  user-select: none;
  -webkit-user-select: none;
}
.api-gear-btn:hover {
  background: #f0e8d8;
  border-color: #c8a96e;
  box-shadow: 0 2px 12px rgba(60, 40, 20, .14);
}
.api-gear-btn:active {
  transform: scale(.95);
}

/* ================================================================
 * 遮罩层
 * ================================================================ */
.api-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s;
}
.api-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* ---- 半透明背景 ---- */
.api-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(30, 20, 10, .4);
}

/* ================================================================
 * 面板 — 从左滑入
 * ================================================================ */
.api-panel {
  position: relative;
  width: 480px;
  max-width: 100vw;
  height: 100vh;
  background: #fdfaf3;
  border-right: 1px solid #e8dcc8;
  box-shadow: 4px 0 24px rgba(60, 40, 20, .12);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform .28s cubic-bezier(.4, 0, .2, 1);
}
.api-overlay.active .api-panel {
  transform: translateX(0);
}

/* ================================================================
 * 标题行
 * ================================================================ */
.api-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 14px;
  border-bottom: 1px solid #ebe3d2;
  flex-shrink: 0;
}
.api-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  color: #3c2a1e;
}
.api-close {
  width: 30px;
  height: 30px;
  border: none;
  background: none;
  font-size: 22px;
  color: #8c7b6b;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
}
.api-close:hover {
  background: #f0e8d8;
  color: #3c2a1e;
}

/* ================================================================
 * 主体滚动区
 * ================================================================ */
.api-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 24px;
}

/* ================================================================
 * AI 开关行
 * ================================================================ */
.api-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  margin-bottom: 14px;
  background: #fdf7ee;
  border: 1px solid #ebe3d2;
  border-radius: 8px;
}
.api-toggle-label {
  font-size: 13px;
  font-weight: 500;
  color: #3c2a1e;
}

/* ---- CSS-only toggle switch ---- */
.api-toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  cursor: pointer;
}
.api-toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.api-toggle-slider {
  position: absolute;
  inset: 0;
  background: #d4c8b0;
  border-radius: 24px;
  transition: background .2s;
}
.api-toggle-slider::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .15);
  transition: transform .2s;
}
.api-toggle-switch input:checked + .api-toggle-slider {
  background: #b8944c;
}
.api-toggle-switch input:checked + .api-toggle-slider::before {
  transform: translateX(20px);
}

/* ================================================================
 * 表单字段
 * ================================================================ */
.api-field {
  margin-bottom: 16px;
}
.api-field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: #6b5c4a;
  margin-bottom: 5px;
}
.api-link {
  font-size: 11px;
  color: #b8944c;
  margin-left: 8px;
  text-decoration: none;
  font-weight: 400;
}
.api-link:hover {
  text-decoration: underline;
}

/* ---- 通用输入 / 下拉 ---- */
.api-field select,
.api-field input[type="text"],
.api-field input[type="password"] {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid #e0d4c0;
  border-radius: 8px;
  font-size: 13px;
  color: #3c2a1e;
  background: #fefcf7;
  box-sizing: border-box;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.api-field select:focus,
.api-field input:focus {
  outline: none;
  border-color: #b8944c;
  box-shadow: 0 0 0 3px rgba(184, 148, 76, .1);
  background: #fff;
}

/* ---- Key 输入行 ---- */
.api-key-row {
  display: flex;
  gap: 6px;
}
.api-key-row input {
  flex: 1;
}

/* ---- 显示/隐藏按钮 ---- */
.api-btn-icon {
  width: 38px;
  height: 38px;
  border: 1.5px solid #e0d4c0;
  border-radius: 8px;
  background: #fefcf7;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  line-height: 1;
}
.api-btn-icon:hover {
  background: #f0e8d8;
  border-color: #c8a96e;
}

/* ================================================================
 * 模型加载 & 错误
 * ================================================================ */
.api-model-loading {
  margin-top: 6px;
  font-size: 12px;
  color: #a89880;
  padding: 6px 10px;
  background: #fdf7ee;
  border-radius: 6px;
}
.api-model-error {
  margin-top: 8px;
}
.api-model-error span {
  display: block;
  font-size: 11px;
  color: #c08050;
  margin-bottom: 6px;
}
.api-model-error input {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid #e0d4c0;
  border-radius: 8px;
  font-size: 13px;
  color: #3c2a1e;
  background: #fefcf7;
  box-sizing: border-box;
  font-family: inherit;
}
.api-model-error input:focus {
  outline: none;
  border-color: #b8944c;
  box-shadow: 0 0 0 3px rgba(184, 148, 76, .1);
  background: #fff;
}

/* ================================================================
 * 记住 Key 区块
 * ================================================================ */
.api-remember {
  margin-bottom: 12px;
}
.api-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: #6b5c4a;
  user-select: none;
  -webkit-user-select: none;
}
.api-checkbox input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: #b8944c;
  cursor: pointer;
  margin: 0;
}
.api-remember-hint {
  margin-top: 6px;
  font-size: 11px;
  color: #a89880;
  line-height: 1.5;
  padding: 8px 10px;
  background: #fdf7ee;
  border-radius: 6px;
}

/* ================================================================
 * 测试结果
 * ================================================================ */
.api-test {
  margin-top: 4px;
  font-size: 12px;
  min-height: 18px;
}
.api-testing {
  color: #a89880;
}
.api-test-ok {
  color: #5a8a4a;
  font-weight: 500;
}
.api-test-err {
  color: #c06050;
}

/* ================================================================
 * 底部操作栏
 * ================================================================ */
.api-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 24px;
  border-top: 1px solid #ebe3d2;
  background: #fefcf7;
  flex-shrink: 0;
}

/* ---- 测试连接按钮 ---- */
.api-btn-test {
  padding: 8px 16px;
  border: 1.5px solid #c8a96e;
  border-radius: 7px;
  background: transparent;
  color: #7a5c30;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  margin-right: auto;
}
.api-btn-test:hover {
  background: #faf3e3;
}

/* ---- 清除按钮 ---- */
.api-btn-clear {
  padding: 8px 16px;
  border: 1.5px solid #d4b8b8;
  border-radius: 7px;
  background: transparent;
  color: #a07070;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.api-btn-clear:hover {
  background: #fdf5f5;
}

/* ---- 保存按钮 ---- */
.api-btn-save {
  padding: 8px 24px;
  border: none;
  border-radius: 8px;
  background: #b8944c;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: .02em;
}
.api-btn-save:hover {
  background: #a07d3a;
  box-shadow: 0 2px 8px rgba(160, 120, 50, .25);
}
.api-btn-save:active {
  transform: scale(.97);
}

/* ================================================================
 * 移动端 — 全宽弹窗
 * ================================================================ */
@media (max-width: 640px) {
  .api-panel {
    width: 100vw;
    max-width: 100vw;
  }
  .api-body {
    padding: 12px 16px;
  }
  .api-head {
    padding: 14px 16px 12px;
  }
  .api-foot {
    padding: 12px 16px;
    gap: 8px;
  }
  .api-btn-test,
  .api-btn-clear {
    padding: 7px 12px;
    font-size: 11px;
  }
  .api-btn-save {
    padding: 7px 18px;
    font-size: 12px;
  }
  .api-gear-btn {
    top: 10px;
    left: 10px;
  }
}
