/**
 * MangaDream AI 页面样式
 * 背景 #1a1a1a，卡片 #242424 边框 #333，主按钮 #4f46e5，模块间距 24px
 */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  min-height: 100vh;
  background-color: #1a1a1a;
  color: #f0f0f0;
  font-family: system-ui, -apple-system, sans-serif;
}

#page-wrap {
  width: 100%;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  padding: 0 16px 24px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 24px;
}

/* ---------- 1. 顶部标题区 ---------- */
.header {
  margin-bottom: 48px;
  margin-top: 0;
  padding-top: 0;
}

.header__top {
  position: relative;
}

.header__brand {
  text-align: center;
}

.header__title {
  margin: 0 0 8px 0;
  font-size: 32px;
  font-weight: bold;
  color: #ff9933;
  text-align: center;
}

.header__subtitle {
  margin: 0 0 12px 0;
  font-size: 16px;
  color: #b0b0b0;
  text-align: center;
}

.header__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin-top: 12px;
}

.tag {
  display: inline-block;
  padding: 6px 12px;
  background-color: #ff9933;
  color: #fff;
  font-size: 14px;
  border-radius: 2px;
}

.nav {
  margin-top: 4px;
  margin-bottom: 32px;
  display: flex;
  justify-content: center;
  gap: 32px;
}

.nav__link {
  color: #ffe9b3;
  font-size: 32px;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
}

.nav__link:hover {
  background-color: #333;
}

.header-user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  position: absolute;
  top: 0;
  right: 0;
}

.header-user__login-btn {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

.header-user__avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid #444;
}

.header-user__name {
  font-size: 14px;
  color: #e0e0e0;
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-user__popover {
  position: absolute;
  top: 40px;
  right: 0;
  padding: 8px 0;
  background-color: #242424;
  border-radius: 8px;
  border: 1px solid #444;
  font-size: 13px;
  color: #e0e0e0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  min-width: 160px;
  z-index: 1002;
}

.header-user__popover-item {
  padding: 6px 14px;
  white-space: nowrap;
}

.header-user__popover-item--muted {
  color: #bbbbbb;
  font-size: 12px;
}

.header-user__popover-divider {
  height: 1px;
  margin: 4px 0;
  background-color: #333;
}

.header-user__logout-btn {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: #e0e0e0;
  font-size: 13px;
  padding: 6px 14px;
  cursor: pointer;
}

.header-user__logout-btn:hover {
  background-color: #333;
}

/* ---------- 2. 顶部上传区（卡片） ---------- */
.generator {
  background-color: #242424;
  border: 1px solid #333;
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-bottom: 0;
}

.generator__intro {
  margin: 0;
  font-size: 18px;
  color: #e0e0e0;
  text-align: center;
  line-height: 1.5;
  width: 100%;
}

.generator__row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.generator__row--upload { align-items: center; gap: 12px; }

.upload-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 140px;
  min-height: 120px;
  padding: 20px 28px;
  background-color: #242424;
  color: #b0b0b0;
  border: 2px dashed #333;
  border-radius: 12px;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.upload-btn__input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.upload-btn__plus { font-size: 36px; font-weight: 300; line-height: 1; color: #999; user-select: none; }
.upload-btn__label { font-size: 15px; color: #b0b0b0; user-select: none; }

.upload-btn:hover {
  background-color: #2a2a2a;
  border-color: #444;
  color: #c0c0c0;
}

.upload-btn:hover .upload-btn__plus,
.upload-btn:hover .upload-btn__label { color: #c0c0c0; }

.file-hint { font-size: 14px; color: #999; }

/* 上传图片预览：居中；下方按钮并排 */
.upload-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
}

.upload-preview__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: center;
}

.upload-preview__img {
  display: block;
  width: 200px;
  height: 280px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid #333;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  margin-left: auto;
  margin-right: auto;
}

.upload-preview__actions .btn {
  height: 36px;
  padding: 0 16px;
  font-size: 14px;
  border-radius: 8px;
}

/* ---------- 按钮 ---------- */
.btn {
  padding: 8px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.btn--secondary {
  background-color: #333;
  color: #e0e0e0;
  border: 1px solid #444;
}

.btn--secondary:hover { background-color: #444; }

.btn--outline {
  background: transparent;
  color: #a0a0a0;
  border: 1px solid #555;
}

.btn--outline:hover {
  background-color: #333;
  color: #e0e0e0;
  border-color: #666;
}

.btn--primary {
  background-color: #4f46e5;
  color: #fff;
}

.btn--primary:hover { background-color: #4338ca; }

.btn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

.loading-indicator {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #d0d0d0;
}

.loading-indicator__spinner {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: #ff9933;
  animation: mangadream-spin 0.7s linear infinite;
}

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

.generator__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-start;
}

/* ---------- 2.5 生成结果区 ---------- */
.result-section { margin-bottom: 0; }

.result-section__title {
  margin: 0 0 16px 0;
  font-size: 18px;
  font-weight: bold;
  color: #f0f0f0;
}

.result-section__wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background-color: #242424;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid #333;
}

.result-section__link {
  display: block;
  cursor: pointer;
}

.result-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
}

.result-row__col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.result-row__label {
  font-size: 13px;
  color: #bbbbbb;
  margin-bottom: 4px;
}

.result-row__img-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #333;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  background-color: #1f1f1f;
  width: 100%;
  /* 预留高度，避免图片加载前缩略图区域塌陷导致“变很小” */
  min-height: 320px;
  max-height: 560px;
}

.result-row__img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 100%;
  object-fit: contain; /* 竖图/横图都不裁切，避免偏左 */
}

.result-row__img-wrap--clickable {
  cursor: pointer;
  transition: box-shadow 0.2s ease;
}

.result-row__img-wrap--clickable:hover {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

/* ---------- 图片预览弹窗 ---------- */
.image-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 1001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.image-preview-modal__backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.85);
  cursor: pointer;
}

