:root {
  --primary-color: #7c3aed;
  --primary-hover: #6d28d9;
  --background: #f5f3ff;
  --text-primary: #1f2937;
  --text-secondary: #4b5563;
  --accent-1: #ec4899;
  --accent-2: #10b981;
  --accent-3: #3b82f6;
  --danger: #dc2626;
  --gradient-start: #c4b5fd;
  --gradient-end: #a78bfa;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Inter", sans-serif;
  background: linear-gradient(
    135deg,
    var(--gradient-start),
    var(--gradient-end)
  );
  color: var(--text-primary);
  min-height: 100vh;
  padding: 2rem;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
}

.glass-panel {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  border-radius: 24px;
  padding: 2rem;
  box-shadow: 0 8px 32px rgba(124, 58, 237, 0.12);
  margin-bottom: 2rem;
  transition: all 0.3s ease;
}

.glass-panel:hover {
  box-shadow: 0 15px 50px rgba(0, 0, 0, 0.3);
}

h1 {
  text-align: center;
  margin-bottom: 2rem;
  font-size: 2.5rem;
  font-weight: 600;
  background: linear-gradient(135deg, var(--primary-color), var(--accent-1));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.input-panel {
  position: relative;
  margin-bottom: 2rem;
  display: flex;
  align-items: stretch;
  gap: 1rem;
}

.input-panel textarea {
  flex: 1;
  height: 60px;
  min-height: 60px;
  max-height: 200px;
  padding: 1rem;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  font-size: 1rem;
  line-height: 1.5;
  transition: all 0.3s ease;
  resize: none;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.input-panel textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.1);
  height: auto;
  white-space: pre-wrap;
  overflow-y: auto;
}

#generateBtn {
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 2rem;
  min-width: 120px;
  height: 50px;
  background: linear-gradient(135deg, var(--primary-color), var(--accent-1));
  color: white;
  border: none;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

#generateBtn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.2);
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  padding: 1rem;
}

.image-card {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  background: white;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.image-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.image-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(110deg, #ececec 8%, #f5f5f5 18%, #ececec 33%);
  background-size: 200% 100%;
  animation: shimmer 1.5s linear infinite;
  z-index: 1;
}

.image-wrapper img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
  transition: all 0.3s ease;
  opacity: 0;
  z-index: 2;
}

.image-wrapper img.loaded {
  opacity: 1;
}

.image-wrapper img.loaded + .image-placeholder {
  display: none;
}

.image-wrapper img:hover {
  transform: scale(1.02);
}

.card-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.95) 0%,
    rgba(0, 0, 0, 0.9) 50%,
    rgba(0, 0, 0, 0.8) 100%
  );
  padding: 0.75rem;
  z-index: 3;
}

.prompt-text {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.875rem;
  line-height: 1.4;
  margin-bottom: 0.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.image-actions button {
  padding: 0.5rem;
  border: none;
  border-radius: 6px;
  color: white;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.image-actions button:hover {
  filter: brightness(110%);
}

.delete-btn {
  background: var(--danger);
}
.download-btn {
  background: var(--accent-3);
}
.copy-btn {
  background: var(--accent-1);
}
.prompt-btn {
  background: var(--accent-2);
}

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  cursor: pointer;
}
.modal.show {
  opacity: 1;
}
.modal-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  cursor: default;
  background-color: #fff; /* 添加背景颜色以便更好地显示 */
  padding: 20px; /* 添加内边距以便更好地显示 */
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}
.modal-content img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.loading-spinner {
  display: none;
  width: 20px;
  height: 20px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  z-index: 2000;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  transform: translateX(120%);
  transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  backdrop-filter: blur(10px);
  max-width: 400px;
  color: var(--text-primary);
  font-weight: 500;
}

.toast.show {
  transform: translateX(0);
}

.toast-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.toast-message {
  font-size: 0.95rem;
  color: var(--text-primary);
  flex-grow: 1;
}

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(to right, var(--primary-color), var(--accent-1));
  border-radius: 0 0 12px 12px;
  transform-origin: left;
}

