<template>
  <div :class="['order-loading-panel', { compact }]">
    <div class="loading-visual" aria-hidden="true">
      <span class="orbit orbit-one"></span>
      <span class="orbit orbit-two"></span>
      <span class="center-dot"></span>
    </div>
    <div class="loading-copy">
      <p class="loading-title">{{ title }}</p>
    </div>
    <div class="progress-track">
      <span class="progress-bar"></span>
    </div>
    <div class="pulse-row" aria-hidden="true">
      <span></span>
      <span></span>
      <span></span>
      <span></span>
    </div>
  </div>
</template>

<script>
export default {
  name: 'OrderLoadingPanel',
  props: {
    title: {
      type: String,
      default: '正在加载数据'
    },
    detail: {
      type: String,
      default: '正在从数据库读取最新指标，请稍候'
    },
    compact: {
      type: Boolean,
      default: false
    }
  }
}
</script>

<style scoped>
.order-loading-panel {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  min-height: 220px;
  padding: 24px;
  border-radius: inherit;
  background: rgba(255, 255, 255, 0.78);
  color: #17243b;
  text-align: center;
  backdrop-filter: blur(1px);
}

.order-loading-panel.compact {
  min-height: 120px;
  gap: 10px;
  padding: 16px;
}

.loading-visual {
  display: none;
}

.compact .loading-visual {
  width: 34px;
  height: 34px;
}

.orbit {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid #edf0fb;
}

.orbit-one {
  border-top-color: #6267f2;
  animation: spin 0.95s linear infinite;
}

.orbit-two {
  display: none;
}

.center-dot {
  display: none;
}

.compact .center-dot {
  inset: 16px;
}

.loading-copy {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.loading-title {
  margin: 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: #8a93a6;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(42, 61, 115, 0.08);
}

.compact .loading-title {
  font-size: 12px;
}

.loading-detail {
  display: none;
}

.compact .loading-detail {
  font-size: 12px;
}

.progress-track {
  display: none;
}

.progress-bar {
  display: block;
  width: 38%;
  height: 100%;
  border-radius: inherit;
  background: #6267f2;
  box-shadow: none;
  animation: progressMove 1.25s ease-in-out infinite;
}

.pulse-row {
  display: none;
}

.pulse-row span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6267f2;
  opacity: 0.32;
  animation: pulse 1.1s ease-in-out infinite;
}

.pulse-row span:nth-child(2) {
  animation-delay: 0.12s;
}

.pulse-row span:nth-child(3) {
  animation-delay: 0.24s;
}

.pulse-row span:nth-child(4) {
  animation-delay: 0.36s;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes progressMove {
  0% {
    transform: translateX(-110%);
  }
  50% {
    transform: translateX(75%);
  }
  100% {
    transform: translateX(230%);
  }
}

@keyframes pulse {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.28;
  }
  50% {
    transform: translateY(-5px);
    opacity: 0.9;
  }
}
</style>
