/* ============================================================
   select-widget.css — 现代化下拉选择组件（零依赖）
   配套 select-widget.js。政务蓝主题。
   ============================================================ */

/* 原生 select：视觉隐藏，但保留在 DOM 中（维持 name/表单提交/校验/无障碍） */
.sw-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* 根容器：占据原 select 的布局位置 */
.sw-root {
  position: relative;
  display: block;
  width: 100%;
}

/* 触发器（原 select 外观的现代化替身） */
.sw-trigger {
  position: relative;
  width: 100%;
  min-height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  border: 1px solid var(--color-border, #d1d5db);
  border-radius: 0.375rem;
  background: #fff;
  font-size: 0.875rem;
  line-height: 1.25;
  color: var(--color-text-main, #1f2937);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.sw-trigger:hover {
  border-color: var(--color-primary, #1a4a8a);
}
.sw-root.sw-open .sw-trigger,
.sw-trigger:focus-visible {
  border-color: var(--color-primary, #1a4a8a);
  box-shadow: 0 0 0 3px rgba(26, 74, 138, 0.12);
  outline: none;
}

/* 当前选中文本（溢出省略） */
.sw-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sw-value.sw-placeholder {
  color: #9ca3af;
}

/* 箭头 */
.sw-arrow {
  position: absolute;
  right: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  color: #6b7280;
  font-size: 0.75rem;
  pointer-events: none;
  transition: transform 0.2s;
}
.sw-root.sw-open .sw-arrow {
  transform: translateY(-50%) rotate(180deg);
}

/* 下拉面板 */
.sw-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 0.25rem;
  max-height: 15rem;
  overflow-y: auto;
  list-style: none;
  margin-bottom: 0;
  padding: 0.25rem;
  background: #fff;
  border: 1px solid var(--color-border, #d1d5db);
  border-radius: 0.5rem;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  z-index: 50;
}
/* 视口空间不足时向上翻转 */
.sw-root.sw-up .sw-list {
  top: auto;
  bottom: 100%;
  margin-top: 0;
  margin-bottom: 0.25rem;
}

/* 选项 */
.sw-opt {
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  color: var(--color-text-main, #1f2937);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sw-opt:hover {
  background: rgba(26, 74, 138, 0.06);
}
.sw-opt.sw-active {
  background: rgba(26, 74, 138, 0.12);
}
.sw-opt.sw-selected {
  color: var(--color-primary, #1a4a8a);
  font-weight: 600;
}
.sw-opt[aria-disabled="true"] {
  color: #9ca3af;
  cursor: not-allowed;
  background: transparent;
}

/* 分组标题 */
.sw-group {
  padding: 0.375rem 0.75rem 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #9ca3af;
}

/* 空态 */
.sw-empty {
  padding: 0.75rem;
  text-align: center;
  color: #9ca3af;
  font-size: 0.875rem;
}

/* 搜索框 */
.sw-search {
  padding: 0.375rem 0.5rem;
  border-bottom: 1px solid var(--color-border, #d1d5db);
  margin-bottom: 0.25rem;
}
.sw-search-input {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--color-border, #d1d5db);
  border-radius: 0.375rem;
  font-size: 0.875rem;
  outline: none;
}
.sw-search-input:focus {
  border-color: var(--color-primary, #1a4a8a);
}

/* 搜索表单内的下拉组件：继承原 .search-form select 的 flex 布局宽度
   （select-widget.css 在 common.css 之后加载，确保此规则生效） */
.search-form .sw-root {
  flex: 0 0 auto;
  width: 8rem;
  display: flex; /* 让 .sw-trigger 撑满根高度，与 input/button 垂直对齐 */
}
/* 触发器与搜索框 input（py-3 text-base => 内容 48px + 2px 边框 ≈ 50px）同高 */
.search-form .sw-root .sw-trigger {
  min-height: 3rem;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
  font-size: 1rem;
  line-height: 1.5;
}
@media (max-width: 640px) {
  .search-form .sw-root {
    flex: 1 1 auto;
    width: auto;
  }
}

/* 顶部搜索框（深色半透明条）内的下拉组件：适配 h-9 高度 + 深色主题，
   与相邻的 input/button 视觉与高度一致。注意：.sw-root 不能设 overflow:hidden，
   否则绝对定位的下拉面板会被裁剪。 */
.header-search-form .sw-root {
  flex: 0 0 auto;
  width: auto;
  display: flex;
  height: 2.25rem;                 /* = h-9 = 36px */
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-right: 0;
  border-radius: 0.375rem 0 0 0.375rem;  /* rounded-l-md，与 input 共享中缝边框 */
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}
.header-search-form .sw-root .sw-trigger {
  min-height: 2.25rem;
  height: 100%;
  padding: 0 1.75rem 0 0.375rem;   /* 左 px-1.5，右留箭头空间 */
  font-size: 0.75rem;              /* text-xs */
  line-height: 1.25;
  background: transparent;
  border: none;
  border-radius: 0.375rem 0 0 0.375rem;
  color: #fff;
}
.header-search-form .sw-root .sw-trigger:hover {
  background: rgba(255, 255, 255, 0.15);
}
.header-search-form .sw-root.sw-open .sw-trigger,
.header-search-form .sw-root .sw-trigger:focus-visible {
  box-shadow: none;
  border-color: transparent;
}
.header-search-form .sw-arrow {
  color: rgba(255, 255, 255, 0.7);
  right: 0.4rem;
}
/* 下拉面板保持浅色以保证可读性（与站点其他面板一致） */
.header-search-form .sw-list {
  color: #1f2937;
}
/* 顶部搜索框面板选项字号跟随触发器（text-xs），避免面板比触发器宽时文字被裁切 */
.header-search-form .sw-list .sw-opt {
  font-size: 0.75rem;
  line-height: 1.25;
}

/* ============================================================
   移动端 / 触屏：底部抽屉式面板（替代原生 picker）
   解决原生 select 在 PC 端面板宽度受限、在深色条/窄屏下显示不佳的问题
   ============================================================ */
.sw-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 900;
}
body.sw-lock {
  overflow: hidden;
}
.sw-mobile .sw-list {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  top: auto;
  width: 100%;
  max-height: 60vh;
  margin: 0;
  border-radius: 1rem 1rem 0 0;
  box-shadow: 0 -10px 30px rgba(15, 23, 42, 0.2);
  z-index: 1000;
  animation: sw-sheet-up 0.22s ease;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
@keyframes sw-sheet-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
/* 移动端抽屉内选项字号略大，便于点按。
   注意：需高于 .header-search-form .sw-list .sw-opt 的优先级，否则顶部搜索框
   在移动端会被误压成 0.75rem（text-xs），导致字体过小。 */
.sw-mobile .sw-list .sw-opt {
  padding: 0.75rem 1rem;
  font-size: 1rem;
  line-height: 1.5;
}
.sw-mobile .sw-search-input {
  font-size: 1rem;
}
