/**
 * 账单管理页面样式 - V21 CSS变量体系
 */
@import "../../styles/global.css";

.xx-billing-page {
  max-width: 800px;
  margin: 0 auto;
  padding: var(--space-2xl) var(--space-lg);
}

/* 订阅概览 */
.xx-billing-overview {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  margin-bottom: var(--space-lg);
  box-shadow: var(--shadow-sm);
}

.xx-billing-overview h2 {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  margin: 0 0 var(--space-lg);
}

.xx-overview-details {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-lg);
}

@media (max-width: 640px) {
  .xx-overview-details {
    grid-template-columns: 1fr;
  }
}

.xx-overview-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.xx-label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  font-weight: var(--font-weight-medium);
}

.xx-value {
  font-size: var(--font-size-md);
  color: var(--text-primary);
  font-weight: var(--font-weight-semibold);
}

/* 自动续费 */
.xx-billing-auto-renew {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  box-shadow: var(--shadow-sm);
}

.xx-billing-auto-renew h2 {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  margin: 0 0 var(--space-lg);
}

.xx-auto-renew-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
}

.xx-auto-renew-info {
  flex: 1;
}

.xx-auto-renew-title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin: 0 0 var(--space-xs);
}

.xx-auto-renew-desc {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin: 0;
  line-height: var(--line-height-base);
}

/* ── ToggleSwitch 组件 ───────────────────────────────── */
.xx-toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 44px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 12px;
  background: var(--color-gray-300);
  cursor: pointer;
  transition: background var(--transition-fast) ease;
  flex-shrink: 0;
}

.xx-toggle-switch.checked {
  background: var(--primary-color);
}

.xx-toggle-switch.loading {
  opacity: 0.65;
  cursor: not-allowed;
}

.xx-toggle-switch-handle {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg-primary);
  box-shadow: var(--shadow-xs);
  transition: transform var(--transition-fast) ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.xx-toggle-switch.checked .xx-toggle-switch-handle {
  transform: translateX(20px);
}

.xx-toggle-switch-inner {
  position: absolute;
  width: 100%;
  text-align: center;
  font-size: 0;
  /* 文字不显示，仅保留 aria 语义 */
}

.xx-toggle-switch-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--primary-color);
  border-top-color: transparent;
  border-radius: 50%;
  animation: xx-toggle-spin 0.6s linear infinite;
}

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

/* ── Spinner 组件 ───────────────────────────────── */
.xx-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-2xl) 0;
}

.xx-spinner-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary-color);
  animation: xx-spinner-bounce 1.2s ease-in-out infinite;
}

.xx-spinner-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.xx-spinner-dot:nth-child(3) {
  animation-delay: 0.3s;
}

.xx-spinner--small .xx-spinner-dot {
  width: 6px;
  height: 6px;
}

@keyframes xx-spinner-bounce {
  0%,
  80%,
  100% {
    transform: scale(0.6);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

@media (max-width: 768px) {
  .xx-billing-table {
    font-size: var(--font-size-sm);
  }

  .xx-billing-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm);
  }
}

@media (max-width: 480px) {
  .xx-billing-table {
    font-size: var(--font-size-sm);
  }

  .xx-billing-row {
    padding: var(--space-sm) var(--space-xs);
  }
}
