/* public/modules/laws/css/law-tags-inline.css */
/* 段落内联标签系统样式 */

/* 
 * ============================================
 * 文件职责说明
 * ============================================
 * 
 * 本文件包含法律法规详情页段落内联标签系统的所有样式：
 * 
 * 1. 内联标签容器 (.block-tags-inline)
 *    - 标签显示/隐藏逻辑
 *    - 位置和布局
 * 
 * 2. 单个标签项 (.inline-tag-item)
 *    - 标签色块 (.tag-color-bar)
 *    - 标签文本 (.inline-tag-name)
 *    - 聚焦状态 (.focused, .family-focused)
 * 
 * 3. 段落状态样式（⚠️ 统一管理处）
 *    - 聚焦段落 (.focused, .directly-focused)
 *    - 虚化段落 (.ghosted)
 *    - ⚠️ 注意：law-tags-sidebar.css 中的重复定义已移除
 * 
 * 4. 聚焦模式UI
 *    - 折叠占位符 (.collapsed-placeholder)
 *    - 顶部面包屑导航 (.law-tags-breadcrumb-top)
 * 
 * ⚠️ 避免重复定义：
 * - law-tags-sidebar.css：已移除段落状态样式
 * - law_tags_display.css：已废弃旧的 .tag-focused 样式
 * - law-tags-focus-panel.css：空文件，仅保留说明
 * 
 * ============================================
 */

/* ========================================
   段落标签容器（贴在右侧）
   ======================================== */

/* 包装容器 */
.block-with-tags-wrapper {
  position: relative;
  display: block;
  margin-bottom: 0; /* 保持段落原有间距 */
}

/* ✅ 使用伪元素创建"桥梁"，连接段落和标签之间的空白区域 */
.block-with-tags-wrapper::after {
  content: '';
  position: absolute;
  right: -200px; /* 从段落右边缘到标签左边缘 */
  top: 0;
  width: 200px; /* 覆盖段落到标签之间的整个区域 */
  height: 100%;
  pointer-events: none; /* 默认不阻止点击 */
  z-index: 9; /* 低于标签本身 */
}

/* ✅ 当鼠标悬浮在wrapper上时，激活桥梁区域 */
.block-with-tags-wrapper:hover::after {
  pointer-events: auto;
}

/* ========================================
   默认状态：标签隐藏
   ======================================== */

.block-tags-inline {
  position: absolute !important;
  right: -200px; /* 在包装容器右侧外部 */
  top: 0;
  width: 140px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 10;
  align-items: flex-start;
  
  /* ✅ 默认隐藏 */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease-in; /* 隐藏时快速 */
}

/* ========================================
   显示触发条件（优先级从高到低）
   ======================================== */

/* 1. 聚焦模式 - 最高优先级（始终显示） */
.block-with-tags-wrapper.focused .block-tags-inline,
.block-with-tags-wrapper.ghosted .block-tags-inline {
  opacity: 1;
  pointer-events: all;
  border-left: 0px !important;
  padding-left: 0px !important;
  transition: opacity 0.2s ease-out;
  background: transparent !important;
  box-shadow: none !important;
}

/* 2. 展开态 - 次高优先级（展开后保持显示） */
.block-tags-inline.all-tags-expanded {
  opacity: 1 !important;
  pointer-events: all !important;
  transition: opacity 0.2s ease-out;
}

/* 3. 点击态 - 通过JS添加class（点击后保持显示） */
.block-with-tags-wrapper.clicked .block-tags-inline {
  opacity: 1;
  pointer-events: all;
  transition: opacity 0.2s ease-out;
}

/* 4. 悬浮态 - 鼠标悬浮段落或标签时显示 */
.block-with-tags-wrapper:hover .block-tags-inline,
.block-tags-inline:hover {
  opacity: 1;
  pointer-events: all;
  transition: opacity 0.2s ease-out;
}

