/* ============================================================
   Platform Management — 卡片网格 + 筛选 + Modal 弹窗
   复用 base.css 变量体系
   ============================================================ */

/* ---- 顶栏 ---- */
.pfm-topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 0 0 16px 0; flex-shrink: 0; flex-wrap: wrap;
}

/* ---- 筛选 Tab ---- */
.pfm-filter {
  display: flex; align-items: center; gap: 4px;
  background: var(--bg-secondary); border-radius: var(--radius-lg); padding: 3px;
}
.pfm-ftab {
  padding: 6px 16px; border: none; background: transparent;
  color: var(--text-secondary); font-size: 12px; font-weight: 500;
  border-radius: var(--radius); cursor: pointer; transition: all var(--transition);
  white-space: nowrap;
}
.pfm-ftab:hover { color: var(--text-primary); }
.pfm-ftab.active {
  background: var(--bg-card); color: var(--text-primary); font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.pfm-count {
  font-size: 11px; color: var(--text-muted); padding: 0 10px;
  white-space: nowrap;
}

.pfm-actions {
  display: flex; gap: 8px; align-items: center;
}

/* ---- 卡片网格 ---- */
.pfm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px; flex: 1; overflow-y: auto; align-content: start;
  padding: 2px 0;
}

/* ---- 空状态 / 加载 ---- */
.pfm-grid .loading-state,
.pfm-grid .empty-state {
  grid-column: 1 / -1; text-align: center; padding: 48px 0;
}

/* ============================================================
   Platform Card
   ============================================================ */
.pfm-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px;
  display: flex; flex-direction: column; gap: 10px;
  transition: all var(--transition); cursor: default;
}
.pfm-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

/* 卡片头部：图标 + 名称 + 类型徽章 */
.pfm-card-top {
  display: flex; align-items: flex-start; gap: 10px;
}
.pfm-card-icon {
  width: 40px; height: 40px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.pfm-card-icon.api {
  background: rgba(99,102,241,0.12); color: #6366f1;
}
.pfm-card-icon.llm {
  background: rgba(34,197,94,0.12); color: #22c55e;
}
.pfm-card-info { flex: 1; min-width: 0; }
.pfm-card-name {
  font-size: 15px; font-weight: 600; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pfm-card-id {
  font-size: 11px; color: var(--text-muted); font-family: monospace;
  margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 类型徽章 */
.pfm-badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10px; font-weight: 600; padding: 2px 8px;
  border-radius: 10px; white-space: nowrap; letter-spacing: 0.3px;
  text-transform: uppercase; flex-shrink: 0;
}
.pfm-badge.api {
  background: rgba(99,102,241,0.1); color: #6366f1; border: 1px solid rgba(99,102,241,0.2);
}
.pfm-badge.llm {
  background: rgba(34,197,94,0.1); color: #22c55e; border: 1px solid rgba(34,197,94,0.2);
}

/* 卡片描述 */
.pfm-card-desc {
  font-size: 12px; color: var(--text-secondary); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 18px;
}

/* 卡片元信息行 */
.pfm-card-meta {
  display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 11px;
  color: var(--text-muted);
}
.pfm-card-meta span {
  display: inline-flex; align-items: center; gap: 4px;
}
.pfm-meta-label { color: var(--text-secondary); font-weight: 500; }

/* 卡片底部操作 */
.pfm-card-actions {
  display: flex; gap: 6px; padding-top: 8px; flex-wrap: wrap;
  border-top: 1px solid var(--border-light, var(--border));
}
.pfm-card-actions .btn { font-size: 11px; padding: 4px 10px; flex-shrink: 0; white-space: nowrap; }

/* ============================================================
   Modal 弹窗
   ============================================================ */
.pfm-modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.45); display: flex;
  align-items: center; justify-content: center;
  animation: pfmFadeIn 0.15s ease;
}
@keyframes pfmFadeIn { from { opacity: 0; } to { opacity: 1; } }

.pfm-modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); width: 680px; max-width: 94vw;
  max-height: 88vh; display: flex; flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  animation: pfmSlideUp 0.2s ease;
}
@keyframes pfmSlideUp {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.pfm-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.pfm-modal-header h3 {
  margin: 0; font-size: 16px; color: var(--text-primary);
}
.pfm-modal-close {
  width: 28px; height: 28px; border: none; background: none;
  font-size: 18px; color: var(--text-muted); cursor: pointer;
  border-radius: var(--radius); display: flex; align-items: center;
  justify-content: center; transition: all var(--transition);
}
.pfm-modal-close:hover {
  background: var(--bg-hover); color: var(--text-primary);
}

.pfm-modal-body {
  flex: 1; overflow-y: auto; padding: 20px;
}

.pfm-modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 20px; border-top: 1px solid var(--border); flex-shrink: 0;
}

/* ---- 表单分区（复用原样式，微调） ---- */
.pfm-section {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-light, var(--border));
}
.pfm-section:last-of-type { border-bottom: none; margin-bottom: 0; }
.pfm-section h4 {
  margin: 0 0 10px 0; font-size: 13px;
  color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.pfm-row { display: flex; gap: 12px; align-items: flex-end; margin-bottom: 8px; }
.pfm-grow { flex: 1; }

/* ---- 工具列表 ---- */
#platformToolList { max-height: 240px; overflow-y: auto; }
.tool-edit-item {
  background: var(--bg-secondary); border: 1px solid var(--border-light);
  border-radius: var(--radius); margin-bottom: 6px; overflow: hidden;
}
.tool-edit-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; cursor: pointer; font-size: 12px;
  transition: background var(--transition);
}
.tool-edit-header:hover { background: var(--bg-hover); }
.tool-idx {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; background: var(--accent);
  color: #fff; border-radius: 50%; font-size: 11px; font-weight: 600; flex-shrink: 0;
}
.tool-edit-body {
  padding: 8px 12px 12px;
  border-top: 1px solid var(--border-light);
}
.tool-edit-body .form-group { margin-bottom: 8px; }
.tool-edit-body label { font-size: 11px; }
.tool-name-input { font-family: monospace; }

/* ============================================================
   Embed 模式适配
   ============================================================ */
body.embed-mode .pfm-modal-overlay { z-index: 2000; }
