/* 表格面板 */
.table-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: var(--color-bg-primary);
}

.tab-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border-light);
  background-color: var(--color-bg-secondary);
}

.title-text {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text-primary);
}

.table-info {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

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

.refresh-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 4px;
  background-color: transparent;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  padding: 0;
}

.refresh-btn:hover:not(:disabled) {
  background-color: rgba(102, 126, 234, 0.15);
  transform: rotate(180deg);
}

.refresh-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* 空状态 */
.empty-table {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--color-text-muted);
  padding: 16px;
}

.empty-table p:first-child {
  font-size: 2rem;
  margin: 0;
}

.empty-table p:nth-child(2) {
  font-size: 0.9rem;
  margin: 0;
  font-weight: 500;
}

/* 表格容器 - 支持滚动 */
.table-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 标签容器 - 横向排列，自动换行 */
.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-content: flex-start;
}

.no-tags-hint {
  width: 100%;
  text-align: center;
  padding: 12px;
  color: var(--color-text-muted);
  font-style: italic;
  font-size: 0.85rem;
}

/* 单个标签项 */
.tag-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background-color: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  font-size: 0.82rem;
  color: var(--color-text-primary);
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  max-width: 100%;
}

.tag-item:hover {
  border-color: var(--color-accent);
  box-shadow: 0 2px 4px rgba(102, 126, 234, 0.15);
  transform: translateY(-1px);
}

.tag-item.editing {
  border-color: var(--color-accent);
  background-color: rgba(102, 126, 234, 0.1);
  padding: 3px 6px;
}

/* 标签文本 */
.tag-text {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.tag-text:hover {
  color: var(--color-accent);
}

/* 标签编辑容器 */
.tag-edit-container {
  display: flex;
  align-items: center;
  width: 100%;
}

.tag-edit-input {
  flex: 1;
  padding: 2px 6px;
  border: 1px solid var(--color-accent);
  border-radius: 12px;
  font-size: 0.82rem;
  outline: none;
  background-color: var(--color-bg-primary);
  color: var(--color-text-primary);
  min-width: 100px;
}

.tag-edit-input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

/* 标签操作按钮组 */
.tag-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.tag-item:hover .tag-actions {
  opacity: 1;
}

.tag-action-btn {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.7rem;
  transition: all 0.15s ease;
  background-color: transparent;
  color: var(--color-text-muted);
}

.tag-action-btn:hover:not(:disabled) {
  background-color: rgba(102, 126, 234, 0.15);
  color: var(--color-accent);
  transform: scale(1.1);
}

.tag-action-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.tag-action-btn.delete:hover:not(:disabled) {
  background-color: rgba(244, 67, 54, 0.15);
  color: #f44336;
}

/* 添加标签输入框 */
.add-tag-container {
  display: flex;
  gap: 6px;
  padding: 8px;
  background-color: var(--color-bg-secondary);
  border-radius: 6px;
  border: 1px solid var(--color-border-light);
}

.add-tag-input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 0.82rem;
  outline: none;
  background-color: var(--color-bg-primary);
  color: var(--color-text-primary);
  transition: border-color 0.2s ease;
}

.add-tag-input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.add-tag-input::placeholder {
  color: var(--color-text-muted);
  opacity: 0.6;
}

.add-tag-btn {
  padding: 6px 12px;
  background-color: var(--color-accent);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.add-tag-btn:hover:not(:disabled) {
  background-color: var(--color-accent-dark);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

.add-tag-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* ==================== 动态表格样式（键值对）==================== */
.dynamic-table {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.table-row {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  background-color: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  transition: all 0.15s ease;
}

.table-row:hover {
  border-color: var(--color-accent);
  box-shadow: 0 2px 4px rgba(102, 126, 234, 0.1);
}

.table-key {
  min-width: 100px;
  max-width: 150px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-value {
  flex: 1;
  font-size: 0.9rem;
  color: var(--color-text-primary);
  padding-left: 12px;
  border-left: 2px solid var(--color-border-light);
  word-break: break-word;
}

/* ✅ 可编辑输入框样式 */
.table-input {
  width: 100%;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--color-text-primary);
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

.table-input:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.15);
}

.table-input:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.table-input::placeholder {
  color: var(--color-text-muted);
  opacity: 0.5;
  font-style: italic;
}

/* SillyTavern 标签区域 */
.tags-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border-light);
}

.tags-header {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tag-badge {
  padding: 3px 8px;
  background-color: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  font-size: 0.75rem;
  color: var(--color-text-secondary);
}
