/* ============================================
   电商商品AI生成平台 - 主样式表
   风格：极简黑白 · 灵动按钮 · 平滑动画
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --black: #000000;
  --white: #ffffff;
  --gray-100: #f5f5f5;
  --gray-200: #e8e8e8;
  --gray-300: #d0d0d0;
  --gray-400: #999999;
  --gray-500: #666666;
  --gray-600: #444444;
  --gray-700: #333333;
  --gray-800: #222222;
  --gray-900: #111111;
  --red: #e74c3c;
  --green: #27ae60;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
  --radius: 6px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--white);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
  animation: fadeIn 0.4s ease;
}

a { color: var(--black); text-decoration: none; transition: opacity var(--transition); }
a:hover { opacity: 0.7; }

img { max-width: 100%; height: auto; display: block; }

/* --- Typography --- */
h1, h2, h3, h4 { font-weight: 600; line-height: 1.3; color: var(--black); }
h1 { font-size: 1.8rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }

.text-muted { color: var(--gray-500); font-size: 0.9rem; }
.text-red { color: var(--red); }
.text-green { color: var(--green); }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* --- Layout --- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

.page-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Fade In Animation --- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

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

@keyframes checkPop {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes ripple {
  to { transform: scale(4); opacity: 0; }
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 24px;
  font-size: 0.95rem;
  font-weight: 500;
  font-family: var(--font);
  border: 1.5px solid var(--black);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--black);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
  user-select: none;
  white-space: nowrap;
}

.btn:hover {
  background: var(--black);
  color: var(--white);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Ripple effect on click */
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.3);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  margin: auto;
  transform: scale(0);
  opacity: 0;
}

.btn:active::after {
  animation: ripple 0.6s ease-out;
}

/* Button variants */
.btn-primary {
  background: var(--black);
  color: var(--white);
}

.btn-primary:hover {
  background: var(--gray-800);
  box-shadow: 0 4px 14px rgba(0,0,0,0.2);
}

.btn-outline {
  background: transparent;
  color: var(--black);
}

.btn-outline:hover {
  background: var(--black);
  color: var(--white);
}

.btn-sm {
  padding: 6px 16px;
  font-size: 0.85rem;
}

.btn-lg {
  padding: 14px 32px;
  font-size: 1.05rem;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
}

/* --- Form Elements --- */
.form-group {
  margin-bottom: 14px;
  animation: slideUp 0.3s ease;
}

.form-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.95rem;
  font-family: var(--font);
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--gray-800);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--black);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.08);
}

.form-input.error,
.form-select.error,
.form-textarea.error {
  border-color: var(--red);
  animation: shake 0.4s ease;
}

.form-input.error:focus,
.form-select.error:focus,
.form-textarea.error:focus {
  box-shadow: 0 0 0 3px rgba(231,76,60,0.15);
}

.form-textarea {
  min-height: 80px;
  resize: vertical;
}

.form-help {
  font-size: 0.8rem;
  color: var(--gray-500);
  margin-top: 4px;
}

.form-error {
  font-size: 0.8rem;
  color: var(--red);
  margin-top: 4px;
  display: none;
}

/* Radio & Checkbox */
.radio-group, .checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.radio-item, .checkbox-item {
  position: relative;
}

.radio-item input, .checkbox-item input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.radio-item label, .checkbox-item label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--white);
  color: var(--gray-600);
}

.radio-item input:checked + label,
.checkbox-item input:checked + label {
  border-color: var(--black);
  background: var(--black);
  color: var(--white);
}

.radio-item label:hover,
.checkbox-item label:hover {
  border-color: var(--gray-500);
}

/* "其他" text input */
.other-input {
  display: none;
  margin-top: 8px;
  animation: slideUp 0.25s ease;
}

.other-input.show {
  display: block;
}

/* --- Cards --- */
.card {
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 18px;
  transition: box-shadow var(--transition), transform var(--transition);
  animation: slideUp 0.35s ease;
}

.card:hover {
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--gray-200);
}

.card-title {
  font-weight: 600;
  font-size: 1.05rem;
}

/* --- Cards Grid --- */
.card-grid {
  display: grid;
  gap: 20px;
}

.card-grid-2 { grid-template-columns: repeat(2, 1fr); }
.card-grid-3 { grid-template-columns: repeat(3, 1fr); }
.card-grid-4 { grid-template-columns: repeat(4, 1fr); }

/* --- Stats Card --- */
.stat-card {
  text-align: center;
  padding: 20px;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--black);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--gray-500);
  margin-top: 4px;
}

/* --- Table --- */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
}

th {
  font-weight: 600;
  color: var(--gray-600);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--gray-100);
}

tr:hover td {
  background: var(--gray-100);
}

/* --- Navbar --- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 0 20px;
  animation: fadeIn 0.3s ease;
}

.navbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 50px;
}

.navbar-brand {
  font-weight: 800;
  font-size: 1.45rem;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.04em;
  position: relative;
  transition: all 0.3s ease;
  text-shadow: none;
}
.navbar-brand:hover {
  transform: scale(1.06);
  background: linear-gradient(135deg, #0f3460 0%, #e94560 50%, #1a1a2e 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

.navbar-nav {
  display: flex;
  align-items: center;
  gap: 20px;
  list-style: none;
}

.navbar-nav a {
  font-size: 0.9rem;
  color: var(--gray-600);
  padding: 6px 0;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
}

.navbar-nav a:hover,
.navbar-nav a.active {
  color: var(--black);
  border-bottom-color: var(--black);
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* --- Alert / Message --- */
.alert {
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  margin-bottom: 16px;
  animation: slideUp 0.3s ease;
  border: 1px solid;
}

