/**
 * API组件通用样式
 * 包含加载状态、错误状态、通知等
 */

/* ==================== 加载状态 ==================== */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  min-height: 300px;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #333;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-state p {
  margin-top: 20px;
  font-size: 16px;
  color: #666;
}

/* ==================== 错误状态 ==================== */
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  min-height: 300px;
}

.error-state p {
  font-size: 18px;
  color: #666;
  margin-bottom: 24px;
  text-align: center;
}

.error-state .btn-reload {
  padding: 12px 32px;
  background: #000;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 16px;
  cursor: pointer;
  transition: opacity 0.3s ease;
}

.error-state .btn-reload:hover {
  opacity: 0.8;
}

/* ==================== 空状态 ==================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  min-height: 300px;
}

.empty-state p {
  font-size: 18px;
  color: #999;
}

/* ==================== 通知组件 ==================== */
.notification-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.notification {
  min-width: 300px;
  max-width: 500px;
  padding: 16px 20px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transform: translateX(400px);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 15px;
  line-height: 1.5;
  word-wrap: break-word;
}

.notification.show {
  transform: translateX(0);
}

.notification-success {
  background: #4caf50;
  color: #fff;
}

.notification-error {
  background: #f44336;
  color: #fff;
}

.notification-warning {
  background: #ff9800;
  color: #fff;
}

.notification-info {
  background: #2196f3;
  color: #fff;
}

/* ==================== 卡片骨架屏 ==================== */
.skeleton-card {
  width: 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
}

.skeleton-image {
  width: 100%;
  height: 326px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

.skeleton-text {
  height: 20px;
  margin: 12px 0;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: 4px;
}

.skeleton-text.title {
  height: 30px;
  width: 80%;
}

.skeleton-text.subtitle {
  height: 18px;
  width: 60%;
}

@keyframes skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ==================== 分页组件 ==================== */
.pagination-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 60px 0 40px;
  gap: 8px;
}

.pagination-list {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 8px;
}

.page-item {
  display: inline-block;
}

.page-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid #e0e0e0;
  background: #fff;
  color: #333;
  text-decoration: none;
  font-size: 15px;
  border-radius: 4px;
  transition: all 0.3s ease;
  cursor: pointer;
}

.page-link:hover {
  border-color: #333;
  background: #f5f5f5;
}

.page-item.active .page-link {
  background: #000;
  color: #fff;
  border-color: #000;
}

.page-item.disabled .page-link {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ==================== Tab切换组件 ==================== */
.tab-container {
  display: flex;
  gap: 40px;
  margin-bottom: 40px;
  border-bottom: 1px solid #e0e0e0;
}

.tab {
  padding: 12px 0;
  font-size: 20px;
  color: #999;
  cursor: pointer;
  position: relative;
  transition: color 0.3s ease;
  border: none;
  background: transparent;
}

.tab:hover {
  color: #333;
}

.tab.active {
  color: #000;
  font-weight: 500;
}

.tab.active::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 100%;
  height: 3px;
  background: #000;
}

/* ==================== 卡片悬停效果 ==================== */
.card-hover-effect {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card-hover-effect:hover {
  transform: translateY(-8px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* ==================== 响应式适配 ==================== */
@media (max-width: 768px) {
  .notification-container {
    top: 10px;
    right: 10px;
    left: 10px;
  }

  .notification {
    min-width: auto;
    width: 100%;
  }

  .pagination-list {
    flex-wrap: wrap;
  }

  .page-link {
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    font-size: 14px;
  }

  .tab-container {
    gap: 20px;
  }

  .tab {
    font-size: 16px;
  }
}

/* ==================== 图片懒加载占位 ==================== */
.lazy-image {
  background: #f5f5f5;
  position: relative;
  overflow: hidden;
}

.lazy-image::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  animation: lazy-shimmer 2s infinite;
}

.lazy-image.loaded::before {
  display: none;
}

@keyframes lazy-shimmer {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

/* ==================== 淡入动画 ==================== */
.fade-in {
  animation: fadeIn 0.6s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
