<template>
  <a-modal
    v-model:visible="visible"
    :footer="false"
    :width="modalWidth"
    modal-class="wechat-bind-modal"
    title-align="start"
    @close="handleClose"
  >
    <template #title>
      <div class="modal-title">
        <span class="modal-title__icon"><icon-wechat /></span>
        <span>微信绑定</span>
      </div>
    </template>

    <section class="bind-shell" :class="`bind-shell--${stateType}`">
      <div class="bind-hero">
        <div class="bind-hero__copy">
          <span class="eyebrow">{{ stateEyebrow }}</span>
          <h2>{{ stateTitle }}</h2>
          <p>{{ stateDescription }}</p>
        </div>
        <div class="signal" :class="`signal--${stateType}`">
          <span></span>
          <i></i>
        </div>
      </div>

      <div class="bind-grid">
        <div class="scan-panel">
          <template v-if="showQr">
            <div
              class="qr-frame qr-frame--clickable"
              :class="{ 'qr-frame--loading': bindingLoading }"
              role="button"
              tabindex="0"
              title="点击重新生成二维码"
              @click="refreshQrCode"
              @keydown.enter.prevent="refreshQrCode"
              @keydown.space.prevent="refreshQrCode"
            >
              <canvas v-if="!bindingQrIsImage" ref="qrcodeCanvas" class="qr-canvas" aria-label="wechat qrcode"></canvas>
              <img v-else :src="bindingQrSource" alt="微信绑定二维码" />
              <span class="qr-frame__action">
                {{ bindingLoading ? '正在生成' : '点击刷新' }}
              </span>
            </div>
            <div class="qr-meta">
              <span>二维码有效期</span>
              <strong>{{ qrRemainText }}</strong>
            </div>
          </template>

          <template v-else>
            <div class="state-visual">
              <icon-check-circle v-if="isActive" />
              <icon-exclamation-circle v-else-if="isExpired" />
              <icon-scan v-else />
            </div>
            <strong>{{ emptyTitle }}</strong>
            <p>{{ emptyText }}</p>
          </template>
        </div>

        <div class="info-panel">
          <div class="metric">
            <span>绑定状态</span>
            <a-tag :color="bindingColor">{{ bindingLabel }}</a-tag>
          </div>
          <div class="metric">
            <span>最近微信消息</span>
            <strong>{{ lastActiveText }}</strong>
          </div>
          <div class="metric">
            <span>登录保持</span>
            <strong>{{ keepAliveText }}</strong>
          </div>
          <div class="capabilities">
            <span>已启用能力</span>
            <ul>
              <li>微信接收消息通知</li>
              <li>微信内与小妍助理对话</li>
            </ul>
          </div>
        </div>
      </div>
    </section>

    <div class="modal-actions">
      <a-button
        v-if="showCreateButton"
        type="primary"
        size="large"
        :loading="bindingLoading"
        @click="createBinding"
      >
        <template #icon><icon-scan /></template>
        {{ createButtonText }}
      </a-button>
      <a-button
        v-if="showUnbindButton"
        size="large"
        status="danger"
        :loading="bindingLoading"
        @click="confirmUnbind"
      >
        <template #icon><icon-delete /></template>
        解除绑定
      </a-button>
      <a-button size="large" :loading="loading" @click="refreshBinding">
        <template #icon><icon-refresh /></template>
        刷新状态
      </a-button>
    </div>
  </a-modal>
</template>

<script setup>
import { computed, nextTick, onUnmounted, ref, watch } from 'vue'
import { Message, Modal } from '@arco-design/web-vue'
import QRCode from 'qrcode'
import { createWeixinBinding, deleteWeixinBinding, getWeixinBinding } from '@/api/aiChat'

const emit = defineEmits(['updated'])

const QR_EXPIRE_MS = 5 * 60 * 1000

