/* ==========================================================================
   文件路径: /public/css/laws/search_bar.css
   文件描述: 法律检索模块 (laws) 的共享搜索栏组件样式
             包含 Hero 区域、顶部搜索栏、快捷关键词组件
             用于 index 页面和 search 页面
   ========================================================================== */


/* ==========================================================================
   1. 全局与基础样式 (Global & Base Styles)
   ========================================================================== */

/* 1.1 页面基础设置 */
body.laws-page {
  background: #f7f8fa;
  /* 与 penalties 页面背景色保持一致 */
}

/* 1.2 基础字体与行高 (全局 12px, 此页面放大至 13px) */
.laws-v2,
.laws-main-layout,
.lw-main {
  font-size: 13px;
  line-height: 1.6;
}

/* 1.3 标题字体大小 */
.laws-v2 .lw-law-card .lw-law-title {
  font-size: 17px;
}

.lw-main h2 {
  font-size: 22px;
  font-weight: 600;
  color: #2c2d41;
  margin: 0 0 14px;
}

/* 1.4 通用按钮过渡效果 */
.qf-btn,
.lw-btn,
.laws-table .jump-button,
#lwPagination button {
  transition: background-color 0.18s, color 0.18s, box-shadow 0.18s;
}

.qf-btn:hover:not(.active) {
  background: #798095;
  color: #fff;
}

.qf-btn.active:hover {
  background: #2c2d41;
}

/* 1.5 关键词高亮 (统一原生 mark 标签和自定义 class) */
.kw-hit,
mark {
  background: var(--color-accent);
  color: #3a2f00;
  padding: 0 2px;
  border-radius: 2px;
}

/* 1.6 通用卡片化容器背景裁切 */
.laws-v2 .lw-filter-sidebar,
.laws-v2 .lw-main,
.laws-main-layout .laws-cat-pane,
.laws-content-pane,
.laws-timeline-view,
.search-results {
  background-clip: padding-box;
}


/* ==========================================================================
   2. Hero Section (英雄区域)
   ========================================================================== */

.lw-hero-section {
  color: #f8fafc; /* 亮色文字 */
  padding: 30px 0;
  margin-bottom: 32px; /* 与下方内容的间距 */
  text-align: center;
  background-size: cover;
}