.alert-success {
  background: #f0faf0;
  border-color: var(--green);
  color: #1a7a3a;
}

.alert-error {
  background: #fdf0ef;
  border-color: var(--red);
  color: #a93226;
}

.alert-info {
  background: var(--gray-100);
  border-color: var(--gray-300);
  color: var(--gray-700);
}

/* --- Loading / Spinner --- */
.spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--gray-300);
  border-top-color: var(--black);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

.spinner-sm { width: 16px; height: 16px; border-width: 2px; }
.spinner-lg { width: 40px; height: 40px; border-width: 3px; }

/* Loading overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(255,255,255,0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  animation: fadeIn 0.2s ease;
}

.loading-overlay .spinner {
  width: 44px;
  height: 44px;
  border-width: 3px;
}

.loading-overlay p {
  font-size: 0.95rem;
  color: var(--gray-500);
}

/* Skeleton loader */
.skeleton {
  background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}

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

.skeleton-box {
  width: 100%;
  height: 200px;
  margin-bottom: 12px;
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
  width: 80%;
}

.skeleton-text:last-child { width: 60%; }

/* --- Badge / Tag --- */
.badge {
  display: inline-block;
  padding: 2px 10px;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 20px;
  border: 1px solid var(--gray-300);
  color: var(--gray-600);
  background: var(--white);
}

.badge-black {
  background: var(--black);
  color: var(--white);
  border-color: var(--black);
}

.badge-green {
  background: var(--green);
  color: var(--white);
  border-color: var(--green);
}

.badge-red {
  background: var(--red);
  color: var(--white);
  border-color: var(--red);
}

.badge-yellow {
  background: #f59e0b;
  color: var(--white);
  border-color: #f59e0b;
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.4);
  display: none;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--white);
  border-radius: var(--radius);
  padding: 28px;
  width: 90%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  animation: fadeInScale 0.3s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--gray-500);
  transition: color var(--transition);
  border-radius: 50%;
}

.modal-close:hover {
  color: var(--black);
  background: var(--gray-100);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-200);
}

/* --- Image Preview --- */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.image-card {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow var(--transition);
  animation: fadeInScale 0.4s ease;
}

.image-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

.image-card img {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.image-card-body {
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.image-card-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--gray-600);
}

/* --- Typewriter --- */
.typewriter {
  display: inline;
}

.typewriter .char {
  animation: fadeIn 0.03s ease;
}

/* --- Payment Modal --- */
.payment-modal .qr-placeholder {
  width: 200px;
  height: 200px;
  margin: 20px auto;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--gray-500);
}

.payment-modal .amount-display {
  text-align: center;
  font-size: 1.8rem;
  font-weight: 700;
  margin: 12px 0;
}

/* Success animation */
.success-check {
  text-align: center;
  padding: 30px;
}

.success-check .check-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  background: var(--green);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: checkPop 0.5s ease;
}

.success-check .check-icon svg {
  width: 32px;
  height: 32px;
  fill: var(--white);
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-400);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  fill: var(--gray-300);
}

.empty-state p {
  font-size: 0.95rem;
}

/* --- Pagination --- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 20px;
}

.pagination a, .pagination span {
  padding: 6px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 0.85rem;
  transition: all var(--transition);
  color: var(--gray-600);
}

.pagination a:hover {
  border-color: var(--black);
  color: var(--black);
}

.pagination .active {
  background: var(--black);
  color: var(--white);
  border-color: var(--black);
}

/* --- Sidebar (Admin) --- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 220px;
  background: var(--gray-900);
  color: var(--white);
  padding: 20px 0;
  z-index: 50;
  animation: fadeIn 0.3s ease;
}

.sidebar-brand {
  padding: 0 20px 20px;
  font-weight: 800;
  font-size: 1.2rem;
  background: linear-gradient(135deg, #e8e8e8 0%, #ffffff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 10px;
  letter-spacing: 0.04em;
}

.sidebar-nav {
  list-style: none;
}

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.65);
  font-size: 0.9rem;
  transition: all var(--transition);
  border-left: 3px solid transparent;
}

.sidebar-nav li a:hover {
  color: var(--white);
  background: rgba(255,255,255,0.06);
}

.sidebar-nav li a.active {
  color: var(--white);
  background: rgba(255,255,255,0.08);
  border-left-color: var(--white);
}

.sidebar-nav li a svg {
  width: 18px;
  height: 18px;
  opacity: 0.7;
}

.admin-main {
  margin-left: 220px;
  min-height: 100vh;
  padding: 20px 30px;
  animation: fadeIn 0.3s ease;
}

/* --- Filter Bar --- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-bar .form-input,
.filter-bar .form-select {
  width: auto;
  min-width: 160px;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .card-grid-2, .card-grid-3, .card-grid-4 {
    grid-template-columns: 1fr;
  }
  .sidebar {
    width: 0;
    overflow: hidden;
  }
  .admin-main {
    margin-left: 0;
    padding: 16px;
  }
  .navbar-inner {
    flex-wrap: wrap;
    height: auto;
    padding: 10px 0;
  }
  .image-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* --- Utility --- */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-gap { gap: 12px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.p-16 { padding: 16px; }
.p-24 { padding: 24px; }
.w-full { width: 100%; }
.hidden { display: none; }