const visible = ref(false)
const loading = ref(false)
const bindingLoading = ref(false)
const binding = ref(null)
const qrcodeCanvas = ref(null)
const now = ref(Date.now())
let pollTimer = null
let clockTimer = null

const modalWidth = computed(() => (window.innerWidth < 760 ? '94vw' : '780px'))
const bindingQrSource = computed(() => binding.value?.qrcode_url || binding.value?.qrcode || '')
const bindingQrIsImage = computed(() => /^data:image\//i.test(bindingQrSource.value))
const qrExpireTime = computed(() => Number(binding.value?.qrcode_expire_time || 0))
const isPending = computed(() => binding.value?.state === 0)
const isActive = computed(() => binding.value?.state === 1)
const isDisabled = computed(() => binding.value?.state === 2)
const isQrExpired = computed(() => {
  if (binding.value?.expire_type === 'qrcode' || binding.value?.qrcode_expired) return true
  if (!isPending.value || !qrExpireTime.value) return false
  return now.value >= qrExpireTime.value
})
const isSessionExpired = computed(() => binding.value?.state === 3 && !isQrExpired.value)
const isExpired = computed(() => isQrExpired.value || isSessionExpired.value)
const showQr = computed(() => isPending.value && !isExpired.value && bindingQrSource.value)
const stateType = computed(() => {
  if (isActive.value) return 'active'
  if (showQr.value) return 'pending'
  if (isExpired.value) return 'expired'
  return 'idle'
})
const bindingLabel = computed(() => {
  if (isActive.value) return '已绑定'
  if (showQr.value) return '待扫码'
  if (isExpired.value) return '已过期'
  if (isDisabled.value) return '已解绑'
  return '未绑定'
})
const bindingColor = computed(() => ({ active: 'green', pending: 'orange', expired: 'red', idle: 'gray' }[stateType.value]))
const stateEyebrow = computed(() => {
  if (isActive.value) return 'CONNECTED'
  if (showQr.value) return 'WAITING FOR SCAN'
  if (isExpired.value) return 'EXPIRED'
  return 'NOT CONNECTED'
})
const stateTitle = computed(() => {
  if (isActive.value) return '微信已连接'
  if (showQr.value) return '等待扫码确认'
  if (isQrExpired.value) return '二维码已过期'
  if (isSessionExpired.value) return '微信登录已过期'
  return '尚未绑定微信'
})
const stateDescription = computed(() => {
  if (isActive.value) return '小妍助理可通过微信接收消息，乐跑通知也可投递到当前微信会话'
  if (showQr.value) return '使用微信扫码并确认授权'
  if (isQrExpired.value) return '当前二维码不可继续使用，请重新生成后完成绑定'
  if (isSessionExpired.value) return '超过 24 小时未向小妍助理发送消息，请重新生成二维码完成绑定'
  return '绑定后可在微信中接收乐跑通知，并继续使用小妍助理对话'
})
const emptyTitle = computed(() => {
  if (isActive.value) return '连接运行中'
  if (isExpired.value) return '当前二维码不可用'
  return '准备生成绑定二维码'
})
const emptyText = computed(() => {
  if (isActive.value) return '保持 24 小时内至少发送一条微信消息，可维持登录状态'
  if (isExpired.value) return '重新生成后请在 5 分钟内扫码确认'
  return '点击下方按钮生成新的微信绑定二维码'
})
const showCreateButton = computed(() => !isActive.value && (!isPending.value || isQrExpired.value || isSessionExpired.value))
const showUnbindButton = computed(() => isActive.value || isSessionExpired.value)
const createButtonText = computed(() => (isExpired.value ? '重新生成二维码' : '生成绑定二维码'))
const keepAliveText = computed(() => (isActive.value ? '24 小时内发送消息' : '绑定后生效'))
const qrRemainText = computed(() => {
  if (!showQr.value || !qrExpireTime.value) return '-'
  const remain = Math.max(0, Math.ceil((qrExpireTime.value - now.value) / 1000))
  const min = Math.floor(remain / 60)
  const sec = String(remain % 60).padStart(2, '0')
  return `${min}:${sec}`
})
const lastActiveText = computed(() => {
  const time = Number(binding.value?.last_user_message_time || 0)
  if (!time) return '暂无'
  return new Date(time).toLocaleString('zh-CN', { month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' })
})

const drawQrLogo = () => {
  const canvas = qrcodeCanvas.value
  if (!canvas) return
  const ctx = canvas.getContext('2d')
  const logo = new Image()
  logo.src = '/logo.svg'
  logo.onload = () => {
    const logoSize = canvas.width * 0.15
    const x = (canvas.width - logoSize) / 2
    const y = (canvas.height - logoSize) / 2
    ctx.save()
    ctx.fillStyle = '#fff'
    if (ctx.roundRect) {
      ctx.beginPath()
      ctx.roundRect(x - 6, y - 6, logoSize + 12, logoSize + 12, 8)
      ctx.fill()
    } else {
      ctx.fillRect(x - 6, y - 6, logoSize + 12, logoSize + 12)
    }
    ctx.drawImage(logo, x, y, logoSize, logoSize)
    ctx.restore()
  }
}

const renderQrCode = async () => {
  await nextTick()
  if (!qrcodeCanvas.value || bindingQrIsImage.value || !showQr.value) return
  await QRCode.toCanvas(qrcodeCanvas.value, bindingQrSource.value, {
    width: 236,
    margin: 1,
    color: { dark: '#0f172a', light: '#ffffff' }
  })
  drawQrLogo()
}

const syncBinding = (data) => {
  binding.value = data || null
  emit('updated', binding.value)
}

const refreshBinding = async () => {
  loading.value = true
  try {
    const res = await getWeixinBinding()
    if (res?.code === 0) {
      syncBinding(res.data)
      await renderQrCode()
    }
  } finally {
    loading.value = false
  }
}

const createBinding = async () => {
  bindingLoading.value = true
  try {
    const res = await createWeixinBinding()
    if (!res || res.code !== 0) return Message.warning(res?.msg || '创建绑定失败')
    now.value = Date.now()
    syncBinding({
      ...res.data,
      qrcode_expire_time: res.data?.qrcode_expire_time || Date.now() + QR_EXPIRE_MS
    })
    await renderQrCode()
    Message.success('二维码已生成')
  } finally {
    bindingLoading.value = false
  }
}

const refreshQrCode = async () => {
  if (!showQr.value || bindingLoading.value) return
  await createBinding()
}

const unbind = async () => {
  bindingLoading.value = true
  try {
    const res = await deleteWeixinBinding()
    if (!res || res.code !== 0) return Message.warning(res?.msg || '解绑失败')
    await refreshBinding()
    Message.success('已解除绑定')
  } finally {
    bindingLoading.value = false
  }
}

const confirmUnbind = () => {
  Modal.warning({
    title: '确认解除微信绑定？',
    content: '解除后将无法通过微信接收乐跑通知，也不能在微信中继续使用小妍助理。',
    hideCancel: false,
    okText: '解除绑定',
    cancelText: '取消',
    onOk: unbind
  })
}

const startTimers = () => {
  handleClose()
  pollTimer = setInterval(() => {
    if (visible.value && (isPending.value || isActive.value)) refreshBinding()
  }, 5000)
  clockTimer = setInterval(() => {
    now.value = Date.now()
  }, 1000)
}

const open = async (initialBinding = null) => {
  visible.value = true
  now.value = Date.now()
  if (initialBinding) syncBinding(initialBinding)
  await refreshBinding()
  startTimers()
}

const handleClose = () => {
  if (pollTimer) clearInterval(pollTimer)
  if (clockTimer) clearInterval(clockTimer)
  pollTimer = null
  clockTimer = null
}

onUnmounted(handleClose)
watch([bindingQrSource, showQr], renderQrCode)

defineExpose({ open })
</script>

<style scoped lang="less">
.modal-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.modal-title__icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: #00c16a;
  background: rgba(0, 193, 106, 0.12);
}

.bind-shell {
  position: relative;
  overflow: hidden;
  padding: 18px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(2, 6, 23, 0.96), rgba(15, 23, 42, 0.92)),
    radial-gradient(circle at 80% 0%, rgba(0, 193, 106, 0.28), transparent 34%);
  color: #f8fafc;
}

.bind-shell::before {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: '';
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.08) 1px, transparent 1px);
  background-size: 26px 26px;
  mask-image: linear-gradient(180deg, #000, transparent 88%);
}

