<script setup lang="ts">
withDefaults(defineProps<{ label?: string; compact?: boolean }>(), {
  label: "加载中",
  compact: false
});
</script>

<template>
  <div class="loading-state" :data-compact="compact ? 'true' : 'false'" role="status" aria-live="polite">
    <span class="loading-spinner" aria-hidden="true" />
    <span>{{ label }}</span>
  </div>
</template>

<style scoped>
.loading-state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #64748b;
  font-size: 13px;
  line-height: 1.4;
}

.loading-state[data-compact="false"] {
  min-height: 96px;
  width: 100%;
}

.loading-state[data-compact="true"] {
  min-height: 0;
}

.loading-spinner {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  border: 2px solid #bae6fd;
  border-top-color: #0e7490;
  border-radius: 999px;
  animation: loading-state-spin 0.8s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .loading-spinner { animation: none; }
}
</style>
