/*
  灵犀 AI 平台 — 共享组件样式
  从设计稿各页面 <style> 中提取的公共组件，避免 10 份重复定义。
  所有取值与设计稿保持一致。
*/

/* ===== 基础 ===== */
body { margin: 0; }
* { box-sizing: border-box; }

/* 设计稿里用到的少数工具类（替代 Tailwind CDN，保证内网/离线可用） */
.overflow-y-auto { overflow-y: auto; }
.overflow-x-auto { overflow-x: auto; }
.ml-auto { margin-left: auto; }
.font-mono { font-family: var(--ai-font-mono); }
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
[hidden] { display: none !important; }

/* ===== 卡片 ===== */
.card {
  background: var(--ai-card);
  border: 1px solid var(--ai-border);
  border-radius: var(--ai-radius-lg);
  padding: 16px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.card-title { font-size: 14px; font-weight: 600; }
.card-subtitle { font-size: 12px; color: var(--ai-muted-foreground); }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--ai-border);
}
.card-footer { display: flex; align-items: center; margin-top: 16px; }
.card-actions { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.card-locked { opacity: 0.65; }
.locked-body { margin-top: 16px; }
.lock-icon { width: 20px; height: 20px; color: var(--ai-muted-foreground); }
.locked-text {
  margin-top: 10px;
  font-size: 12px;
  color: var(--ai-muted-foreground);
  line-height: 1.6;
}

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--ai-radius-md);
  background: transparent;
  color: var(--ai-foreground);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease,
    filter 150ms ease;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--ai-primary); color: var(--ai-primary-foreground); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary {
  background: var(--ai-card);
  color: var(--ai-foreground);
  border-color: var(--ai-border);
}
.btn-secondary:hover { background: var(--ai-surface-hover); }
.btn-outline {
  background: transparent;
  color: var(--ai-foreground);
  border-color: var(--ai-border);
}
.btn-outline:hover { background: var(--ai-surface-hover); border-color: var(--ai-primary); }
.btn-ghost { background: transparent; color: var(--ai-muted-foreground); }
.btn-ghost:hover { background: var(--ai-surface-hover); color: var(--ai-foreground); }
.btn-danger { background: var(--state-error); color: #fff; }
.btn-warning { color: var(--state-warning); border-color: color-mix(in srgb, var(--state-warning) 45%, transparent); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-sm svg { width: 13px; height: 13px; }
.btn[disabled], .btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn[disabled]:hover, .btn:disabled:hover { filter: none; background: inherit; }
.spin { animation: lingxi-spin 900ms linear infinite; }
@keyframes lingxi-spin { to { transform: rotate(360deg); } }

/* ===== 图标按钮 ===== */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--ai-radius-md);
  background: transparent;
  color: var(--ai-muted-foreground);
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease;
}
.icon-btn:hover { background: var(--ai-surface-hover); color: var(--ai-foreground); }
.icon-btn svg { width: 17px; height: 17px; }

/* ===== 徽标 ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--ai-radius-sm);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-success {
  background: color-mix(in srgb, var(--state-success) 15%, transparent);
  color: var(--state-success);
}
.badge-warning {
  background: color-mix(in srgb, var(--state-warning) 15%, transparent);
  color: var(--state-warning);
}
.badge-danger {
  background: color-mix(in srgb, var(--state-error) 15%, transparent);
  color: var(--state-error);
}
.badge-info {
  background: color-mix(in srgb, var(--ai-primary) 15%, transparent);
  color: var(--ai-primary);
}
.badge-default { background: var(--ai-muted); color: var(--ai-muted-foreground); }
.badge-official {
  background: color-mix(in srgb, var(--ai-primary) 15%, transparent);
  color: var(--ai-primary);
}
.badge-certified {
  background: color-mix(in srgb, var(--state-info) 15%, transparent);
  color: var(--state-info);
}
.badge-local { background: var(--ai-muted); color: var(--ai-muted-foreground); }

.chip {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--ai-radius-sm);
  background: var(--ai-muted);
  color: var(--ai-muted-foreground);
  font-size: 11px;
  white-space: nowrap;
}

/* ===== 开关 ===== */
.switch { position: relative; display: inline-flex; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 19px;
  border-radius: var(--ai-radius-full);
  background: var(--ai-muted);
  transition: background-color 150ms ease;
}
.switch-track::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 2px;
  width: 15px;
  height: 15px;
  border-radius: var(--ai-radius-full);
  background: var(--ai-neutral-0);
  transition: transform 150ms ease;
}
.switch input:checked + .switch-track { background: var(--ai-primary); }
.switch input:checked + .switch-track::after { transform: translateX(15px); }
.switch input:disabled + .switch-track { opacity: 0.5; }
.switch input:disabled ~ .switch-track { cursor: not-allowed; }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--ai-ring); outline-offset: 2px; }
/* 纯展示型开关（技能市场横幅） */
.switch-track.is-on { background: var(--ai-primary); }
.switch-track.is-on .switch-thumb {
  position: absolute;
  left: 17px;
  top: 2px;
  width: 15px;
  height: 15px;
  border-radius: var(--ai-radius-full);
  background: var(--ai-neutral-0);
}

