<view class="container">
  <!-- 搜索 -->
  <view class="search-bar">
    <input class="search-input" placeholder="搜索节气、节日、术语..." value="{{keyword}}" bindinput="onSearch" confirm-type="search"/>
  </view>

  <!-- 分类 -->
  <scroll-view class="cat-scroll" scroll-x enhanced show-scrollbar="{{false}}">
    <view class="cat-list">
      <view
        class="cat-item {{activeCat === item.key ? 'active' : ''}}"
        wx:for="{{categories}}"
        wx:key="key"
        bindtap="switchCat"
        data-key="{{item.key}}"
      >{{item.name}}</view>
    </view>
  </scroll-view>

  <!-- 条目列表 -->
  <view class="entry-list">
    <view class="card entry-card" wx:for="{{filteredEntries}}" wx:key="title" bindtap="toggleEntry" data-index="{{index}}">
      <view class="flex justify-between items-center">
        <text class="text-lg font-bold font-chinese">{{item.title}}</text>
        <text class="badge badge-outline">{{item.catName}}</text>
      </view>
      <view class="text-sm text-muted mt-1" wx:if="{{!item.open}}">{{item.brief}}</view>
      <view class="entry-detail mt-2" wx:if="{{item.open}}">
        <text class="text-base">{{item.content}}</text>
      </view>
    </view>

    <view class="text-center text-muted empty-tip" wx:if="{{filteredEntries.length === 0}}">
      <text>没有找到相关条目</text>
    </view>
  </view>
</view>
