/* ========== CSS Variables ========== */
:root {
  --primary: #FF6B35;
  --primary-dark: #E55A2B;
  --primary-light: #FF8F5E;
  --accent: #FFD700;
  --bg-dark: #1A1A2E;
  --bg-card: #16213E;
  --bg-input: #0F3460;
  --text-primary: #FFFFFF;
  --text-secondary: #B0B0C0;
  --text-muted: #6C6C80;
  --border-color: #2A2A4A;
  --success: #4CAF50;
  --danger: #F44336;
  --star-active: #FFD700;
  --star-inactive: #3A3A5A;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 20px rgba(0,0,0,0.3);
  --transition: all 0.3s ease;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-light); }

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

/* ========== Scrollbar ========== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }

/* ========== Navigation ========== */
.navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  background: rgba(26, 26, 46, 0.95);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  padding: 0 20px;
  height: 60px;
  display: flex; align-items: center; justify-content: space-between;
}

.nav-brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 20px; font-weight: 700;
  color: var(--text-primary);
}

.nav-brand .icon { font-size: 26px; }

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

.nav-btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
  font-weight: 500;
}

.nav-btn.primary {
  background: var(--primary);
  color: white;
}

.nav-btn.primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.nav-btn.ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.nav-btn.ghost:hover {
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

.nav-btn.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid transparent;
}

.nav-btn.danger:hover {
  background: rgba(244, 67, 54, 0.1);
}

.nav-user {
  display: flex; align-items: center; gap: 12px;
}

.nav-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600;
  color: white;
}

/* ========== Nav User Stats ========== */
.nav-stats {
  display: flex;
  gap: 8px;
  font-size: 11px;
  line-height: 1;
  margin-top: 3px;
}

.nav-stats .stat-item {
  color: var(--text-muted);
  padding: 2px 6px;
  background: var(--bg-input);
  border-radius: 4px;
  white-space: nowrap;
}

/* ========== Main Content ========== */
.main-content {
  margin-top: 60px;
  padding: 20px;
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
}

/* ========== Hero Section ========== */
.hero {
  text-align: center;
  padding: 60px 20px 40px;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(circle at 50% 80%, rgba(255,107,53,0.15) 0%, transparent 50%);
  pointer-events: none;
}

.hero h1 {
  font-size: 42px;
  font-weight: 800;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  font-size: 18px;
  color: var(--text-secondary);
  max-width: 500px;
  margin: 0 auto 30px;
}

.hero-actions {
  display: flex; gap: 12px; justify-content: center; flex-wrap: wrap;
}

/* ========== Filter Bar ========== */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  padding: 16px 20px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.filter-tabs {
  display: flex; gap: 4px;
}

.filter-tab {
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  transition: var(--transition);
}

.filter-tab.active {
  background: var(--primary);
  color: white;
}

.filter-tab:hover:not(.active) {
  background: var(--bg-input);
  color: var(--text-primary);
}

.filter-sort select {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  cursor: pointer;
  outline: none;
}

/* ========== Waterfall Grid ========== */
.waterfall {
  columns: 4;
  column-gap: 16px;
}

@media (max-width: 1200px) { .waterfall { columns: 3; } }
@media (max-width: 800px) { .waterfall { columns: 2; } }
@media (max-width: 500px) { .waterfall { columns: 1; } }

/* ========== Photo Card ========== */
.photo-card {
  break-inside: avoid;
  margin-bottom: 16px;
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: var(--transition);
}

.photo-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
  box-shadow: 0 8px 30px rgba(255,107,53,0.15);
}

.photo-card img {
  width: 100%;
  object-fit: cover;
  display: block;
}

.photo-card .card-info {
  padding: 12px 14px;
}

.photo-card .card-user {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
}

.photo-card .card-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: white;
  flex-shrink: 0;
}

.photo-card .card-username {
  font-size: 13px; color: var(--text-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.photo-card .card-stats {
  display: flex; align-items: center; gap: 14px;
  font-size: 13px; color: var(--text-muted);
}

.photo-card .card-stats span {
  display: flex; align-items: center; gap: 4px;
}

.photo-card .card-stats .icon { font-size: 14px; }

/* ========== Modal ========== */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.8);
  z-index: 2000;
  display: none; align-items: center; justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

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

/* ========== Navigation Arrows ========== */
.nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.5);
  color: white;
  font-size: 24px;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  backdrop-filter: blur(4px);
}

.nav-arrow:hover {
  background: var(--primary);
  transform: translateY(-50%) scale(1.1);
}

.nav-prev { left: 12px; }
.nav-next { right: 12px; }

@media (max-width: 600px) {
  .nav-arrow { width: 36px; height: 36px; font-size: 20px; }
  .nav-prev { left: 8px; }
  .nav-next { right: 8px; }
}

/* ========== Swipe Hint ========== */
.swipe-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.7);
  color: white;
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 15px;
  z-index: 20;
  pointer-events: none;
  animation: swipeHintFade 2.5s ease forwards;
  backdrop-filter: blur(8px);
  white-space: nowrap;
}

@keyframes swipeHintFade {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.95); }
}

/* ========== Photo Counter ========== */
.photo-counter {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  position: relative;
}

.modal-close {
  position: absolute; top: 12px; right: 12px;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.5);
  color: white;
  font-size: 18px;
  cursor: pointer;
  z-index: 10;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}

.modal-close:hover { background: var(--danger); }

.modal-image {
  width: 100%;
  max-height: 500px;
  object-fit: contain;
  background: #000;
}

.modal-body {
  padding: 20px;
}

.modal-user {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px;
}

.modal-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 600; color: white;
}

.modal-username { font-weight: 600; }
.modal-date { font-size: 13px; color: var(--text-muted); }