.lw-hero-title {
  font-size: 36px;
  font-weight: 700;
  margin: 0 0 24px;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* 法律检索页面头部与英雄区合并容器 */
.laws-header-hero-container {
  background-image: url('/images/background.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.laws-header-hero-container .header-area {
  background-color: transparent;
}

/* laws页面header初始状态：透明背景 */
.laws-page .header-area {
  background-color: transparent;
  background-image: none;
}

/* laws页面header滚动后：显示背景图片 */
.laws-page .header-area.scrolled {
  background-image: url('/images/background.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-color: rgba(0, 0, 0, 0.3);
}

/* 仅在 laws-page 页面下，调整 header 颜色以适应深色背景 */
.laws-page .header-area .main-nav .logo,
.laws-page .header-area .main-nav .nav>li>a {
  color: #ffffff;
  /* 默认文字颜色 - 浅灰白色 */
}

/* 调整下拉菜单的箭头颜色 */
.laws-page .header-area .main-nav .nav>li.dropdown>a.dropdown-toggle {
  color: #e2e8f0;
}
.laws-page .header-area .main-nav .nav>li.dropdown:hover>a.dropdown-toggle,
.laws-page .header-area .main-nav .nav>li.dropdown.active>a.dropdown-toggle {
  color: #ffffff;
}


/* ==========================================================================
   3. 顶部主搜索栏 (Top Search Bar)
   ========================================================================== */

.lw-top-search {
  display: flex;
  align-items: center;
  background: var(--color-surface);
  border: 1px solid transparent;
  /* 默认无边框，通过 focus-within 控制 */
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(102, 112, 133, 0.07);
  overflow: visible;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  margin: 0 auto;
  margin-bottom:30px;
  width: 100%; /* 宽度由父容器决定 */
  max-width: 800px; /* 限制搜索栏本身的最大宽度，防止在超宽屏上过长 */
  position: relative;
}

/* 搜索输入区域包装器（用于容纳标签块和输入框） */
.lw-search-input-wrapper {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 4px 12px;
  min-height: 48px;
  position: relative;
}

/* 多关键词标签块容器 */
.lw-keyword-tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

/* 单个关键词标签块 - 使用主题颜色 */
.lw-keyword-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--color-bg);
  border: 1px solid #d4d8dd;
  border-radius: 16px;
  font-size: 14px;
  color: #5a6272;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  max-width: 200px;
}

.lw-keyword-tag:hover {
  background: var(--color-border);
  border-color: #798095;
  color: #2c2d41;
}

.lw-keyword-tag.editing {
  background: #fff;
  border-color: #798095;
  box-shadow: 0 0 0 2px rgba(121, 128, 149, 0.1);
}

.lw-keyword-tag-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lw-keyword-tag-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(90, 98, 114, 0.12);
  color: #5a6272;
  font-size: 14px;
  font-weight: bold;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.lw-keyword-tag-remove:hover {
  background: rgba(121, 128, 149, 0.25);
  color: #798095;
  transform: scale(1.1);
}

/* 标签块编辑输入框 */
.lw-keyword-tag-input {
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
  color: #2c2d41;
  padding: 0;
  margin: 0;
  width: auto;
  min-width: 60px;
  max-width: 180px;
}

/* 隐藏原始输入框（在标签模式下） */
.lw-key-input.has-tags {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

/* 显示原始输入框（在聚焦或无标签时） */
.lw-key-input:not(.has-tags) {
  flex: 1;
  width: 100%;
  min-width: 100px;
}

/* 输入框基础样式（确保字体大小正确） */
.lw-key-input {
  border: none;
  outline: none;
  background: transparent;
  font-size: 16px;
  color: var(--color-text);
  padding: 0;
  cursor: text; /* 鼠标悬停时显示文本光标 */
}

/* 搜索输入区域包装器：多标签追加模式下显示文本光标 */
.lw-search-input-wrapper {
  cursor: text;
}

/* 标签块容器不阻止光标样式传递 */
.lw-keyword-tags-container {
  cursor: text;
}

/* 输入框清除按钮 */
.lw-input-clear-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: none;
  background: #d1d5db;
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  margin-left: 8px;
  flex-shrink: 0;
  transition: all 0.15s ease;
  font-weight: bold;
}

.lw-input-clear-btn:hover {
  background: #9ca3af;
  transform: scale(1.1);
}

.lw-input-clear-btn:active {
  transform: scale(0.95);
}

/* 核心: 内部任一元素聚焦时，整个容器高亮 - 优化聚焦效果 */
.lw-top-search:focus-within {
  border-color: #b8bcc6;
  box-shadow: 0 4px 16px rgba(102, 112, 133, 0.12), 0 0 0 1px rgba(121, 128, 149, 0.2);
}

/* 重置内部元素默认样式，实现一体化设计 */
.lw-top-search>select,
.lw-top-search>input[type="text"],
.lw-top-search>.lw-btn {
  border: none;
  outline: none;
  background-color: transparent;
  font-size: 16px;
  height: auto;
  min-height: 48px;
  color: var(--color-text);
  border-radius: 0;
  /* 移除内部圆角 */
}

/* 让下拉框和按钮拉伸填满容器高度，保持与标签块对齐 */
.lw-top-search>select,
.lw-top-search>.lw-btn {
  align-self: stretch;
}

.lw-top-search select {
  padding: 12px 40px 12px 30px;
}

/* 输入框 */
.lw-top-search input[type="text"] {
  flex: 1;
  min-width: 100px;
  border: none;
  outline: none;
  background: transparent;
  padding: 0;
}

/* 当有标签块时，隐藏输入框 */
.lw-top-search input[type="text"].has-tags {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.lw-top-search input[type="text"]::placeholder {
  color: #9098a5;
  opacity: 1;
}

/* 下拉选择框 (带分割线和图标) */
.lw-top-search select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 40px;
  border-right: 1px solid var(--color-border);
  cursor: pointer;
  font-weight: 500;
  transition: background-color 0.2s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  /* 保持左侧圆角，即使在hover状态下 */
  border-radius: 12px 0 0 12px !important;
}

.lw-top-search select:hover {
  background-color: #f7f8fa;
}

/* 主操作按钮 (如搜索) */
.lw-top-search .lw-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-shrink: 0;
  background-color: var(--color-primary);
  color: #ffffff;
  font-weight: 600;
  cursor: pointer;
  padding: 12px 10px;
}