/* ✅ 关键：悬浮过的标签添加keeping类，延迟移除pointer-events */
.block-tags-inline.keeping {
  pointer-events: all; /* 保持可交互 */
  transition: opacity 0.3s ease-in 0.6s; /* 延迟0.6s后隐藏 */
}

/* 5. 悬浮标签且未展开时，自动展开标签 */
.block-tags-inline:hover:not(.all-tags-expanded) .inline-tag-item {
  width: 140px;
  transition: all 0.2s ease-out;
}

.block-tags-inline:hover:not(.all-tags-expanded) .inline-tag-item .tag-color-bar {
  width: 6px;
  transition: all 0.2s ease-out;
}

.block-tags-inline:hover:not(.all-tags-expanded) .inline-tag-item .inline-tag-name {
  opacity: 1;
  max-width: 150px;
  font-size: 12px;
  padding: 0 8px;
}

/* 可见标签区域 */
.tags-visible {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 0;
}

/* 展开的标签区域（位置在按钮上方）*/
.tags-expanded {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 4px; /* 与按钮之间的间距 */
}

/* ========================================
   单个标签项（收起状态）
   ======================================== */

.inline-tag-item {
  display: flex;
  align-items: center;
  flex-direction: row-reverse;
  justify-content: flex-end;
  height: 28px;
  /* background: white; */
  /* border-radius: 4px; */
  cursor: pointer;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  width: 100px; /* 收起时只显示色块宽度 */
}

/* 左侧色块（始终可见）*/
.tag-color-bar {
  width: 4px;
  height: 100%;
  background: var(--tag-border);
  flex-shrink: 0;
  transition: width 0.3s ease;
}

/* 标签文本（默认隐藏，悬浮展开）*/
.inline-tag-name {
  flex: 1;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--tag-text);
  opacity: 0;
  max-width: 0;
  transition: all 0.3s ease;
  font-weight: 500;
  text-align: left;
}