.bind-shell--pending {
  background:
    linear-gradient(135deg, rgba(17, 24, 39, 0.96), rgba(2, 6, 23, 0.92)),
    radial-gradient(circle at 80% 0%, rgba(247, 144, 9, 0.24), transparent 34%);
}

.bind-shell--expired {
  background:
    linear-gradient(135deg, rgba(17, 24, 39, 0.96), rgba(2, 6, 23, 0.94)),
    radial-gradient(circle at 80% 0%, rgba(240, 68, 56, 0.24), transparent 34%);
}

.bind-hero,
.bind-grid,
.modal-actions {
  position: relative;
  z-index: 1;
}

.bind-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  color: #7dd3fc;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.bind-hero h2 {
  margin: 6px 0;
  color: #fff;
  font-size: 24px;
  line-height: 1.2;
}

.bind-hero p {
  max-width: 520px;
  margin: 0;
  color: #cbd5e1;
  line-height: 1.65;
}

.signal {
  position: relative;
  flex: 0 0 auto;
  width: 62px;
  height: 62px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 50%;
}

.signal span,
.signal i {
  position: absolute;
  inset: 14px;
  border-radius: 50%;
}

.signal span {
  background: #94a3b8;
  box-shadow: 0 0 28px rgba(148, 163, 184, 0.55);
}

