/**
 * 主题：浅色电商风（参考淘宝系：白底、浅灰、主色橙 #ff5000）
 * 使用 CSS 变量便于以后微调
 */
:root {
  --bg-page: #f4f4f4;
  --bg-card: #ffffff;
  --bg-subtle: #fafafa;
  --bg-input: #ffffff;
  --border: #e8e8e8;
  --border-light: #f0f0f0;
  --text: #3c3c3c;
  --text-secondary: #666666;
  --text-muted: #999999;
  --text-placeholder: #bfbfbf;
  --brand: #ff5000;
  --brand-hover: #e64500;
  --brand-soft: #fff4f0;
  --brand-grad-start: #ff7528;
  --brand-grad-end: #ff5000;
  --success: #00a862;
  --warning: #ff8000;
  --danger: #e62822;
  --danger-soft: #fff1f0;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 2px 10px rgba(0, 0, 0, 0.08);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.06);
  --radius: 12px;
  --radius-lg: 16px;
  --media-placeholder: #ebebeb;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, "Noto Sans SC", sans-serif;
  background: var(--bg-page);
  color: var(--text);
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  color: var(--brand-hover);
  text-decoration: underline;
}

.container {
  max-width: 1160px;
  margin: 0 auto;
  padding: 16px;
}

header.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #ffffff;
  box-shadow: var(--shadow-sm);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1160px;
  margin: 0 auto;
  padding: 10px 16px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--text);
}

.nav-brand span {
  font-size: 18px;
}

.nav-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: contain;
  background: linear-gradient(145deg, #ffe8dc 0%, #ffd0b8 100%);
  border: 1px solid var(--border-light);
}

.nav-links {
  display: flex;
  gap: 8px;
  align-items: center;
}

.nav-user {
  margin-left: 12px;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.nav-link {
  padding: 8px 14px;
  border-radius: 4px;
  font-size: 14px;
  color: var(--text-secondary);
}

.nav-link.active,
.nav-link:hover {
  background: var(--brand-soft);
  color: var(--brand);
  text-decoration: none;
}

.nav-mobile-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 22px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.5fr);
  gap: 32px;
  align-items: center;
  padding-top: 16px;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-img {
  width: 80px;
  height: 80px;
  border-radius: 16px;
  object-fit: contain;
  background: linear-gradient(145deg, #ffffff 0%, #fff4f0 100%);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.hero h1 {
  font-size: 32px;
  margin: 0 0 8px;
  font-weight: 700;
  color: var(--text);
}

.hero p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.6;
}

.carousel {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  background: var(--bg-card);
}

.carousel-slide {
  display: none;
}

.carousel-slide.active {
  display: block;
}

.carousel img {
  width: 100%;
  height: 260px;
  object-fit: cover;
  display: block;
}

.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 34px;
  height: 34px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.carousel-btn:hover {
  color: var(--brand);
  border-color: var(--brand);
}

.carousel-btn.prev {
  left: 10px;
}

.carousel-btn.next {
  right: 10px;
}

.carousel-dots {
  position: absolute;
  bottom: 12px;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: center;
  gap: 8px;
}

.carousel-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.15);
  cursor: pointer;
}

.carousel-dot.active {
  background: var(--brand);
  width: 20px;
  border-radius: 4px;
}

.section {
  margin-top: 40px;
}

