<!-- components/popup-notice/popup-notice.wxml -->

<!-- 全屏弹窗遮罩层（完全不变） -->
<view class="popup-mask" wx:if="{{visible}}" catchtouchmove="preventMove">
  <view class="popup-container {{isFullscreen ? 'fullscreen' : ''}}">
    <!-- 右上角操作按钮组 -->
    <view class="action-buttons">
      <!-- 最小化按钮 -->
      <view class="minimize-btn" bindtap="onMinimize">
        <text class="btn-icon">−</text>
      </view>
      <!-- 全屏切换按钮 -->
      <view class="fullscreen-btn" bindtap="toggleFullscreen">
        <text class="btn-icon">{{isFullscreen ? '✕' : '⛶'}}</text>
      </view>
    </view>

    <!-- 标题 -->
    <view wx:if="{{title}}" class="popup-title">{{title}}</view>

    <!-- 可滚动内容区 -->
    <view class="scroll-wrapper">
      <scroll-view scroll-y class="scroll-view" enhanced show-scrollbar="{{true}}">
        <view wx:if="{{hasTextOnly}}" class="text-content">{{textContent}}</view>
        <view wx:else>
          <view wx:for="{{processedImages}}" wx:key="index" class="image-block">
            <view wx:if="{{item.text}}" class="block-text">{{item.text}}</view>
            <view class="image-padding">
              <image 
                class="block-image" 
                src="{{item.url}}" 
                style="width:100%; height:{{item.height}}px; display:block;"
                data-index="{{index}}"
                data-url="{{item.url}}"
                bindtap="onCustomPreview"
                binderror="onImageError"
                lazy-load="{{false}}"
              />
            </view>
          </view>
        </view>
      </scroll-view>
    </view>

    <!-- 底部固定区 -->
    <view class="bottom-fixed">
      <view wx:if="{{remainingSeconds > 0}}" class="countdown-tip">
        请阅读 {{remainingSeconds}} 秒后关闭
      </view>
      <view wx:if="{{remainingSeconds === 0 && showMuteCheckbox}}" class="mute-row">
        <checkbox-group bindchange="onMuteChange">
          <checkbox value="mute" color="#000" />
          <text class="mute-label">今日不再提示</text>
        </checkbox-group>
      </view>
      <!-- 关闭按钮 -->
      <view 
        class="close-btn {{remainingSeconds > 0 ? 'close-btn-disabled' : ''}}" 
        bindtap="{{remainingSeconds > 0 ? '' : 'onCloseTap'}}"
      >
        <text class="close-btn-text">{{remainingSeconds > 0 ? '阅读中...' : '关闭'}}</text>
        <view class="close-btn-sweep" wx:if="{{remainingSeconds === 0}}"></view>
      </view>
    </view>
  </view>
</view>

<!-- 悬浮窗（自定义触摸拖动） -->
<view 
  class="floating-avatar-wrapper" 
  wx:if="{{isMinimized}}"
  style="left: {{floatX}}px; top: {{floatY}}px;"
  catchtouchstart="onFloatTouchStart"
  catchtouchmove="onFloatTouchMove"
  catchtouchend="onFloatTouchEnd"
>
  <image 
    class="floating-avatar" 
    src="{{floatAvatarUrl}}" 
    mode="aspectFill"
    binderror="onFloatAvatarError"
  />
</view>

<!-- 🆕 自定义图片预览遮罩（全屏，不触发页面生命周期） -->
<view 
  class="custom-preview-mask" 
  wx:if="{{showCustomPreview}}" 
  catchtouchmove="preventMove"
  bindtap="onCloseCustomPreview"
>
  <view class="preview-header">
    <text class="preview-index">{{currentPreviewIndex + 1}} / {{previewUrls.length}}</text>
    <view class="preview-close" bindtap="onCloseCustomPreview">×</view>
  </view>
  <swiper 
    class="preview-swiper" 
    current="{{currentPreviewIndex}}" 
    bindchange="onPreviewSwiperChange"
    indicator-dots="{{false}}"
  >
    <swiper-item wx:for="{{previewUrls}}" wx:key="index">
      <image 
        src="{{item}}" 
        mode="aspectFit" 
        class="preview-image"
        catchtap="stopPropagation"
      />
    </swiper-item>
  </swiper>
</view>