<template>
  <PhoneMockup :theme="settings.theme" :class="{ 'ios-font': settings.phoneModel === 'ios' }">
    <!-- Status Bar -->
    <StatusBar :time="settings.statusTime" :battery="settings.battery" :signal="settings.signal" :wifi="settings.wifi"
      :is-charging="settings.isCharging" :theme="settings.theme" />

    <!-- Nav Bar -->
    <div class="nav-bar">
      <img class="back-icon" :src="`/src/public/common/back-${settings.theme}.png`" alt="">
      <span class="right-title">{{ settings.pageTitle || '零钱明细' }}</span>
    </div>

    <!-- Content -->
    <div class="page-content">
      <div class="user-info">
        <img class="money-icon" src="@/public/balance/money.png" alt="">
        <p class="nick-name">{{ settings.nickName || '我的零钱' }}</p>
      </div>

      <div class="amount-display wx-font-regular">
        <span class="amount-symbol">￥</span>
        <span class="amount-num">{{ (settings.amount ?? 0).toFixed(2) }}</span>
      </div>

      <div v-if="settings.showLimit" class="limit-warrp">
        <div class="limit-text">
          <img class="icon" src="@/public/balance/warning.png" alt="">
          <span>支付额度剩余<span class="wx-font-regular">¥{{ Number(settings.limitAmount || 0).toFixed(2)
              }}</span>，了解解决办法</span>
          <el-icon size="14">
            <ArrowRight color="#E75E63" />
          </el-icon>
        </div>
      </div>

      <template v-else>
        <div v-if="settings.showLiqitong" class="liqitong-card">
          <img src="@/public/balance/lingtong-logo.png" class="lt-icon" />
          <div class="lt-info">
            <p class="lt-desc">{{ settings.liqitongDesc || '转入零钱通，能赚又能花' }}</p>
            <p class="lt-rate">零钱通 {{ settings.liqitongRate || '七日年化1.17%' }}</p>
          </div>
          <el-icon size="16">
            <ArrowRight color="#AEAEAE" />
          </el-icon>
        </div>

        <div v-else class="lingtong-text">
          <span>转入零钱通，能赚又能花</span>
          <el-icon size="16">
            <ArrowRight color="#FA9D3B" />
          </el-icon>
        </div>
      </template>

      <div v-if="settings.showFAQ" class="faq-section">

        <div class="btn-group">
          <button v-if="settings.showChargeBtn" class="action-btn primary">充值</button>
          <button v-if="settings.showWithdrawBtn" class="action-btn secondary">提现</button>
        </div>
        <p class="faq-title">常见问题</p>
        <p class="faq-desc">{{ settings.serviceText || '本服务由财付通提供' }}</p>
      </div>
    </div>
    <!-- Home Bar -->
    <HomeBar />
  </PhoneMockup>
</template>

<script setup>
import PhoneMockup from '@/components/simulator/PhoneMockup.vue'
import StatusBar from '@/components/simulator/StatusBar.vue'
import HomeBar from '@/components/simulator/homeBar.vue'

defineProps({ settings: { type: Object, default: () => ({}) } })
</script>

<style lang="scss" scoped>
$w: 393px;

.ios-font {
  font-family: -apple-system, "PingFang SC", "Helvetica Neue", Helvetica, Arial, sans-serif !important;
}



.nav-bar {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 0 12px;
  background: var(--wx-bg-primary);
  color: var(--wx-text-primary);

  .back-icon {
    width: 24px;
    height: 24px;
  }

  .right-title {
    font-size: 16px;
    color: var(--wx-text-primary);
    line-height: 23px;
    text-align: right;
  }
}

.page-content {
  flex: 1;
  padding: 55px 20px;
  background: var(--wx-bg-primary);
  color: var(--wx-text-primary);

  .user-info {
    text-align: center;
    margin-bottom: 21px;

    .money-icon {
      width: 52px;
      height: 52px;
    }

    .nick-name {
      margin-top: 32px;
      font-size: 16px;
      color: var(--wx-text-primary);
      line-height: 24px;
    }
  }

  .amount-display {
    text-align: center;
    display: flex;
    align-items: flex-start;
    justify-content: center;

    .amount-symbol {
      font-weight: 700;
      font-size: 30px;
      color: var(--wx-text-primary);
      line-height: 40px;
      // margin-top: 3px;
    }

    .amount-num {
      font-weight: 500;
      font-size: 46px;
      color: var(--wx-text-primary);
      line-height: 40px;
      margin-left: 8px;
    }
  }

  .limit-warrp {
    display: flex;
    justify-content: center;
  }

  .limit-text {
    height: 34px;
    display: inline-flex;
    align-items: center;
    font-weight: 400;
    font-size: 14px;
    color: var(--wx-limit-text-red);
    line-height: 24px;
    background: var(--wx-limit-bg-red);
    border-radius: 4px 4px 4px 4px;
    padding: 9px 4px 9px 8px;
    margin: 24px auto 0;

    .icon {
      width: 16px;
      height: 16px;
      margin-right: 6px;
    }
  }

  .liqitong-card {
    position: relative;
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-radius: 8px;
    margin-bottom: 24px;
    margin-top: 34px;

    &::before {
      content: '';
      position: absolute;
      top: 1px;
      left: 0;
      width: 100%;
      height: 1px;
      background-color: var(--wx-line-color);
      transform: scaleY(0.5);
    }

    &::after {
      content: '';
      position: absolute;
      bottom: 1px;
      left: 0;
      width: 100%;
      height: 1px;
      background-color: var(--wx-line-color);
      transform: scaleY(0.5);
    }

    .lt-icon {
      width: 48px;
      height: 48px;
      border-radius: 50%;
      margin-right: 8px;
    }

    .lt-info {
      flex: 1;

      .lt-desc {
        font-weight: 400;
        font-size: 16px;
        color: var(--wx-text-primary);
      }

      .lt-rate {
        font-weight: 400;
        font-size: 13px;
        color: var(--wx-text-primary);
        margin-top: 1px;
      }
    }

    .lt-arrow {
      font-size: 20px;
      color: #ccc;
    }
  }

  .lingtong-text {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    margin-top: 18px;
    font-weight: 400;
    font-size: 15px;
    color: #FA9D3B;
    line-height: 24px;
  }

  .btn-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 65px;

    .action-btn {
      border: none;
      border-radius: 8px;
      font-size: 16px;
      padding: 13px;
      width: 175px;
      height: 46px;
      font-weight: 500;
      cursor: pointer;

      &.primary {
        background: var(--wx-btn-primary);
        font-size: 16px;
        color: #FFFFFF;
        line-height: 24px;
      }

      &.secondary {
        background: var(--wx-btn-secondary);
        font-size: 16px;
        color: var(--wx-text-primary);
        line-height: 24px;
      }
    }
  }

  .faq-section {
    text-align: center;
    position: absolute;
    bottom: 53px;
    left: 50%;
    transform: translateX(-50%);

    .faq-title {
      font-weight: 400;
      font-size: 13px;
      color: var(--wx-desc-text-blue);
      line-height: 20px;
    }

    .faq-desc {
      font-weight: 400;
      font-size: 11px;
      color: var(--wx-desc-text-grey);
      line-height: 20px;
      margin-top: 4px;
    }
  }
}
</style>