.section h1 {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

.section h2 {
  margin: 0 0 12px;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.section-subtitle {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 14px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.card h3 {
  margin-top: 0;
  margin-bottom: 8px;
  font-size: 16px;
  color: var(--text);
}

.card p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
}

.form-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.form-row label {
  font-size: 14px;
  color: var(--text-secondary);
}

.form-row input,
.form-row textarea,
.form-row select {
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 10px 12px;
  background: var(--bg-input);
  color: var(--text);
  font-size: 14px;
}

.form-row input::placeholder,
.form-row textarea::placeholder {
  color: var(--text-placeholder);
}

.form-row input:focus,
.form-row textarea:focus,
.form-row select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(255, 80, 0, 0.12);
}

.form-row small {
  color: var(--text-muted);
  font-size: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 20px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  transition: border-color 0.15s, color 0.15s;
}

.btn:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.btn.primary {
  background: linear-gradient(180deg, var(--brand-grad-start), var(--brand-grad-end));
  border-color: var(--brand);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(255, 80, 0, 0.25);
}

.btn.primary:hover {
  background: linear-gradient(180deg, #ff8750, var(--brand-hover));
  color: #ffffff;
  text-decoration: none;
}

.btn.small {
  padding: 4px 10px;
  font-size: 12px;
}

.message-list {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message-item {
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
}

.message-item-header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
}

.message-item-content {
  margin-top: 6px;
  font-size: 14px;
  color: var(--text);
}

.footer {
  margin-top: 40px;
  padding: 20px 16px;
  text-align: center;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  background: var(--bg-subtle);
}

.form-inline {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.form-inline input {
  flex: 1;
}

.chip-list {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 4px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
}

.chip button {
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
}

.form-row.full-width {
  grid-column: 1 / -1;
}

.filter-row {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.products-api-status {
  margin: 0 0 14px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-secondary);
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  min-height: 8px;
}

#product-list.product-grid {
  position: relative;
  z-index: 0;
}

.product-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.product-media {
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--media-placeholder);
}

.product-media img,
.product-media video {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
}

.product-media {
  position: relative;
}

.product-media.product-media-clickable {
  cursor: pointer;
}

.media-play-btn {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.35));
  border: none;
  cursor: pointer;
  color: #ffffff;
}

.media-play-btn-icon {
  width: 52px;
  height: 52px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.media-play-btn-icon span {
  display: block;
  margin-left: 3px;
  width: 0;
  height: 0;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-left: 16px solid #ffffff;
}

#viewer-section .product-media {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding-left: max(0px, env(safe-area-inset-left, 0px));
  padding-right: max(0px, env(safe-area-inset-right, 0px));
}

#viewer-section .product-media.viewer-media-fit .viewer-video-shell {
  box-sizing: border-box;
  width: auto;
  max-width: 100%;
  margin: 0 auto;
  aspect-ratio: 16 / 9;
  max-height: min(85vh, 92vw);
  max-height: min(85dvh, 92vw);
  background: var(--media-placeholder);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: min(180px, 85vh);
  position: relative;
}

.viewer-video-decode-hint {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  padding: 16px;
  text-align: center;
  font-size: 14px;
  line-height: 1.55;
  color: var(--danger);
  background: rgba(255, 255, 255, 0.96);
  z-index: 2;
  border: 1px solid var(--border);
}
.viewer-video-decode-hint.is-visible {
  display: flex;
}

#viewer-section .product-media.viewer-media-fit .viewer-video-shell video {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

#viewer-section .product-media.viewer-media-fit img {
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: min(85vh, 92vw);
  max-height: min(85dvh, 92vw);
  object-fit: contain;
  display: block;
}

.product-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.product-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.qrcode-container {
  width: 88px;
  height: 88px;
}

.auth-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.form-msg {
  margin-top: 8px;
  font-size: 13px;
}

.form-msg.error {
  color: var(--danger);
}

.form-msg.success {
  color: var(--success);
}

.table-wrapper table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table-wrapper th,
.table-wrapper td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
}

.table-wrapper th {
  text-align: left;
  color: var(--text-secondary);
  font-weight: 500;
  background: var(--bg-subtle);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.badge.admin {
  border-color: rgba(255, 80, 0, 0.45);
  color: var(--brand);
  background: var(--brand-soft);
}

.badge.user {
  border-color: rgba(0, 168, 98, 0.35);
  color: var(--success);
}

@media (max-width: 900px) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
  }

  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .auth-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .nav-mobile-toggle {
    display: block;
  }

  .nav-links {
    position: absolute;
    top: 56px;
    right: 10px;
    flex-direction: column;
    background: #ffffff;
    padding: 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    display: none;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-user {
    display: none;
  }

  .hero {
    padding-top: 10px;
  }

  .grid-3 {
    grid-template-columns: minmax(0, 1fr);
  }

  .product-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
