<t-navbar title="满意度问卷" left-arrow />
<scroll-view class="page-container" scroll-y>
  <!-- 加载状态 -->
  <view class="loading-container" wx:if="{{loading}}">
    <view class="loading-text">加载中...</view>
  </view>

  <!-- 问卷内容 -->
  <view class="questionnaire-container" wx:elif="{{!showEmpty}}">
    <!-- 标题 -->
    <view class="questionnaire-title">{{followDetail.name || '满意度问卷'}}</view>

    <!-- 介绍文字 -->
    <view class="questionnaire-intro" wx:if="{{followDetail.startSentence}}">
      {{followDetail.startSentence}}
    </view>

    <!-- 分数说明 -->
    <view class="score-explanation">
      <text class="score-explanation-text">分数说明:1分表示非常不满意,2分表示不满意,3分表示一般,4分表示满意,5分表示非常满意</text>
    </view>

    <!-- 问题组 -->
    <view class="question-groups" wx:if="{{followDetail.groups}}">
      <view class="question-group" wx:for="{{followDetail.groups}}" wx:key="index" wx:for-index="groupIndex">
        <!-- 问题组标题 -->
        <view class="group-title">{{item.name}}</view>

        <!-- 问题列表 -->
        <view class="question-list">
          <view class="question-item" wx:for="{{item.items}}" wx:key="index" wx:for-index="itemIndex">
            <!-- 问题名称 -->
            <view class="question-name">{{itemIndex + 1}}、{{item.name}}</view>

            <!-- 分数选择（单选） -->
            <t-radio-group value="{{item.selectedScore || item.score}}" borderless t-class="box" bind:change="onScoreChange" data-group-index="{{groupIndex}}" data-item-index="{{itemIndex}}">
              <t-radio block="{{false}}" :label="{{item.label}}" :value="{{item.value}}" wx:for="{{scoreList}}" wx:key="value" style="margin-right:20rpx" />
            </t-radio-group>
          </view>
        </view>
      </view>
    </view>

    <!-- 其他意见 -->
    <view class="other-comment-section">
      <view class="other-comment-title">其他意见:</view>
      <textarea class="other-comment-input" placeholder="请给我们留言您的其他意见" value="{{suggestion}}" bindinput="onCommentInput" maxlength="500" show-confirm-bar="{{false}}" />
    </view>

    <!-- 结束语 -->
    <view class="questionnaire-end">
      {{followDetail.endSentence}}
    </view>
  </view>

  <!-- 无数据提示 -->
  <view class="empty-container" wx:elif="{{showEmpty}}">
    <view class="empty-text">暂无问卷数据</view>
  </view>
</scroll-view>

<!-- 保存按钮 -->
<view class="save-button-container" wx:if="{{!showEmpty}}">
  <button class="save-button" bindtap="onSave" disabled="{{saving}}">
    <text wx:if="{{saving}}">保存中...</text>
    <text wx:else>保存</text>
  </button>
</view>