/* 悬浮整个标签项时展开 */
.inline-tag-item:hover {
  width: 140px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.inline-tag-item:hover .tag-color-bar {
  width: 6px;
}

.inline-tag-item:hover .inline-tag-name {
  opacity: 1;
  max-width: 150px;
  font-size: 12px;
  padding: 0 8px;
}

/* ✅ 展开状态下，所有标签都保持展开 */
.block-tags-inline.all-tags-expanded .inline-tag-item {
  width: auto;
  min-width: 80px;
  max-width: 140px;
}

.block-tags-inline.all-tags-expanded .inline-tag-item.tags-more-btn {
  background: linear-gradient(135deg, #e5e7eb 0%, #d1d5db 100%);
}

.block-tags-inline.all-tags-expanded .inline-tag-item .tag-color-bar {
  width: 6px;
}

.block-tags-inline.all-tags-expanded .inline-tag-item .inline-tag-name {
  opacity: 1;
  max-width: 150px;
  font-size: 12px;
  padding: 0 8px;
}

/* ========================================
   标签聚焦状态
   ======================================== */

/* 聚焦状态（用户直接点击的标签）- 强调显示 */
.inline-tag-item.focused {
  background: var(--tag-bg);
  border-color: var(--tag-border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  font-weight: 600;
  width: 140px;
}

.inline-tag-item.focused .tag-color-bar {
  width: 6px;
}

.inline-tag-item.focused .inline-tag-name {
  opacity: 1;
  max-width: 150px;
  font-weight: 600;
  padding: 0 8px;
}

/* 家族聚焦状态（祖先或后代标签）- 次级高亮 */
.inline-tag-item.family-focused {
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--tag-bg);
  opacity: 0.8;
  width: 140px;
}

.inline-tag-item.family-focused .tag-color-bar {
  width: 4px;
  opacity: 0.7;
}

.inline-tag-item.family-focused .inline-tag-name {
  opacity: 0.8;
  max-width: 150px;
  font-size: 11px;
  padding: 0 6px;
}

/* ✅ 聚焦模式下非聚焦标签的灰色显示（收起状态） */
.block-with-tags-wrapper.focused .inline-tag-item:not(.focused):not(.family-focused):not(.tags-more-btn) .tag-color-bar,
.block-with-tags-wrapper.ghosted .inline-tag-item:not(.focused):not(.family-focused):not(.tags-more-btn) .tag-color-bar {
  background: #e5e7eb !important;
}

/* ✅ 悬浮和选中时恢复原本颜色 */
.block-with-tags-wrapper.focused .inline-tag-item:not(.focused):not(.family-focused):not(.tags-more-btn):hover .tag-color-bar,
.block-with-tags-wrapper.ghosted .inline-tag-item:not(.focused):not(.family-focused):not(.tags-more-btn):hover .tag-color-bar {
  background: var(--tag-border) !important;
}

/* ========================================
   展开/收起按钮（inline-tag-item 样式）
   ======================================== */

.tags-more-btn {
  /* 继承 inline-tag-item 的所有样式 */
  cursor: pointer;
}

.tags-more-btn .tag-color-bar {
  background: #e5e7eb !important;
}

.tags-more-btn .inline-tag-name {
  color: #6b7280;
  font-weight: 600;
  font-size: 11px;
}

.tags-more-btn:hover {
  background: linear-gradient(135deg, #e5e7eb 0%, #d1d5db 100%);
  border-color: #9ca3af;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.tags-more-btn:hover .inline-tag-name {
  color: #374151;
  font-size: 12px;
}


/* ========================================
   段落状态样式
   ======================================== */

/* ⚠️ 重要：使用精确选择器，只选择段落元素（p标签），避免误选wrapper和标签容器 */

/* 聚焦状态（家族链标签的段落 - 保持原样） */
.regulation-content .block-with-tags-wrapper.focused > p[data-block-id] {
  background: rgba(249, 250, 251, 0.8);
  /* box-shadow: inset 0 0 0 0.2px rgba(209, 213, 219, 0.5); */
  transition: all 0.3s ease;
}

/* ✅ 直接聚焦状态（用户选中标签的段落 - 米黄色背景） */
/* 使用 > p[data-block-id] 确保只选择直接子元素的p标签，不影响wrapper和标签容器 */
.regulation-content .block-with-tags-wrapper.directly-focused > p[data-block-id],
.regulation-content p[data-block-id].directly-focused:not(.block-with-tags-wrapper) {
  background: #FFFBE6 !important;
  color: #000000 !important;
  /* box-shadow: inset 0 0 0 1px rgba(250, 204, 21, 0.3); */
  transition: all 0.3s ease;
}

/* ✅ 确保段落内文字颜色为纯黑 */
.regulation-content .block-with-tags-wrapper.directly-focused > p[data-block-id] *,
.regulation-content p[data-block-id].directly-focused:not(.block-with-tags-wrapper) * {
  color: inherit;
}

/* 虚化状态（半透明）*/
/* 同样使用精确选择器，避免影响标签容器 */
.regulation-content p[data-block-id].ghosted:not(.block-with-tags-wrapper),
.regulation-content .block-with-tags-wrapper.ghosted > p[data-block-id] {
  opacity: 0.3;
  filter: grayscale(70%);
  transition: all 0.3s ease;
  cursor: pointer;
  user-select: none;
}

.regulation-content p[data-block-id].ghosted:not(.block-with-tags-wrapper):hover,
.regulation-content .block-with-tags-wrapper.ghosted > p[data-block-id]:hover {
  opacity: 0.5;
}

/* ========================================
   折叠占位符（双箭头设计）
   ======================================== */

.collapsed-placeholder {
  padding: 8px 24px;
  margin: 12px 0;
  height: 20px;
  background: transparent;
  border: none;
  border-radius: 4px;
  text-align: center;
  cursor: pointer;
  transition: background-color 0.2s ease;
  user-select: none;
  position: relative;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.collapsed-placeholder:hover {
  background: rgba(243, 244, 246, 0.5);
}

.collapsed-placeholder-dots {
  font-size: 20px;
  color: #d1d5db;
  font-weight: bold;
  letter-spacing: 3px;
  line-height: 1;
}

.collapsed-placeholder:hover .collapsed-placeholder-dots {
  display: none;
}

.collapsed-placeholder-text {
  display: none;
  font-size: 14px;
  color: #6b7280;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}

.collapsed-placeholder:hover .collapsed-placeholder-text {
  display: block;
}

/* 闪烁高亮动画（用于长段落收起时的视觉提示） */
.collapsed-placeholder.flash-highlight {
  animation: flashHighlight 0.8s ease-out;
}

@keyframes flashHighlight {
  0% {
    background: rgba(59, 130, 246, 0.3);
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
  }
  50% {
    background: rgba(59, 130, 246, 0.15);
    box-shadow: 0 0 0 8px rgba(59, 130, 246, 0);
  }
  100% {
    background: transparent;
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
  }
}

/* ========================================
   顶部面包屑导航（固定在页面顶部）
   ======================================== */

.law-tags-breadcrumb-top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 999;
  background: white;
  border-bottom: 2px solid #e5e7eb;
  padding: 12px 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: none;
  align-items: center;
  justify-content: space-between;
  animation: slideDown 0.3s ease;
}

.law-tags-breadcrumb-top.active {
  display: flex;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.breadcrumb-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  overflow: hidden;
}

.breadcrumb-label {
  font-size: 14px;
  color: #6b7280;
  font-weight: 600;
  white-space: nowrap;
}

.breadcrumb-tags {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.2) transparent;
}

.breadcrumb-tags::-webkit-scrollbar {
  height: 4px;
}

.breadcrumb-tags::-webkit-scrollbar-track {
  background: transparent;
}

.breadcrumb-tags::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.2);
  border-radius: 2px;
}

.breadcrumb-tags::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,0.3);
}

