/* AI 配置面板样式 - 浮动按钮 + 弹窗 */
/* 与平台紫蓝渐变风格一致，fixed定位确保壳子重排后仍正常显示 */

/* ============ 浮动按钮 ============ */
.ai-config-fab {
  position: fixed !important;
  right: 22px !important;
  bottom: 22px !important;
  z-index: 9999 !important;
  width: auto !important;
  display: inline-flex !important;
  align-items: center;
  gap: 0.4rem;
  padding: 0.7rem 1.1rem;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(102, 126, 234, 0.45);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.ai-config-fab:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 14px 34px rgba(102, 126, 234, 0.55);
}
.ai-config-fab i {
  font-size: 1rem;
}
.ai-config-fab .ai-config-fab-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff5252;
  margin-left: 0.2rem;
  box-shadow: 0 0 6px rgba(255, 82, 82, 0.8);
}
.ai-config-fab.is-ready .ai-config-fab-dot {
  background: #4ade80;
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.8);
}

@media (max-width: 480px) {
  .ai-config-fab {
    right: 14px;
    bottom: 14px;
    padding: 0.6rem 0.9rem;
    font-size: 0.82rem;
  }
}

/* ============ 弹窗遮罩 ============ */
.ai-config-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.ai-config-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* ============ 弹窗主体 ============ */
.ai-config-modal {
  width: min(560px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 30px 70px rgba(15, 23, 42, 0.35);
  overflow: hidden;
  transform: translateY(20px) scale(0.97);
  transition: transform 0.25s ease;
}
.ai-config-overlay.is-open .ai-config-modal {
  transform: translateY(0) scale(1);
}

.ai-config-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1.4rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}
.ai-config-header h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.ai-config-close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1.7rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: 8px;
  transition: background 0.2s ease;
}
.ai-config-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ============ Tabs ============ */
.ai-config-tabs {
  display: flex;
  gap: 0.35rem;
  padding: 0.8rem 1.4rem 0;
  border-bottom: 1px solid #f0f2f8;
  overflow-x: auto;
  scrollbar-width: thin;
}
.ai-config-tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.6rem 0.9rem;
  border: none;
  background: transparent;
  color: #6b7280;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.ai-config-tab:hover {
  color: #4f46e5;
}
.ai-config-tab.active {
  color: #667eea;
  border-bottom-color: #667eea;
}
.ai-config-tab .ai-tab-status {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #e5e7eb;
}
.ai-config-tab.is-configured .ai-tab-status {
  background: #4ade80;
}

/* ============ 表单 ============ */
.ai-config-body {
  padding: 1.3rem 1.4rem;
  overflow-y: auto;
  flex: 1;
}
.ai-form-group {
  margin-bottom: 1rem;
}
.ai-form-group label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
}
.ai-form-group label .ai-label-hint {
  font-weight: 400;
  color: #9ca3af;
  font-size: 0.78rem;
  margin-left: 0.3rem;
}
.ai-form-group input[type="text"],
.ai-form-group input[type="password"],
.ai-form-group select {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
  background: #fff;
  color: #1f2937;
}
.ai-form-group input:focus,
.ai-form-group select:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.12);
}
.ai-input-with-action {
  display: flex;
  gap: 0.5rem;
}
.ai-input-with-action input {
  flex: 1;
}
.ai-icon-btn {
  flex: 0 0 auto;
  width: 42px;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  background: #f9fafb;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.2s ease;
}
.ai-icon-btn:hover {
  background: #f3f4f6;
  color: #4f46e5;
}

.ai-form-tip {
  margin-top: 0.4rem;
  font-size: 0.78rem;
  color: #9ca3af;
  line-height: 1.5;
}
.ai-form-tip a {
  color: #667eea;
  text-decoration: none;
}
.ai-form-tip a:hover {
  text-decoration: underline;
}

.ai-form-helplink {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: #667eea;
  font-size: 0.8rem;
  text-decoration: none;
  margin-top: 0.3rem;
}
.ai-form-helplink:hover {
  text-decoration: underline;
}

/* ============ Footer ============ */
.ai-config-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.4rem;
  border-top: 1px solid #f0f2f8;
  background: #fafbfc;
}
.ai-config-status {
  font-size: 0.8rem;
  color: #6b7280;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.ai-config-status .ai-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e5e7eb;
}
.ai-config-status.is-ok .ai-status-dot {
  background: #4ade80;
}
.ai-config-status.is-err .ai-status-dot {
  background: #f87171;
}
.ai-config-footer-actions {
  display: flex;
  gap: 0.5rem;
}

/* ============ 按钮 ============ */
.ai-btn {
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 10px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}
.ai-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.ai-btn-save {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}
.ai-btn-save:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.35);
}
.ai-btn-test {
  background: #f3f4f6;
  color: #4f46e5;
}
.ai-btn-test:hover:not(:disabled) {
  background: #e0e7ff;
}
.ai-btn-clear {
  background: transparent;
  color: #9ca3af;
  border: 1.5px solid #e5e7eb;
}
.ai-btn-clear:hover:not(:disabled) {
  color: #ef4444;
  border-color: #fecaca;
}

/* ============ 提示条 ============ */
.ai-config-toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  z-index: 10001;
  padding: 0.7rem 1.4rem;
  border-radius: 12px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  max-width: 90vw;
}
.ai-config-toast.is-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.ai-config-toast.is-ok {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}
.ai-config-toast.is-err {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}
.ai-config-toast.is-loading {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* ============ 配置提示条 ============ */
.ai-config-banner {
  width: 100% !important;
  margin-bottom: 16px;
  border-radius: 12px;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 1.5px solid #f59e0b;
  padding: 12px 16px;
  box-sizing: border-box;
  animation: bannerSlideIn 0.3s ease;
}
@keyframes bannerSlideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}
.ai-config-banner-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.ai-config-banner-icon {
  font-size: 1.2rem;
  color: #d97706;
  flex-shrink: 0;
}
.ai-config-banner-text {
  flex: 1;
  min-width: 200px;
  font-size: 0.88rem;
  color: #92400e;
  line-height: 1.5;
}
.ai-config-banner-text strong {
  color: #78350f;
}
.ai-config-banner-btn {
  padding: 6px 16px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;
}
.ai-config-banner-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}
.ai-config-banner-close {
  background: transparent;
  border: none;
  color: #92400e;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  flex-shrink: 0;
}
.ai-config-banner-close:hover {
  color: #78350f;
}

@media (max-width: 480px) {
  .ai-config-modal {
    max-height: 92vh;
    border-radius: 18px;
  }
  .ai-config-header,
  .ai-config-body,
  .ai-config-footer {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  .ai-config-footer {
    flex-direction: column;
    align-items: stretch;
  }
  .ai-config-footer-actions {
    justify-content: space-between;
  }
  .ai-btn {
    flex: 1;
  }
}