.signal i {
  border: 1px solid rgba(255, 255, 255, 0.45);
  animation: signal-ring 1.8s ease-out infinite;
}

.signal--active span {
  background: #00c16a;
  box-shadow: 0 0 32px rgba(0, 193, 106, 0.75);
}

.signal--pending span {
  background: #f79009;
  box-shadow: 0 0 32px rgba(247, 144, 9, 0.75);
}

.signal--expired span {
  background: #f04438;
  box-shadow: 0 0 32px rgba(240, 68, 56, 0.75);
}

.bind-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 14px;
}

.scan-panel,
.info-panel {
  min-width: 0;
  border: 1px solid rgba(226, 232, 240, 0.14);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.64);
  backdrop-filter: blur(14px);
}

.scan-panel {
  display: grid;
  place-items: center;
  min-height: 330px;
  padding: 20px;
  text-align: center;
}

.qr-frame {
  display: grid;
  place-items: center;
  width: 270px;
  height: 270px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.32);
}

.qr-frame img,
.qr-canvas {
  width: 236px;
  height: 236px;
}

.qr-meta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  color: #cbd5e1;
}

.qr-meta strong {
  color: #facc15;
  font-size: 18px;
}

.state-visual {
  display: grid;
  place-items: center;
  width: 82px;
  height: 82px;
  margin-bottom: 18px;
  border: 1px solid rgba(125, 211, 252, 0.26);
  border-radius: 8px;
  color: #7dd3fc;
  background: rgba(14, 165, 233, 0.12);
  font-size: 34px;
}

.scan-panel > strong {
  color: #fff;
  font-size: 18px;
}

.scan-panel > p {
  max-width: 360px;
  margin: 8px 0 0;
  color: #cbd5e1;
  line-height: 1.6;
}

.info-panel {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 14px;
}

