/* === 标签管理页面 === */

/* 左右布局 */
.tag-manage-layout {
    display: flex;
    gap: 12px;
    height: calc(var(--fit-vh, 100vh) - var(--header-height) - 48px);
}

/* 左侧分类 */
.category-panel {
    width: 200px;
    min-width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.category-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.cat-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    margin-bottom: 2px;
}

.cat-item:hover {
    background: var(--bg-nav-hover);
}

.cat-item.active {
    background: var(--bg-nav-active);
    color: var(--accent);
}

.cat-item .cat-name {
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.cat-item .cat-count {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-input);
    padding: 1px 6px;
    border-radius: 8px;
    margin-left: 6px;
}

.cat-actions {
    display: none;
    gap: 2px;
    margin-left: 4px;
}

.cat-item:hover .cat-actions {
    display: flex;
}

.cat-actions button {
    width: 22px; height: 22px;
    display: flex; align-items: center; justify-content: center;
    background: transparent; border: none;
    border-radius: 4px; cursor: pointer;
    color: var(--text-muted); font-size: 12px;
}

.cat-actions button:hover { background: var(--bg-input); color: var(--text-primary); }
.cat-actions .del-btn:hover { color: var(--danger); }

/* 右侧标签 */
.tag-panel {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.panel-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.panel-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-add-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 32px;
    padding: 0 12px;
    background: var(--accent);
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.panel-add-btn:hover { filter: brightness(1.15); }
.panel-add-btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; }

.tag-search {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0 10px;
    height: 32px;
}

.tag-search:focus-within { border-color: var(--accent); }
.tag-search svg { width: 14px; height: 14px; stroke: var(--text-muted); fill: none; stroke-width: 1.5; }
.tag-search input {
    border: none; background: transparent; outline: none;
    color: var(--text-primary); font-size: 12px; width: 150px;
}
.tag-search input::placeholder { color: var(--text-muted); }

.tag-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 20px;
}

.tag-list::-webkit-scrollbar { width: 6px; }
.tag-list::-webkit-scrollbar-track { background: transparent; }
.tag-list::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }

.panel-loading, .panel-empty {
    display: flex; align-items: center; justify-content: center;
    height: 200px; color: var(--text-muted); font-size: 13px;
}

/* 标签卡片 */
.tag-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; border: 1px solid var(--border-color);
    border-radius: 8px; margin-bottom: 6px;
    transition: all 0.15s;
}

.tag-item:hover { border-color: var(--accent); }

.tag-color-dot {
    width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}

.tag-item-name { font-size: 13px; font-weight: 500; color: var(--text-primary); flex-shrink: 0; }

.tag-priority {
    font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 3px;
    flex-shrink: 0;
}

.tag-priority-high { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.tag-priority-mid { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }

.tag-item-desc {
    font-size: 11px; color: var(--text-muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    flex: 1;
    min-width: 50px;
}

.tag-desc-label {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(120, 113, 108, 0.12);
    color: #78716c;
    font-weight: 500;
    margin-right: 4px;
    flex-shrink: 0;
}

.tag-item-actions { display: flex; gap: 4px; flex-shrink: 0; }

.tag-item-actions button {
    padding: 3px 10px; background: transparent;
    border: 1px solid var(--border-color); border-radius: 4px;
    color: var(--text-muted); font-size: 11px; cursor: pointer; transition: all 0.15s;
}

.tag-item-actions button:hover { border-color: var(--accent); color: var(--accent); }
.tag-item-actions .del-btn:hover { border-color: var(--danger); color: var(--danger); }

/* 搜索高亮 */
.kw-highlight {
    background: #f59e0b;
    color: #1e293b;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 3px;
    box-shadow: 0 1px 3px rgba(245, 158, 11, 0.3);
}

/* 优先级颜色提示 */
.priority-hint { margin-top: 6px; display: flex; gap: 12px; font-size: 11px; color: var(--text-muted); }

/* ===== 匹配位置选择器 ===== */

.match-type-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.match-type-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 36px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.match-type-option:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.match-type-option.active {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.08);
    color: var(--accent);
    font-weight: 600;
}

.match-type-option svg {
    width: 16px; height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.5;
}

/* 分类列表中的引用标记 */
.cat-match-badge {
    font-size: 10px;
    margin-left: 3px;
    color: #6366f1;
}

/* ===== 可搜索标签选择器（跨分类引用） ===== */

.cts-wrapper {
    position: relative;
}

/* chips 和输入框共用的 flex-wrap 容器 */
.cts-input-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    min-height: 36px;
    max-height: 160px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-input);
    cursor: text;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.cts-input-container:hover,
.cts-input-container:focus-within {
    border-color: var(--accent);
}

.cts-input-container:focus-within {
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

/* chips */
.cts-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 4px;
    font-size: 12px;
    color: var(--accent);
    line-height: 20px;
    white-space: nowrap;
}

.cts-tag-remove {
    cursor: pointer;
    font-size: 14px;
    color: var(--accent);
    opacity: 0.5;
    transition: opacity 0.15s;
    line-height: 1;
    padding: 0 2px;
}

.cts-tag-remove:hover {
    opacity: 1;
}

/* 输入框 */
.cts-input {
    flex: 1;
    min-width: 100px;
    height: 22px;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 13px;
    padding: 0;
}

.cts-input::placeholder {
    color: var(--text-muted);
}

/* 下拉菜单 */
.cts-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    max-height: 180px;
    overflow-y: auto;
    margin-top: 2px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-card);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.cts-dropdown.show {
    display: block;
}

.cts-dropdown-item {
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s;
}

.cts-dropdown-item:hover,
.cts-dropdown-item.highlighted {
    background: var(--bg-nav-hover);
    color: var(--accent);
}

.cts-dropdown-empty {
    padding: 12px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
}

/* 标签列表中的匹配位置徽章 */
.match-type-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    flex-shrink: 0;
    font-weight: 500;
}

.match-type-badge.content {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.match-type-badge.category {
    background: rgba(99, 102, 241, 0.15);
    color: #6366f1;
}

/* 匹配提示词预览 */
.match-prompt-preview {
    font-size: 11px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}