.lw-top-search .lw-btn.ghost {
  border-radius: 0 10px 10px 0;
  /* 仅右侧圆角 */
  border-left: none;
  /* 去掉左侧边框 */
}
.lw-top-search .lw-btn:hover {
  background-color: var(--color-primary-hover);
  color:#ffffff;
}

.lw-top-search .lw-btn.primary::before {
  content: '';
  display: inline-block;
  width: 18px;
  height: 18px;
  background-color: currentColor;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E");
  -webkit-mask-size: contain;
  mask-size: contain;
}

/* 加载状态时隐藏放大镜图标 */
.lw-top-search .lw-btn.primary.loading::before {
  display: none;
}

/* 加载中状态（搜索按钮样式）：宽度调整为搜索+重置按钮的总宽度，右侧圆角与重置按钮一致 */
.lw-top-search .lw-btn.primary.loading {
  /* 通过增加padding来扩展宽度，使其等于搜索+重置按钮的总宽度 */
  /* 搜索按钮文字2字符+图标 ≈ 60-70px，重置按钮2字符 ≈ 60-70px */
  /* 加载中3个字符，需要额外padding来匹配总宽度 */
  padding: 12px 20px;
  border-radius: 0 10px 10px 0;
  /* 右上和右下圆角10px，与ghost按钮(.lw-btn.ghost)一致 */
}

/* 加载中状态（重置按钮样式）：宽度调整为搜索+重置按钮的总宽度，右侧圆角保持一致 */
.lw-top-search .lw-btn.ghost.loading {
  /* 加载中3个字符，通过padding匹配两个按钮的总宽度 */
  padding: 12px 21px;
  border-radius: 0 10px 10px 0;
  /* 右侧圆角10px，与普通ghost按钮一致 */
  border: 1px solid var(--color-primary);
}

 
/* 按钮内的小型加载动画 */
.btn-loading-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 6px;
  border: 2px solid #fff;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}

/* ghost按钮的转圈动画（颜色适应ghost按钮） */
.btn-loading-spinner-ghost {
  border-color: var(--color-primary);
  border-top-color: transparent;
}


/* ==========================================================================
   4. 快捷关键词 (Quick Keywords)
   ========================================================================== */

.lw-quick-keywords {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px auto;
  padding: 0 16px;
  width: 90%;
  max-width: 1200px;
  flex-wrap: wrap;
}

.lw-quick-keywords .qk-label {
  font-size: 13px;
  font-weight: 500;
  color: #666;
  white-space: nowrap;
}

.lw-quick-keywords .qk-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.lw-quick-keywords .qk-tag {
  appearance: none;
  border: none;
  background: transparent;
  color: #666;
  font-size: 13px;
  font-weight: 400;
  padding: 0;
  cursor: pointer;
  transition: color 0.15s ease;
  white-space: nowrap;
  position: relative;
}

.lw-quick-keywords .qk-tag:not(:last-child)::after {
  content: '|';
  margin: 0 8px;
  color: #d0d0d0;
}

.lw-quick-keywords .qk-tag:hover {
  color: #798095;
}

.lw-quick-keywords .qk-tag.active {
  color: #2c2d41;
  font-weight: 500;
}


/* ==========================================================================
   5. 响应式设计 (Responsive Design)
   ========================================================================== */