/* ===== 状态点 ===== */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--ai-radius-full);
  display: inline-block;
  flex-shrink: 0;
  background: var(--ai-muted-foreground);
}
.status-dot.success {
  background: var(--state-success);
  animation: status-pulse 1600ms ease-out infinite;
}
.status-dot.warning { background: var(--state-warning); }
.status-dot.error { background: var(--state-error); }
.status-dot.muted { background: var(--ai-muted-foreground); }
@keyframes status-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--state-success) 50%, transparent); }
  70% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--state-success) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.dot { width: 6px; height: 6px; border-radius: var(--ai-radius-full); background: currentColor; display: inline-block; }
.dot-pulse { animation: dot-blink 1.4s ease-in-out infinite; }
@keyframes dot-blink { 50% { opacity: 0.25; } }
.status-dot-ring {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: var(--ai-radius-full);
  background: var(--state-success);
}
.status-dot-ring::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--state-success);
  animation: ring-pulse 1.6s ease-out infinite;
}
@keyframes ring-pulse {
  0% { opacity: 0.55; transform: scale(1); }
  100% { opacity: 0; transform: scale(2.6); }
}

/* ===== 进度条 ===== */
.progress {
  height: 5px;
  border-radius: var(--ai-radius-full);
  background: var(--ai-muted);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  border-radius: var(--ai-radius-full);
  background: var(--ai-primary);
  transition: width 300ms ease;
}
.progress-track {
  height: 4px;
  border-radius: var(--ai-radius-full);
  background: var(--ai-muted);
  overflow: hidden;
  margin-top: 10px;
}
.progress-track .progress-bar {
  width: 40%;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--ai-primary) 25%, transparent),
    var(--ai-primary),
    color-mix(in srgb, var(--ai-primary) 25%, transparent)
  );
  animation: progress-slide 1.5s ease-in-out infinite;
}
@keyframes progress-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}

/* ===== 表单 ===== */
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.field > label { font-size: 12px; color: var(--ai-muted-foreground); }
.control,
.field input[type="text"],
.field input[type="url"],
.field input[type="email"],
.field input[type="number"],
.field input[type="password"],
.field textarea,
.field select {
  width: 100%;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--ai-input);
  border-radius: var(--ai-radius-md);
  background: var(--ai-card);
  color: var(--ai-foreground);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 150ms ease;
}
.field textarea, textarea.control { resize: vertical; min-height: 64px; line-height: 1.55; }
.control:focus,
.field input:focus,
.field textarea:focus,
.field select:focus { border-color: var(--ai-primary); }
.control:disabled,
.field input:disabled,
.field textarea:disabled { opacity: 0.55; cursor: not-allowed; }
.hint { font-size: 11px; color: var(--ai-muted-foreground); }
.input-action { display: flex; align-items: center; gap: 8px; }
.input-action input { flex: 1; min-width: 0; }
.input-64 { width: 64px; min-width: 64px; text-align: center; }