.modal-description {
  margin-bottom: 16px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ========== Rating ========== */
.rating-section {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 0;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.stars {
  display: flex; gap: 4px;
}

.star {
  font-size: 28px;
  cursor: pointer;
  color: var(--star-inactive);
  transition: var(--transition);
  user-select: none;
}

.star.active, .star.hover { color: var(--star-active); }

.star:hover { transform: scale(1.2); }

.rating-info {
  display: flex; flex-direction: column;
}

.rating-average {
  font-size: 24px; font-weight: 700;
  color: var(--accent);
}

.rating-count {
  font-size: 13px; color: var(--text-muted);
}

/* ========== Vote ========== */
.vote-section {
  display: flex; gap: 12px;
}

.vote-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  transition: var(--transition);
}

.vote-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.vote-btn.voted {
  background: rgba(255,107,53,0.15);
  border-color: var(--primary);
  color: var(--primary);
}

.vote-btn .icon { font-size: 16px; }

/* ========== Auth Pages ========== */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 60px);
  padding: 20px;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}

.auth-card h2 {
  text-align: center;
  margin-bottom: 8px;
  font-size: 24px;
}

.auth-card .subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 28px;
  font-size: 14px;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  transition: var(--transition);
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255,107,53,0.15);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.auth-switch {
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  color: var(--text-muted);
}

.auth-switch a { color: var(--primary); font-weight: 500; }

.auth-error {
  background: rgba(244,67,54,0.1);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

.auth-error.show { display: block; }

/* ========== Upload Page ========== */
.upload-container {
  max-width: 600px;
  margin: 40px auto;
  padding: 0 20px;
}

.upload-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 30px;
}

.upload-card h2 {
  margin-bottom: 24px;
  font-size: 22px;
}

.upload-dropzone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 20px;
  position: relative;
}

.upload-dropzone:hover,
.upload-dropzone.dragover {
  border-color: var(--primary);
  background: rgba(255,107,53,0.05);
}

.upload-dropzone .icon { font-size: 48px; margin-bottom: 12px; }

.upload-dropzone p {
  color: var(--text-muted);
  font-size: 14px;
}

.upload-dropzone .hint {
  font-size: 12px;
  margin-top: 6px;
  color: var(--text-muted);
}

.upload-preview {
  display: none;
  margin-bottom: 20px;
  border-radius: var(--radius);
  overflow: hidden;
}

/* ========== Copyright Options ========== */
.copyright-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.copyright-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-size: 14px;
  color: var(--text-secondary);
}

.copyright-option:hover {
  border-color: var(--primary);
  color: var(--text-primary);
}

.copyright-option input[type="radio"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.copyright-option:has(input:checked) {
  border-color: var(--primary);
  background: rgba(255,107,53,0.08);
  color: var(--text-primary);
}

.upload-preview img {
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  background: #000;
}

.upload-preview.show { display: block; }

textarea.form-input {
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
}

.char-count {
  text-align: right;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ========== Leaderboard ========== */
.leaderboard {
  max-width: 800px;
  margin: 0 auto;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  margin-bottom: 12px;
  transition: var(--transition);
}

.leaderboard-item:hover {
  border-color: var(--primary);
}

.leaderboard-rank {
  font-size: 24px;
  font-weight: 800;
  width: 40px;
  text-align: center;
  flex-shrink: 0;
}

.leaderboard-rank.gold { color: #FFD700; }
.leaderboard-rank.silver { color: #C0C0C0; }
.leaderboard-rank.bronze { color: #CD7F32; }

.leaderboard-thumb {
  width: 70px; height: 70px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
}

.leaderboard-info { flex: 1; min-width: 0; }

.leaderboard-title {
  font-weight: 600;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-meta {
  font-size: 13px;
  color: var(--text-muted);
  display: flex; gap: 14px;
}

.leaderboard-score {
  display: flex; align-items: center; gap: 4px;
  font-size: 18px; font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.leaderboard-score .icon { font-size: 20px; }

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

.empty-state .icon { font-size: 64px; margin-bottom: 16px; }
.empty-state h3 { color: var(--text-secondary); margin-bottom: 8px; }

/* ========== Loading ========== */
.loading-spinner {
  display: flex;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ========== Toast ========== */
.toast-container {
  position: fixed;
  top: 76px;
  right: 20px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  animation: slideIn 0.3s ease;
  box-shadow: var(--shadow);
}

.toast.success { background: var(--success); color: white; }
.toast.error { background: var(--danger); color: white; }
.toast.info { background: var(--primary); color: white; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ========== Responsive ========== */
@media (max-width: 600px) {
  .hero h1 { font-size: 28px; }
  .hero p { font-size: 15px; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-tabs { overflow-x: auto; }
  .modal { max-height: 95vh; }
  .auth-card { padding: 24px; }
  .rating-section { flex-direction: column; align-items: flex-start; gap: 12px; }
  .leaderboard-item { gap: 10px; }
  .leaderboard-thumb { width: 50px; height: 50px; }
}

/* ========== Profile Card ========== */
.profile-section { margin-top: 10px; }

.profile-card {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  flex-wrap: wrap;
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.profile-info { flex: 1; min-width: 150px; }
.profile-username { font-size: 20px; font-weight: 700; }
.profile-email { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.profile-joined { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ========== Owner Actions ========== */
.owner-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.owner-btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  transition: var(--transition);
}

.owner-btn:hover { border-color: var(--text-secondary); color: var(--text-primary); }
.edit-btn:hover { border-color: var(--primary); color: var(--primary); }
.delete-btn:hover { border-color: var(--danger); color: var(--danger); background: rgba(244,67,54,0.08); }

.owner-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.fav-btn.voted {
  background: rgba(255,107,53,0.15);
  border-color: var(--primary);
  color: var(--primary);
}