.confirm-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  background: white;
  padding: 1.5rem;
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 2000;
  backdrop-filter: blur(10px);
}

.confirm-toast.show {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

.confirm-message {
  margin-bottom: 1.5rem;
  color: var(--text-primary);
  font-size: 1.125rem;
  font-weight: 500;
}

.confirm-buttons {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
}

.confirm-btn {
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 500;
  letter-spacing: 0.3px;
}

.confirm-yes {
  background: #dc2626;
  color: white;
}

.confirm-yes:hover {
  background: #b91c1c;
}

.confirm-no {
  background: #e5e7eb;
  color: #374151;
}

.confirm-no:hover {
  background: #d1d5db;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.theme-toggle button {
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.main-content {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.style-filters {
  display: flex;
  gap: 0.5rem;
}

.filter-btn {
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.filter-btn.active {
  background: var(--primary-color);
  color: white;
}

/* 响应式布局优化 */
@media (max-width: 768px) {
  body {
    padding: 0.5rem;
  }

  .container {
    width: 100%;
    padding: 0;
  }

  .glass-panel {
    padding: 1rem;
    border-radius: 16px;
  }

  .input-panel {
    flex-direction: column;
    gap: 0.75rem;
  }

  #generateBtn {
    width: 100%;
    height: 45px;
    padding: 0.75rem;
  }

  .gallery {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    padding: 0.5rem;
  }

  .card-content {
    padding: 0.5rem;
  }

  .prompt-text {
    font-size: 0.75rem;
  }

  .image-actions button {
    font-size: 0.75rem;
    padding: 0.35rem;
  }

  .style-panel {
    padding: 1rem;
  }

  .preset-buttons {
    gap: 0.75rem;
    padding: 0.25rem 0;
    mask-image: linear-gradient(to right, black 90%, transparent 100%);
    -webkit-mask-image: linear-gradient(to right, black 90%, transparent 100%);
  }

  .preset-btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }

  .modal-content {
    width: auto;
    height: auto;
  }

}

/* 自定义滚动条样式 */
.preset-buttons {
  display: flex;
  gap: 1rem;
  padding: 0.5rem 0;
  overflow-x: auto;
  scroll-behavior: smooth;
  position: relative;
  -webkit-overflow-scrolling: touch;
}

/* 自定义滚动条样式 */
.preset-buttons::-webkit-scrollbar {
  height: 6px;
}

.preset-buttons::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 3px;
}

.preset-buttons::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 3px;
}

.preset-buttons::-webkit-scrollbar-thumb:hover {
  background: var(--primary-hover);
}

/* Firefox 滚动条样式 */
.preset-buttons {
  scrollbar-width: thin;
  scrollbar-color: var(--primary-color) rgba(0, 0, 0, 0.05);
}

/* 移动端优化 */
@media (max-width: 768px) {
  .preset-buttons {
    gap: 0.75rem;
    padding: 0.25rem 0;
    mask-image: linear-gradient(to right, black 90%, transparent 100%);
    -webkit-mask-image: linear-gradient(to right, black 90%, transparent 100%);
  }

  .preset-buttons::-webkit-scrollbar {
    display: none;
  }

  .preset-buttons {
    scrollbar-width: none;
  }
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* 预设风格面板 */
.style-panel {
  background: rgba(255, 255, 255, 0.5);
  border-radius: 16px;
  padding: 1.5rem;
  position: relative;
  margin-bottom: 1rem;
}

.style-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.style-header h3 {
  color: var(--text-secondary);
  font-size: 1.1rem;
  font-weight: 600;
}

.preset-btn {
  flex: 0 0 auto;
  padding: 0.75rem 1.5rem;
  white-space: nowrap;
  background: white;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  color: var(--text-primary);
  font-weight: 500;
  transition: all 0.2s ease;
  cursor: pointer;
}

.preset-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.preset-btn.active {
  background: var(--primary-color);
  color: white;
  border-color: transparent;
}
