/* 我的界面样式 */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

.profile-container {
  width: 100%;
  height: 100vh;
  background: #f5f5f5;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.profile-header {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  background: white;
  border-bottom: 1px solid #e5e5e5;
  position: sticky;
  top: 0;
  z-index: 100;
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  color: #667eea;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 8px;
  transition: background 0.2s;
}

.back-btn:hover {
  background: rgba(102, 126, 234, 0.1);
}

.profile-content {
  padding: 16px 20px;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  overflow: hidden;
  height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
}

.page-title {
  margin: 0 0 20px 0;
  font-size: 28px;
  font-weight: 700;
  color: #1f2937;
  padding-bottom: 12px;
  border-bottom: 3px solid #667eea;
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-title::before {
  content: '';
  width: 4px;
  height: 28px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 2px;
}

.profile-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  align-items: start;
  height: calc(100% - 60px);
  overflow: hidden;
}

.profile-left {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
}

.profile-right {
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
  overflow-y: auto;
}

.history-section {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.history-section .ai-history-container {
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.purchase-section {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.purchase-container {
  flex: 1;
  max-height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
}

.profile-section {
  background: white;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  flex-shrink: 0;
}

.section-title {
  margin: 0 0 16px 0;
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
  padding-bottom: 10px;
  border-bottom: 2px solid #f0f0f0;
}

.profile-info {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

.avatar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.avatar-preview {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid #e5e5e5;
  background: #f9fafb;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-upload-btn {
  padding: 8px 16px;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.avatar-upload-btn:hover {
  background: #5568d3;
  transform: translateY(-1px);
}

.info-form {
  width: 100%;
}

.form-item {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  font-size: 14px;
  color: #1f2937;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.form-input:focus {
  outline: none;
  border-color: #667eea;
}

.form-input[readonly] {
  background: #f9fafb;
  color: #6b7280;
  cursor: not-allowed;
}

.save-btn {
  padding: 10px 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 8px;
}

.save-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.points-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
}

.points-display {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.points-label {
  font-size: 14px;
  color: #6b7280;
}

.points-value {
  font-size: 28px;
  font-weight: 700;
  color: #667eea;
}

.points-unit {
  font-size: 14px;
  color: #6b7280;
}

.recharge-btn {
  padding: 8px 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.recharge-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.ai-history-container {
  min-height: 200px;
  max-height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
}

.loading-state,
.empty-state {
  text-align: center;
  padding: 40px;
  color: #9ca3af;
  font-size: 14px;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  padding: 4px;
  overflow: visible;
}

.history-item {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #f9fafb;
  aspect-ratio: 1;
  border: 2px solid #e5e5e5;
  transition: all 0.3s ease;
}

.history-item:hover {
  border-color: #667eea;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
  transform: translateY(-2px);
}

.history-item.rendering {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f0f0f0 0%, #e5e5e5 100%);
}

.history-item.rendering .rendering-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* 模糊预览图 */
.history-item-preview {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(8px) brightness(0.7);
  transform: scale(1.1); /* 防止模糊边缘漏出 */
}

.history-item-preview.failed-preview {
  filter: blur(8px) brightness(0.5) grayscale(0.5);
}

/* 加载中蒙层 */
.history-item-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 2;
}

.loading-spinner-container {
  width: 48px;
  height: 48px;
  position: relative;
}

.loading-spinner {
  width: 100%;
  height: 100%;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.loading-status-text {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  padding: 4px 12px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  backdrop-filter: blur(4px);
}

/* rendering 和 queued 状态共用基础样式 */
.history-item.rendering,
.history-item.queued {
  overflow: hidden;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.history-item.failed {
  overflow: hidden;
  background: linear-gradient(135deg, #2d1b1b 0%, #1a1a1a 100%);
}

.history-item.failed .failed-content {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  z-index: 2;
  background: rgba(0, 0, 0, 0.4);
}

.history-item.failed .failed-icon {
  font-size: 32px;
}

.history-item.failed .failed-text {
  font-size: 14px;
  font-weight: 600;
  color: #fca5a5;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

/* 重新生图按钮 */
.history-item.failed .retry-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 8px 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.history-item.failed .retry-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.history-item.failed .retry-btn:active {
  transform: translateY(0);
}

.history-item.failed .retry-btn svg {
  flex-shrink: 0;
}

/* 已重试标记 */
.history-item.failed .retried-badge {
  margin-top: 8px;
  padding: 4px 12px;
  background: rgba(100, 100, 100, 0.6);
  color: #999;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
}

.history-item-time {
  position: absolute;
  bottom: 4px;
  left: 4px;
  right: 4px;
  font-size: 10px;
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
  padding: 2px 6px;
  border-radius: 4px;
  text-align: center;
  font-weight: 500;
  z-index: 3;
  backdrop-filter: blur(4px);
}

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

.history-item-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.history-item-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s;
}

.history-item:hover .history-item-overlay {
  opacity: 1;
}

/* 操作按钮组 */
.history-item-actions {
  display: flex;
  gap: 12px;
}

.history-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.95);
  color: #667eea;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  transform: translateY(10px);
  opacity: 0;
}

.history-item:hover .history-action-btn {
  transform: translateY(0);
  opacity: 1;
}

.history-item:hover .history-action-btn:nth-child(2) {
  transition-delay: 0.05s;
}

.history-action-btn span {
  font-size: 12px;
  font-weight: 600;
}

.history-action-btn:hover {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  transform: translateY(-2px) scale(1.05) !important;
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.history-action-btn:active {
  transform: translateY(0) scale(0.98) !important;
}

/* 图片预览弹窗 */
.image-preview-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.image-preview-modal.show {
  opacity: 1;
}

.image-preview-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(8px);
}

.image-preview-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.image-preview-modal.show .image-preview-content {
  transform: scale(1);
}

.image-preview-content img {
  max-width: 100%;
  max-height: 85vh;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.image-preview-close {
  position: absolute;
  top: -50px;
  right: 0;
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: white;
  font-size: 28px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.image-preview-close:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.1);
}

.image-preview-download-btn {
  position: absolute;
  bottom: -60px;
  right: 50%;
  transform: translateX(50%);
  width: 50px;
  height: 50px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.5);
}

.image-preview-download-btn:hover {
  transform: translateX(50%) scale(1.1);
  box-shadow: 0 6px 25px rgba(102, 126, 234, 0.6);
}

.rendering-text {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
}

/* 退出登录按钮 */
.logout-btn {
  width: 100%;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
}

.logout-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* 响应式设计 */
@media (max-width: 1024px) {
  .profile-layout {
    grid-template-columns: 1fr;
  }
  
  .history-section {
    height: auto;
    min-height: 400px;
  }
}

/* 购买记录样式 */
.purchase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 20px;
  padding: 12px;
  overflow-y: auto;
  max-height: 100%;
}

.purchase-item {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  background: white;
  aspect-ratio: 0.82;
  border: 1px solid rgba(102, 126, 234, 0.08);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  box-shadow: 
    0 4px 20px rgba(102, 126, 234, 0.08),
    0 2px 8px rgba(0, 0, 0, 0.04);
}

.purchase-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 40%, #f093fb 70%, #667eea 100%);
  background-size: 200% 100%;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.purchase-item::after {
  content: '';
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
  border-radius: 50%;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 1;
}

.purchase-item:hover {
  transform: translateY(-8px);
  border-color: rgba(102, 126, 234, 0.2);
  box-shadow: 
    0 24px 48px rgba(102, 126, 234, 0.18),
    0 12px 24px rgba(0, 0, 0, 0.06);
}

.purchase-item:hover::before {
  opacity: 1;
  animation: shimmer 2s ease-in-out infinite;
}

.purchase-item:hover::after {
  opacity: 1;
  transform: scale(1.2);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.purchase-item.deleted {
  opacity: 0.5;
  filter: grayscale(0.5);
}

.purchase-item-image {
  width: 100%;
  height: 62%;
  object-fit: contain;
  background: linear-gradient(145deg, #f8fafc 0%, #eef2f7 50%, #e8ecf2 100%);
  padding: 16px;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.purchase-item:hover .purchase-item-image {
  transform: scale(1.08);
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.1));
}

.purchase-item-placeholder {
  width: 100%;
  height: 62%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #f8fafc 0%, #eef2f7 100%);
  color: #9ca3af;
  font-size: 32px;
}

.purchase-item-info {
  padding: 14px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%);
  border-top: 1px solid rgba(102, 126, 234, 0.06);
  position: relative;
}

.purchase-item-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(180deg, rgba(102, 126, 234, 0.9) 0%, rgba(118, 75, 162, 0.95) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all 0.35s ease;
  z-index: 10;
  backdrop-filter: blur(6px);
}

.purchase-item:hover .purchase-item-overlay {
  opacity: 1;
}

.purchase-item-add-btn {
  padding: 12px 24px;
  background: white;
  color: #667eea;
  border: none;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  transform: translateY(10px);
  opacity: 0;
}

.purchase-item:hover .purchase-item-add-btn {
  transform: translateY(0);
  opacity: 1;
}

.purchase-item-add-btn:hover {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  transform: scale(1.08) !important;
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
}

.purchase-item-add-btn:active {
  transform: scale(1) !important;
}

.purchase-item-add-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.purchase-item-name {
  font-size: 14px;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.2px;
  line-height: 1.3;
}

.purchase-item-category {
  font-size: 11px;
  color: #6b7280;
  margin-bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);
  padding: 3px 10px;
  border-radius: 12px;
  width: fit-content;
}

.purchase-item-category::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 50%;
  flex-shrink: 0;
}

.purchase-item-price {
  font-size: 13px;
  font-weight: 800;
  color: transparent;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  background-clip: text;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  letter-spacing: -0.3px;
}

.purchase-item-price::before {
  content: '💎';
  font-size: 11px;
}

.purchase-item-deleted-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
  z-index: 5;
  animation: pulse-badge 2s ease-in-out infinite;
}

@keyframes pulse-badge {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.rendering-text {
  font-size: 14px;
  font-weight: 600;
  color: #667eea;
}

@media (max-width: 768px) {
  .profile-content {
    padding: 16px;
  }
  
  .profile-layout {
    gap: 16px;
  }
  
  .profile-left {
    gap: 16px;
  }
  
  .profile-section {
    padding: 16px;
  }
  
  .avatar-preview {
    width: 100px;
    height: 100px;
  }
}

