/* 悬浮球 & Tag 选择器 */

/* 悬浮球 */
.tag-fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
    z-index: 8000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    -webkit-tap-highlight-color: transparent;
}

.tag-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(99, 102, 241, 0.55);
}

.tag-fab:active { transform: scale(0.95); }

.tag-fab svg {
    width: 26px;
    height: 26px;
    transition: transform 0.3s ease;
}

.tag-fab.open svg { transform: rotate(45deg); }

/* 面板 */
.tag-panel {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    max-height: 80vh;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0,0,0,0.18);
    z-index: 7999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.4) translateY(40px);
    transform-origin: bottom right;
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(.4,0,.2,1), opacity 0.25s ease;
}

.tag-panel.visible {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* 面板头部 */
.tag-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
    border-bottom: 1px solid #f0f0f0;
}

.tag-panel-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #1f2937;
}

.tag-panel-actions {
    display: flex;
    gap: 6px;
}

.tag-panel-actions button {
    background: none;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 12px;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.15s;
}

.tag-panel-actions button:hover {
    background: #f3f4f6;
    color: #374151;
}

/* 已选 tag 区域 */
.tag-selected-area {
    padding: 10px 16px;
    border-bottom: 1px solid #f0f0f0;
    min-height: 44px;
    max-height: 100px;
    overflow-y: auto;
}

.tag-selected-area:empty::before {
    content: '点击下方标签添加到提示词…';
    color: #c0c0c0;
    font-size: 13px;
}

.tag-selected-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    background: linear-gradient(135deg, #ede9fe, #e0e7ff);
    color: #4338ca;
    cursor: grab;
    user-select: none;
    transition: background 0.15s;
    white-space: nowrap;
}

.tag-pill:hover { background: linear-gradient(135deg, #ddd6fe, #c7d2fe); }

.tag-pill .pill-remove {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: rgba(99,102,241,0.2);
    color: #6366f1;
    border: none;
    cursor: pointer;
    font-size: 10px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
}

.tag-pill .pill-remove:hover { background: rgba(239,68,68,0.2); color: #ef4444; }

.tag-pill.dragging { opacity: 0.5; }

/* 搜索 */
.tag-search-wrap {
    padding: 8px 16px;
}

.tag-search-wrap input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    font-size: 13px;
    background: #f9fafb;
    transition: border-color 0.2s;
}

.tag-search-wrap input:focus {
    border-color: #6366f1;
    outline: none;
    background: #fff;
}

/* 分类 tabs - 自动换行 */
.tag-category-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 16px;
    flex-shrink: 0;
}

/* 展开/收起按钮 */
.tag-cat-toggle {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #6b7280;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    padding: 0;
}

.tag-cat-toggle:hover { background: #f3f4f6; color: #374151; }

.tag-category-tabs.collapsed {
    max-height: 38px;
    overflow: hidden;
}

.tag-cat-btn {
    flex-shrink: 0;
    padding: 5px 14px;
    border-radius: 20px;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #6b7280;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.tag-cat-btn:hover { background: #f3f4f6; color: #374151; }

.tag-cat-btn.active {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border-color: transparent;
}

/* Tag 列表 - 横向滚动行 */
.tag-list-area {
    flex: 1;
    overflow-y: auto;
    padding: 10px 16px 16px;
    scrollbar-width: thin;
}

.tag-group-title {
    font-size: 12px;
    font-weight: 600;
    color: #9ca3af;
    margin: 10px 0 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tag-group-title:first-child { margin-top: 0; }

/* 每个子分类的 tag 行 - 自动换行 */
.tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-bottom: 8px;
}

.tag-item {
    flex-shrink: 0;
    padding: 5px 12px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #fafafa;
    color: #374151;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    user-select: none;
    margin-bottom: 2px;
}

.tag-item:hover {
    border-color: #6366f1;
    background: #f5f3ff;
    color: #4f46e5;
}

.tag-item.selected {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border-color: transparent;
}

/* 插入目标选择 */
.tag-insert-target {
    padding: 8px 16px 12px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tag-insert-target label {
    font-size: 12px;
    color: #6b7280;
    flex-shrink: 0;
}

.tag-insert-target select {
    flex: 1;
    padding: 5px 8px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 12px;
    background: #fff;
    color: #374151;
}

.tag-insert-target .tag-insert-btn {
    flex-shrink: 0;
    padding: 5px 14px;
    border-radius: 8px;
    border: none;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.15s;
}

.tag-insert-target .tag-insert-btn:hover { filter: brightness(1.08); }

/* 自定义 tag 输入 */
.tag-custom-row {
    display: flex;
    gap: 6px;
    padding: 0 16px 10px;
}

.tag-custom-row input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 12px;
}

.tag-custom-row button {
    flex-shrink: 0;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid #6366f1;
    background: #f5f3ff;
    color: #6366f1;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
}

.tag-custom-row button:hover { background: #ede9fe; }

/* 响应式 */
@media (max-width: 480px) {
    .tag-fab {
        bottom: 20px;
        right: 16px;
        width: 50px;
        height: 50px;
    }
    .tag-panel {
        bottom: 80px;
        right: 10px;
        left: 10px;
        width: auto;
        max-width: none;
        max-height: 65vh;
    }
}
