<view class="container">
  <!-- 用户信息填写弹窗 -->
  <view class="user-info-modal" wx:if="{{showUserInfoModal}}">
    <view class="modal-mask"></view>
    <view class="modal-content">
      <view class="modal-title">填写你的信息</view>
      <view class="modal-body">
        <view class="avatar-section">
          <button class="avatar-wrapper" open-type="chooseAvatar" bindchooseavatar="onChooseAvatar">
            <image class="avatar" src="{{userInfo.avatarUrl || '/images/default-avatar.png'}}" mode="aspectFill"></image>
            <view class="avatar-tip">点击选择头像</view>
          </button>
        </view>
        <input type="nickname" class="nickname-input-modal" placeholder="请输入昵称" value="{{userInfo.nickName}}" bindchange="onNicknameChange" />
      </view>
      <view class="modal-footer">
        <button class="modal-btn cancel" bindtap="onCancelUserInfo">取消</button>
        <button class="modal-btn confirm" bindtap="onConfirmUserInfo">确定</button>
      </view>
    </view>
  </view>

  <!-- 聚会信息 -->
  <view class="room-info">
    <view class="room-title" bindtap="onEditRoomName">{{roomName}}</view>
    <view class="room-tags">
      <picker mode="selector" range="{{keywordOptions}}" value="{{keywordIndex}}" bindchange="onKeywordChange">
        <view class="tag keyword-tag">{{keywords}}</view>
      </picker>
      <view class="time-tag-picker">
        <picker mode="date" value="{{meetDate}}" bindchange="onDateChange" class="time-picker">
          <view class="tag time-tag">
            {{meetDate || '选择日期'}}
          </view>
        </picker>
        <picker mode="time" value="{{meetTimeOnly}}" bindchange="onTimeChange" class="time-picker">
          <view class="tag time-tag">
            {{meetTimeOnly || '选择时间'}}
          </view>
        </picker>
      </view>
    </view>

    <!-- 特殊需求直接编辑 -->
    <view class="requirements-section {{requirements || editingRequirements ? '' : 'empty'}}" bindtap="onEditRequirements">
      <view class="requirements-label" wx:if="{{requirements || editingRequirements}}">特殊需求</view>
      <textarea
        wx:if="{{editingRequirements}}"
        class="requirements-textarea"
        placeholder="如：需要停车位、环境安静、有Wi-Fi等"
        value="{{requirements}}"
        bindinput="onRequirementsInput"
        bindblur="onRequirementsBlur"
        bindconfirm="onRequirementsConfirm"
        maxlength="200"
        auto-focus="{{true}}"
        show-confirm-bar="{{false}}"
      />
      <view class="requirements-text" wx:elif="{{requirements}}">{{requirements}}</view>
      <view class="requirements-text" wx:else>点击添加特殊需求</view>
    </view>
  </view>

  <!-- 顶部统计信息 -->
  <view class="header">
    <view class="stats">
      <text class="stat-item">参与成员 {{members.length}}人</text>
      <text class="stat-divider">|</text>
      <text class="stat-item ready-count">已就位 {{readyCount}}人</text>
    </view>
  </view>

  <!-- 成员列表 -->
  <scroll-view scroll-y class="member-list">
    <block wx:for="{{members}}" wx:key="openid">
      <view class="member-item {{item.location ? 'ready' : 'waiting'}}"
            bindtap="onAddMemberLocation"
            bindlongpress="{{isCreator && item.openid !== currentUserOpenId ? 'onRemoveMember' : ''}}"
            data-openid="{{item.openid}}"
            data-nickname="{{item.nickName}}"
            data-istest="{{item.isTestMember}}">
        <image class="avatar" src="{{item.avatarUrl || '/images/default-avatar.png'}}" mode="aspectFill"></image>
        <view class="info">
          <view class="nickname">
            {{item.nickName}}
            <text wx:if="{{item.openid === currentUserOpenId}}" class="me-tag">（我）</text>
          </view>
          <view class="status">
            {{item.location ? item.location.name || '已选定位置' : '等待添加位置...'}}
          </view>
        </view>
        <view class="status-icon">{{item.location ? '√' : '○'}}</view>
      </view>
    </block>
  </scroll-view>

  <!-- 测试按钮（浮动） -->
  <view class="test-float-btn" bindtap="onAddTestMember" wx:if="{{true}}">
    <text>+</text>
  </view>

  <!-- 底部操作按钮 -->
  <view class="footer-actions">
    <button class="action-btn secondary-btn" bindtap="onAddLocation">添加/修改我的位置</button>
    <button class="action-btn secondary-btn" open-type="share">邀请好友</button>
    <button wx:if="{{!isCreator && hasJoined}}" class="action-btn warning-btn" bindtap="onLeaveRoom">退出聚会</button>
    <button class="action-btn primary-btn" bindtap="onCalculate" loading="{{calculating}}" disabled="{{calculating}}">
      {{calculating ? '计算中...' : '开始计算'}}
    </button>
    <button class="action-btn result-btn {{hasResult ? '' : 'disabled'}}" bindtap="onViewResult">查看结果</button>
  </view>
</view>
