/* ==========================================================================
   AIGC Gallery Design System
   Modern Dark Aesthetic, Responsive Grid, High-Performance CSS
   ========================================================================== */

:root {
  --bg-main: #090d16;
  --bg-card: #111827;
  --bg-card-hover: #172033;
  --bg-header: rgba(9, 13, 22, 0.85);
  --border-color: #1f293d;
  --border-focus: #3b82f6;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-cyan: #06b6d4;
  --accent-pink: #ec4899;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.4);
  --shadow-hover: 0 12px 30px -4px rgba(59, 130, 246, 0.15), 0 8px 16px -4px rgba(0, 0, 0, 0.5);
}

/* Reset & Basics */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

/* Container */
.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header & Navigation */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background-color: var(--bg-header);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  padding: 16px 0;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.5px;
}

.brand-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  border-radius: var(--radius-sm);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.5);
}

.brand-text {
  background: linear-gradient(135deg, #ffffff 40%, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 6px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 4px;
}

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

.nav-link {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.nav-link:hover, .nav-link.active {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.05);
}

/* Hero Section */
.hero-section {
  padding: 50px 0 30px;
  text-align: center;
  border-bottom: 1px solid var(--border-color);
  background: radial-gradient(circle at 50% 20%, rgba(59, 130, 246, 0.08) 0%, transparent 60%);
}

.hero-title {
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 14px;
  letter-spacing: -0.5px;
}

.hero-gradient {
  background: linear-gradient(135deg, #60a5fa, #c084fc, #f472b6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  color: var(--text-secondary);
  font-size: 1.05rem;
  max-width: 680px;
  margin: 0 auto 24px;
}

/* Category Filter Bar */
.category-filter-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.filter-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: rgba(31, 41, 61, 0.5);
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  transition: all 0.2s;
}

.filter-tab:hover {
  color: var(--text-primary);
  border-color: #334155;
  background: rgba(51, 65, 85, 0.5);
}

.filter-tab.active {
  color: #ffffff;
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.35);
}

.filter-count {
  font-size: 0.75rem;
  padding: 1px 6px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 10px;
}

/* Section Header */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 0 16px;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-summary {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Card Grid - Uniform Width & Uniform Height */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 24px;
  padding-bottom: 60px;
}

/* Card Item - Strictly Uniform Height */
.gallery-card {
  height: 490px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
  box-shadow: var(--shadow-card);
  position: relative;
}

.gallery-card:hover {
  transform: translateY(-4px);
  border-color: #3b82f6;
  box-shadow: var(--shadow-hover);
}

/* Card Media Header - Fixed Height */
.card-media {
  position: relative;
  height: 210px;
  width: 100%;
  background: #000;
  overflow: hidden;
  flex-shrink: 0;
}

.card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

.gallery-card:hover .card-image {
  transform: scale(1.03);
}

/* Media Overlay Badges */
.card-badges {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}

.badge-group {
  display: flex;
  gap: 6px;
}

.badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  backdrop-filter: blur(8px);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.badge-model {
  background: rgba(15, 23, 42, 0.85);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.badge-category {
  background: rgba(15, 23, 42, 0.85);
  color: #cbd5e1;
  border: 1px solid rgba(203, 213, 225, 0.2);
}

.badge-video {
  background: rgba(236, 72, 153, 0.9);
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
  box-shadow: 0 0 10px rgba(236, 72, 153, 0.5);
}

.badge-video svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
}

/* Card Body - Structured flex layout to guarantee uniform height */
.card-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
  justify-content: space-between;
  overflow: hidden;
}

.card-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.4;
  height: 2.8em; /* Exactly 2 lines */
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card-title a:hover {
  color: var(--accent-blue);
}

/* Prompt Box - Collapsed preview with fixed height to never break grid */
.prompt-box {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  padding: 10px;
  position: relative;
  height: 96px; /* Fixed height container */
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.prompt-text {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: #94a3b8;
  line-height: 1.45;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.prompt-actions-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 4px;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
}

.btn-view-prompt {
  font-size: 0.75rem;
  color: var(--accent-cyan);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color 0.2s;
}

.btn-view-prompt:hover {
  color: #38bdf8;
  text-decoration: underline;
}

/* Card Footer Actions */
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  margin-top: 8px;
}

.card-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-item svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
}

.card-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  text-decoration: none;
}

.btn-copy {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.btn-copy:hover {
  background: var(--accent-blue);
  color: #ffffff;
}

.btn-download {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-download:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
}

.btn-xsource {
  background: rgba(0, 0, 0, 0.4);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.btn-xsource:hover {
  background: #0284c7;
  color: #ffffff;
}

/* Detail Page Layout */
.detail-container {
  padding: 30px 0 60px;
}

.breadcrumb-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.breadcrumb-nav a:hover {
  color: var(--accent-blue);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 36px;
  align-items: start;
}

@media (max-width: 860px) {
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

.detail-media-wrap {
  background: #000;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

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

.detail-media-actions {
  display: flex;
  gap: 12px;
  padding: 16px;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
}

.detail-info-wrap {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.detail-title {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1.3;
}

.detail-meta-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
}

.detail-section-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.detail-prompt-box {
  background: #090d16;
  border: 1px solid #1e293b;
  border-radius: var(--radius-sm);
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: #cbd5e1;
  line-height: 1.6;
  word-break: break-all;
  white-space: pre-wrap;
}

/* Parameters Table */
.param-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.param-table th, .param-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.param-table th {
  color: var(--text-muted);
  font-weight: 500;
  width: 35%;
}

.param-table td {
  color: var(--text-primary);
  font-family: var(--font-mono);
}

/* Related Recommendations */
.related-section {
  margin-top: 60px;
  padding-top: 30px;
  border-top: 1px solid var(--border-color);
}

/* Prompt Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

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

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 640px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
  overflow: hidden;
  animation: modalIn 0.2s ease-out;
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-close {
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  padding: 4px;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  max-height: 60vh;
  overflow-y: auto;
}

.modal-prompt-text {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.6;
  color: #e2e8f0;
  background: #090d16;
  border: 1px solid #1e293b;
  border-radius: var(--radius-sm);
  padding: 16px;
  white-space: pre-wrap;
  word-break: break-all;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.2);
}

/* Toast Notification */
.toast-notice {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #10b981;
  color: #ffffff;
  padding: 10px 20px;
  border-radius: 9999px;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 10px 25px rgba(16, 185, 129, 0.4);
  z-index: 200;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s;
  opacity: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast-notice.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Footer */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-color);
  padding: 36px 0;
  background: rgba(9, 13, 22, 0.95);
  color: var(--text-muted);
  font-size: 0.85rem;
}

.footer-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
}

.footer-links {
  display: flex;
  gap: 20px;
}

.footer-links a:hover {
  color: var(--accent-blue);
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .card-grid {
    grid-template-columns: 1fr;
  }
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }
  .nav-links {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
  }
}