/* 面包屑中的标签样式 */
.breadcrumb-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: #f3f4f6;
  border-radius: 6px;
  font-size: 13px;
  white-space: nowrap;
  transition: all 0.2s ease;
  border-left: 3px solid var(--tag-border, #3b82f6);
  flex-shrink: 0;
}

.breadcrumb-tag:hover {
  background: #e5e7eb;
}

.breadcrumb-tag-name {
  color: #374151;
  font-weight: 500;
}

.breadcrumb-tag-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: #9ca3af;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.15s ease;
  margin-left: 2px;
}

.breadcrumb-tag-remove:hover {
  background: #d1d5db;
  color: #374151;
  transform: scale(1.1);
}

.breadcrumb-exit {
  padding: 8px 20px;
  background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  color: #374151;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

.breadcrumb-exit:hover {
  background: linear-gradient(135deg, #e5e7eb 0%, #d1d5db 100%);
  border-color: #9ca3af;
  color: #1f2937;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.breadcrumb-exit::before {
  content: '×';
  font-size: 20px;
  font-weight: bold;
}

/* 聚焦所有关键词按钮 */
.breadcrumb-focus-all {
  padding: 8px 16px;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  border: 1px solid #2563eb;
  border-radius: 6px;
  font-size: 14px;
  color: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  margin-right: 8px;
}

.breadcrumb-focus-all:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  border-color: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
}

/* ========================================
   响应式设计
   ======================================== */

@media (max-width: 1400px) {
  .block-tags-inline {
    right: -160px;
  }
  
  [data-block-id]:hover .block-tags-inline {
    right: -140px;
  }
}

@media (max-width: 1200px) {
  .block-tags-inline {
    display: none; /* 小屏幕隐藏内联标签 */
  }
}

/* ========================================
   确保法规内容区域有足够的右侧空间
   ======================================== */

.content-container {
  position: relative;
  overflow: visible !important; /* 关键：允许标签溢出容器 */
}

.regulation-content {
  position: relative;
  overflow: visible !important; /* 关键：允许标签溢出 */
}

/* 面包屑激活时的页面调整由 JavaScript 动态控制 body padding-top */

/* 确保段落和wrapper本身也允许溢出，但不重复定义position */
.regulation-content [data-block-id] {
  overflow: visible !important;
}