/* ==========================================================================
   5. 响应式设计 (Responsive Design) - 移动端适配
   ========================================================================== */

   @media (max-width: 680px) {
    .lw-hero-title {
      font-size:32px;
    }
    /* --- 5.1 布局调整：让搜索和重置按钮并排 --- */
    
    .lw-top-search {
      /* 使用 flex-wrap 允许换行，从而实现 Input 独占一行，按钮并排 */
      display: flex;
      flex-direction: row; 
      flex-wrap: wrap;
      align-items: stretch;
      gap: 10px; /* 元素之间的间距 */
      
      padding: 0 12px;
      margin-bottom: 15px;
      border: none;
      box-shadow: none;
      background-color: transparent;
      overflow: visible;
    }
  
    /* 英雄区域间距调整 */
    .lw-hero-section {
      margin-bottom: 15px;
      padding: 30px 0 15px 0;
    }
  
    /* --- 5.2 输入框与下拉框：强制独占一行 (100%宽度) --- */
  
    /* 下拉选择框 */
    .lw-top-search > select {
      width: 100%;
      flex: 0 0 100%; /* 强制换行 */
      height: 44px;
      border-radius: 10px !important;
      background-color: #fff; /* 确保背景不透明 */
      border: 1px solid #d4d8dd;
      border-right: 1px solid #d4d8dd; /* 恢复PC端去掉的右边框 */
      margin: 0;
    }
  
    /* 搜索输入框容器 */
    .lw-search-input-wrapper {
      width: 100%;
      flex: 0 0 100%; /* 强制换行 */
      min-height: 44px;
      border-radius: 10px;
      background-color: #fff;
      color: #333;
      border: 1px solid #d4d8dd;
    }
  
    /* 聚焦时的样式 */
    .lw-top-search > select:focus,
    .lw-search-input-wrapper:focus-within {
      border-color: var(--color-primary);
      box-shadow: 0 0 0 3px rgba(121, 128, 149, 0.15);
    }
  
    /* --- 5.3 按钮组：搜索和重置并排 (各占50%) --- */
    
    .lw-top-search > .lw-btn {
      flex: 1; /* 两个按钮平分剩余空间 */
      width: auto; /*不仅限于固定宽度 */
      height: 44px;
      border-radius: 10px; /* 恢复四个角的圆角 */
      padding: 0; /* 居中文字 */
      margin: 0;
    }
  
    /* 针对重置按钮(Ghost)的特殊修复 */
    .lw-top-search .lw-btn.ghost {
      border-left: 1px solid var(--color-primary); /* 恢复PC端去掉的左边框 */
      border-radius: 10px;
    }
    
    /* 加载状态下的样式修复 */
    .lw-top-search .lw-btn.primary.loading,
    .lw-top-search .lw-btn.ghost.loading {
      padding: 0;
      border-radius: 10px;
    }
  
    /* --- 5.4 快捷关键词 --- */
    .lw-quick-keywords {
      /* flex-direction: column;
      gap: 10px;
      margin-top: 10px; */
      display:none;
    }
  
    .lw-quick-keywords .qk-label {
      font-size: 13px;
    }
  
    .lw-quick-keywords .qk-tags {
      gap: 8px;
    }
  
    .lw-quick-keywords .qk-tag {
      font-size: 12px;
      padding: 5px 12px;
      background: rgba(255,255,255,0.5); /* 增加一点背景方便点击 */
      border-radius: 4px;
    }
    
    .lw-quick-keywords .qk-tag:not(:last-child)::after {
      display: none; /* 移动端去掉竖线分隔符，看起来更整洁 */
    }
  
    /* --- 5.5 头部导航栏适配 (保留你原本代码中的逻辑) --- */
    .mobile-menu-toggle .hamburger-line {
      background-color: #fff;
    }
    
    .laws-page .header-area .main-nav .nav > li > a {
      color: #333;
    }
    
    .header-area .nav a:hover, 
    .header-area .nav a.active {
      color: white !important;
    }
    
    .laws-page .header-area .main-nav .nav > li.dropdown > a.dropdown-toggle {
      color: #333 !important;
    }
    
  }