.image-preview-modal__box {
  position: relative;
  max-width: 95vw;
  max-height: 95vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-preview-modal__close {
  position: absolute;
  top: -40px;
  right: 0;
  width: 36px;
  height: 36px;
  font-size: 28px;
  line-height: 1;
  color: #f0f0f0;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  z-index: 2;
}

.image-preview-modal__close:hover { background: rgba(255, 255, 255, 0.25); }

.image-preview-modal__box > a {
  display: block;
  max-width: 95vw;
  max-height: 95vh;
}

.image-preview-modal__box img {
  max-width: 95vw;
  max-height: 95vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
}

/* ---------- 3. 选择风格模块 ---------- */
.inspiration {
  margin-top: 0;
  background-color: #242424;
  border: 1px solid #333;
  border-radius: 12px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.inspiration__title {
  margin: 48px 0 16px 0;
  font-size: 32px;
  font-weight: bold;
  color: #f0f0f0;
  text-align: center;
  width: 100%;
}

.inspiration__desc {
  margin: 0 0 48px 0;
  font-size: 28px;
  color: #b0b0b0;
  text-align: center;
  width: 100%;
}

.inspiration__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  width: 100%;
  max-width: 1200px;
}

.inspiration-card {
  width: 100%;
  height: 280px;
  background-color: #2a2a2a;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border: 1px solid #333;
}

.inspiration-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.inspiration-card__img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: cover;
  background-color: #333;
}

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.6);
}

.modal__box {
  position: relative;
  background-color: #242424;
  border: 1px solid #333;
  padding: 24px;
  border-radius: 12px;
  min-width: 280px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.modal__text {
  margin: 0 0 20px 0;
  font-size: 16px;
  color: #f0f0f0;
}

.modal__actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* ---------- 登录弹窗 ---------- */
.login-modal__title {
  margin: 0 0 12px 0;
  font-size: 18px;
  font-weight: bold;
}

.login-modal__desc {
  margin: 0 0 16px 0;
  font-size: 14px;
  color: #c0c0c0;
}

.login-modal__google-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  background-color: #fff;
  color: #333;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 14px;
}

.login-modal__google-btn:hover {
  background-color: #f3f3f3;
}

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .inspiration__grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .upload-preview__img {
    width: 100%;
    max-width: 200px;
    height: 280px;
  }
  .result-section__img {
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: 560px;
  }
  .inspiration__grid { grid-template-columns: 1fr; }
  .inspiration__title { font-size: 24px; }
  .inspiration__desc { font-size: 18px; }
}