.metric,
.capabilities {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(226, 232, 240, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.metric span,
.capabilities span {
  color: #94a3b8;
  font-size: 12px;
}

.metric strong {
  color: #f8fafc;
}

.capabilities ul {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  color: #e2e8f0;
  list-style: none;
}

.capabilities li::before {
  margin-right: 7px;
  color: #00c16a;
  content: '•';
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

@keyframes signal-ring {
  from {
    opacity: 0.8;
    transform: scale(0.7);
  }

  to {
    opacity: 0;
    transform: scale(1.7);
  }
}

@media (max-width: 760px) {
  .bind-shell {
    padding: 14px;
  }

  .bind-hero {
    align-items: flex-start;
  }

  .signal {
    width: 46px;
    height: 46px;
  }

  .signal span,
  .signal i {
    inset: 11px;
  }

  .bind-grid {
    grid-template-columns: 1fr;
  }

  .scan-panel {
    min-height: 286px;
  }

  .qr-frame {
    width: 236px;
    height: 236px;
  }

  .qr-frame img,
  .qr-canvas {
    width: 208px;
    height: 208px;
  }

  .modal-actions .arco-btn {
    flex: 1 1 100%;
  }
}

/* Visual refresh: keep the existing state logic, align the card with the AI assistant light theme. */
.modal-title {
  color: #1d2129;
}

.modal-title__icon {
  color: #0f9f7a;
  background: linear-gradient(135deg, rgba(236, 253, 243, 0.96), rgba(239, 246, 255, 0.96));
  box-shadow: 0 8px 20px rgba(43, 179, 169, 0.12);
}

.bind-shell,
.bind-shell--pending,
.bind-shell--expired {
  padding: 20px;
  border-color: rgba(43, 179, 169, 0.16);
  background:
    radial-gradient(circle at 12% 8%, rgba(43, 179, 169, 0.12), transparent 32%),
    radial-gradient(circle at 92% 6%, rgba(103, 87, 245, 0.1), transparent 30%),
    linear-gradient(135deg, #f7f9ff 0%, #ffffff 50%, #f3fbf8 100%);
  color: #1d2129;
  box-shadow: 0 20px 48px rgba(35, 48, 86, 0.08);
}

.bind-shell--pending {
  background:
    radial-gradient(circle at 12% 8%, rgba(247, 144, 9, 0.1), transparent 32%),
    radial-gradient(circle at 92% 6%, rgba(103, 87, 245, 0.1), transparent 30%),
    linear-gradient(135deg, #fffaf3 0%, #ffffff 48%, #f5fbff 100%);
}

.bind-shell--expired {
  background:
    radial-gradient(circle at 12% 8%, rgba(240, 68, 56, 0.09), transparent 32%),
    radial-gradient(circle at 92% 6%, rgba(103, 87, 245, 0.08), transparent 30%),
    linear-gradient(135deg, #fff7f7 0%, #ffffff 48%, #f7f9ff 100%);
}

.bind-shell::before {
  background-image:
    linear-gradient(rgba(116, 89, 255, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(43, 179, 169, 0.055) 1px, transparent 1px);
  background-size: 24px 24px;
  mask-image: linear-gradient(180deg, #000, transparent 86%);
}

.eyebrow {
  color: #0f9f7a;
}

.bind-shell--pending .eyebrow {
  color: #d97706;
}

.bind-shell--expired .eyebrow {
  color: #d92d20;
}

.bind-hero h2 {
  color: #1d2129;
}

.bind-hero p {
  color: #667085;
}

.signal {
  width: 58px;
  height: 58px;
  border-color: rgba(43, 179, 169, 0.18);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 14px 34px rgba(35, 48, 86, 0.08);
}

.signal span {
  background: #98a2b3;
  box-shadow: 0 0 24px rgba(152, 162, 179, 0.28);
}

.signal i {
  border-color: rgba(43, 179, 169, 0.3);
}

.signal--active span {
  background: #12b76a;
  box-shadow: 0 0 28px rgba(18, 183, 106, 0.38);
}

.signal--pending span {
  background: #f79009;
  box-shadow: 0 0 28px rgba(247, 144, 9, 0.34);
}

.signal--expired span {
  background: #f04438;
  box-shadow: 0 0 28px rgba(240, 68, 56, 0.34);
}

.scan-panel,
.info-panel {
  border-color: rgba(17, 24, 39, 0.075);
  background: rgba(255, 255, 255, 0.76);
  box-shadow:
    0 14px 32px rgba(35, 48, 86, 0.07),
    inset 0 1px 0 rgba(255, 255, 255, 0.82);
}

.qr-frame {
  position: relative;
  border-color: rgba(43, 179, 169, 0.16);
  border-radius: 14px;
  box-shadow:
    0 22px 48px rgba(35, 48, 86, 0.12),
    0 0 0 8px rgba(43, 179, 169, 0.055);
}

.qr-frame--clickable {
  cursor: pointer;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.qr-frame--clickable:hover,
.qr-frame--clickable:focus-visible {
  border-color: rgba(43, 179, 169, 0.34);
  box-shadow:
    0 24px 52px rgba(35, 48, 86, 0.14),
    0 0 0 8px rgba(43, 179, 169, 0.08);
  transform: translateY(-1px);
}

.qr-frame--loading {
  cursor: wait;
}

.qr-frame--loading .qr-canvas,
.qr-frame--loading img {
  opacity: 0.56;
}

.qr-frame__action {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border: 1px solid rgba(43, 179, 169, 0.18);
  border-radius: 999px;
  color: #0f766e;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 18px rgba(35, 48, 86, 0.1);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.qr-frame--clickable:hover .qr-frame__action,
.qr-frame--clickable:focus-visible .qr-frame__action,
.qr-frame--loading .qr-frame__action {
  opacity: 1;
  transform: translateY(0);
}

.qr-frame::before,
.qr-frame::after {
  content: none;
}

.qr-frame img,
.qr-canvas {
  border-radius: 8px;
}

.qr-meta {
  padding: 8px 12px;
  border: 1px solid rgba(247, 144, 9, 0.16);
  border-radius: 999px;
  color: #667085;
  background: rgba(255, 250, 235, 0.86);
}

.qr-meta strong {
  color: #b54708;
}

.state-visual {
  border-color: rgba(43, 179, 169, 0.18);
  color: #0f9f7a;
  background: linear-gradient(135deg, rgba(236, 253, 243, 0.96), rgba(239, 246, 255, 0.96));
  box-shadow: 0 14px 34px rgba(43, 179, 169, 0.12);
}

.scan-panel > strong {
  color: #1d2129;
}

.scan-panel > p {
  color: #667085;
}

.metric,
.capabilities {
  padding: 13px;
  border-color: rgba(17, 24, 39, 0.065);
  background: rgba(255, 255, 255, 0.68);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.metric:hover,
.capabilities:hover {
  border-color: rgba(43, 179, 169, 0.2);
  box-shadow: 0 12px 26px rgba(35, 48, 86, 0.07);
  transform: translateY(-1px);
}

.metric span,
.capabilities span {
  color: #667085;
}

.metric strong,
.capabilities ul {
  color: #1d2129;
}

.capabilities li::before {
  color: #12b76a;
}

.modal-actions :deep(.arco-btn-primary) {
  border: 0;
  background: linear-gradient(135deg, #6757f5, #20b7a7);
  box-shadow: 0 10px 22px rgba(43, 179, 169, 0.24);
}

@media (max-width: 760px) {
  .bind-shell,
  .bind-shell--pending,
  .bind-shell--expired {
    padding: 14px;
  }

  .signal {
    width: 46px;
    height: 46px;
  }
}
</style>