/* ===== 表格 ===== */
.data-table,
.model-table,
.table,
.members-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th,
.model-table th,
.table th,
.members-table th {
  font-size: 12px;
  font-weight: 500;
  color: var(--ai-muted-foreground);
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--ai-border);
  white-space: nowrap;
}
.data-table td,
.model-table td,
.table td,
.members-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--ai-border);
  vertical-align: middle;
}
.data-table tbody tr:last-child td,
.model-table tbody tr:last-child td,
.table tbody tr:last-child td,
.members-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr,
.model-table tbody tr,
.table tbody tr,
.members-table tbody tr { transition: background-color 120ms ease; }
.data-table tbody tr:hover,
.model-table tbody tr:hover,
.table tbody tr:hover,
.members-table tbody tr:hover { background: var(--ai-surface-hover); }
.table-card { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; }
.cell-muted, .muted-cell, .muted { color: var(--ai-muted-foreground); }
.cell-id { font-family: var(--ai-font-mono); font-size: 12px; color: var(--ai-muted-foreground); white-space: nowrap; }
.row-actions { display: inline-flex; align-items: center; gap: 4px; }
.status-text { font-size: 12px; }
.status-text.success { color: var(--state-success); }
.status-text.muted { color: var(--ai-muted-foreground); }
.status-text.error { color: var(--state-error); }

/* ===== 设置行 ===== */
.setting-rows { display: flex; flex-direction: column; }
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--ai-border);
}
.setting-row:last-child { border-bottom: none; }
.setting-info, .setting-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.setting-title { font-size: 13px; font-weight: 500; }
.setting-desc { font-size: 12px; color: var(--ai-muted-foreground); }
.setting-control { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.setting-inline-text { font-size: 12px; color: var(--ai-muted-foreground); }

/* ===== 分段控件 ===== */
.seg {
  display: inline-flex;
  padding: 2px;
  border-radius: var(--ai-radius-md);
  background: var(--ai-muted);
}
.seg button {
  height: 28px;
  padding: 0 12px;
  border: none;
  border-radius: var(--ai-radius-sm);
  background: transparent;
  color: var(--ai-muted-foreground);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease;
}
.seg button.active { background: var(--ai-card); color: var(--ai-foreground); }

/* ===== Toast ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 16px);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--ai-border);
  border-radius: var(--ai-radius-md);
  background: var(--ai-popover);
  color: var(--ai-popover-foreground);
  font-size: 13px;
  box-shadow: var(--ai-shadow-float);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast svg { width: 15px; height: 15px; }
.toast.error { border-color: color-mix(in srgb, var(--state-error) 45%, transparent); }
.toast.success { border-color: color-mix(in srgb, var(--state-success) 45%, transparent); }

/* ===== 模态弹层 ===== */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 9, 14, 0.62);
  z-index: 50;
}
.modal.open { display: flex; }
.modal-panel {
  width: 100%;
  max-width: 620px;
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--ai-border);
  border-radius: var(--ai-radius-lg);
  background: var(--ai-popover);
  box-shadow: var(--ai-shadow-overlay);
  overflow: hidden;
}
.modal-panel.wide { max-width: 760px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--ai-border);
}
.modal-header h3 { font-size: 15px; font-weight: 600; }
.modal-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; }
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--ai-border);
}

/* ===== 时间线 ===== */
.timeline { display: flex; flex-direction: column; gap: 2px; }
.timeline-row, .tl-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  font-size: 12px;
}
.tl-dot {
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: var(--ai-radius-full);
  background: var(--ai-muted-foreground);
  flex-shrink: 0;
}
.tl-dot-success { background: var(--state-success); }
.tl-dot-warning { background: var(--state-warning); }
.tl-dot-error { background: var(--state-error); }
.tl-time { font-family: var(--ai-font-mono); font-size: 11px; color: var(--ai-muted-foreground); flex-shrink: 0; width: 62px; }
.tl-text { color: var(--ai-foreground); line-height: 1.6; }

/* ===== 页头 ===== */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.page-head h1 { font-size: 20px; font-weight: 600; line-height: 1.3; }
.page-head .desc { margin-top: 4px; font-size: 13px; color: var(--ai-muted-foreground); }
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.page-header h1 { font-size: 20px; font-weight: 600; line-height: 1.3; }
.page-header p { margin-top: 4px; font-size: 13px; color: var(--ai-muted-foreground); }
.back-row { margin-bottom: 12px; }

/* ===== 空态 / 骨架 ===== */
.empty-hint {
  padding: 40px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--ai-muted-foreground);
}
.skeleton {
  border-radius: var(--ai-radius-sm);
  background: linear-gradient(90deg, var(--ai-muted), var(--ai-surface-hover), var(--ai-muted));
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== 窄屏 ===== */
@media (max-width: 1100px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr) !important; }
}