* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #fcbf47;
  --primary-dark: #ffa500;
  --background: #001b2e;
  --surface: #011c33;
  --surface-light: #053452;
  --text: #e6f1ff;
  --text-muted: #9bb3c7;
  --border: #122A3A;
  --success: #10b981;
  --danger: #ff7a00;
  --warning: #ffa500;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--background);
  color: var(--text);
  line-height: 1.6;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
.header {
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-light) 100%);
  border-radius: 12px;
  padding: 30px;
  margin-bottom: 30px;
  border: 1px solid var(--border);
}

.header-title-section {
  display: flex;
  align-items: center;
  gap: 30px;
  margin-bottom: 20px;
}

.header-starfish-container {
  flex-shrink: 0;
  width: 100px;
  height: 100px;
}

.header-starfish {
  width: 100px;
  height: 100px;
  border-radius: 12px;
  filter: drop-shadow(0 0 15px rgba(100, 200, 255, 0.5));
  animation: float 4s ease-in-out infinite, glow 3s ease-in-out infinite;
  object-fit: contain;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0px) rotateZ(-2deg);
  }
  50% {
    transform: translateY(-8px) rotateZ(2deg);
  }
}

@keyframes glow {
  0%, 100% {
    filter: drop-shadow(0 0 15px rgba(252, 191, 71, 0.4));
  }
  50% {
    filter: drop-shadow(0 0 25px rgba(252, 191, 71, 0.7));
  }
}

.header-content h1 {
  font-size: 2em;
  margin-bottom: 5px;
  background: linear-gradient(135deg, var(--primary) 0%, #60a5fa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-content .subtitle {
  color: var(--text-muted);
  font-size: 0.95em;
}

.header-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin-top: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 15px;
  text-align: center;
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 2em;
  font-weight: bold;
  color: var(--primary);
}

.stat-change {
  color: var(--text-muted);
  font-size: 0.85em;
  margin-top: 5px;
}

.stat-change.positive {
  color: var(--success);
}

.stat-change.negative {
  color: var(--danger);
}

/* Navigation Tabs */
.nav-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 30px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.nav-tab {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 12px 20px;
  font-size: 1em;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.3s ease;
  font-weight: 500;
}

.nav-tab:hover {
  color: var(--text);
  background: var(--surface);
  border-radius: 8px 8px 0 0;
}

.nav-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Tab Content */
.tab-content {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-content.active {
  display: block;
}

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

/* Charts */
.chart-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
}

.chart-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 25px;
  width: 100%;
  overflow: hidden;
}

.chart-wrapper h2 {
  font-size: 1.2em;
  margin-bottom: 15px;
  color: var(--text);
}

@media (min-width: 960px) {
  .chart-container {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.chart-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.range-btn,
.range-btn-posts {
  background: var(--surface-light);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85em;
  transition: all 0.2s ease;
}

.range-btn:hover,
.range-btn-posts:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.range-btn.active,
.range-btn-posts.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

canvas {
  max-height: 300px;
}

/* Users Section */
.users-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 25px;
}

.users-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 15px;
}

.users-header h2 {
  font-size: 1.2em;
}

.users-controls {
  display: flex;
  gap: 15px;
  align-items: center;
  flex-wrap: wrap;
}

.search-box {
  background: var(--surface-light);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 6px;
  width: 250px;
  font-size: 0.95em;
}

.search-box::placeholder {
  color: var(--text-muted);
}

.search-box:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
}

.filter-select {
  background: var(--surface-light);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.95em;
  min-width: 170px;
}

.filter-select:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
}

/* Column Toggles */
.column-toggles {
  display: flex;
  gap: 15px;
  align-items: center;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.9em;
  color: var(--text-muted);
  user-select: none;
  transition: color 0.2s ease;
}

.toggle-label:hover {
  color: var(--text);
}

.toggle-label input[type="checkbox"] {
  cursor: pointer;
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  appearance: auto;
  -webkit-appearance: auto;
}

/* Ensure checkbox is always visible */
.toggle-label input[type="checkbox"]:checked,
.toggle-label input[type="checkbox"]:not(:checked) {
  appearance: auto;
  -webkit-appearance: auto;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-left: 8px;
  border: 1px solid transparent;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-badge.status-left {
  background: rgba(248, 113, 113, 0.15);
  color: #fda4af;
  border-color: rgba(248, 113, 113, 0.4);
}

/* Table */
.users-table-wrapper {
  overflow-x: auto;
  max-height: 600px;
  overflow-y: auto;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.users-table {
  width: 100%;
  border-collapse: collapse;
}

.users-table thead {
  background: var(--surface-light);
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.users-table th {
  padding: 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.85em;
  letter-spacing: 0.5px;
  cursor: pointer;
  user-select: none;
}

.users-table th.sortable:hover {
  color: var(--text);
  background: rgba(99, 102, 241, 0.1);
}

.users-table th.sortable::after {
  content: ' ⇅';
  opacity: 0.3;
  font-size: 0.8em;
  transition: opacity 0.2s;
}

.users-table th.sortable:hover::after {
  opacity: 0.6;
}

.users-table th.sortable.active::after {
  opacity: 1;
}

.users-table th.sortable.sort-asc::after {
  content: ' ↑';
  color: var(--primary);
}

.users-table th.sortable.sort-desc::after {
  content: ' ↓';
  color: var(--primary);
}

.users-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.users-table tbody tr:hover {
  background: rgba(99, 102, 241, 0.05);
}

.users-table tbody tr.loading {
  text-align: center;
  color: var(--text-muted);
}

.users-table .wallet-address {
  font-family: 'Monaco', 'Courier New', monospace;
  font-size: 0.85em;
  color: var(--primary);
}

.users-table .value {
  color: var(--success);
  font-weight: 500;
}

.users-table .value.negative {
  color: var(--danger);
}

.users-table .time-ago {
  color: var(--text-muted);
  font-size: 0.9em;
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    padding: 15px;
  }

  .header {
    padding: 20px;
  }

  .header-content h1 {
    font-size: 1.5em;
  }

  .header-stats {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 15px;
  }

  .chart-container {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .users-header {
    flex-direction: column;
    gap: 15px;
  }

  .search-box {
    width: 100%;
  }

  .nav-tabs {
    flex-wrap: wrap;
  }

  .users-table {
    font-size: 0.9em;
  }

  .users-table th,
  .users-table td {
    padding: 8px;
  }

  .user-heading {
    flex-direction: column;
    align-items: flex-start;
  }

  .user-meta-row {
    flex-wrap: wrap;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .pagination-controls {
    flex-wrap: wrap;
  }

  .stat-grid.user-stat-grid {
    grid-template-columns: 1fr;
  }
}

/* Loading animation */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.loading {
  animation: pulse 2s infinite;
}

/* User Links */
.user-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s ease;
  border-bottom: 1px solid transparent;
}

.user-link:hover {
  color: #ffd966;
  border-bottom-color: var(--primary);
  text-shadow: 0 0 8px rgba(252, 191, 71, 0.3);
}

.user-link:active {
  color: #ffaa00;
}

/* Wallet Links */
.wallet-link {
  color: var(--primary);
  text-decoration: none;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
  transition: all 0.2s ease;
  border-bottom: 1px solid transparent;
}

.wallet-link:hover {
  color: #ffd966;
  border-bottom-color: var(--primary);
  text-shadow: 0 0 8px rgba(252, 191, 71, 0.3);
}

.wallet-link:active {
  color: #ffaa00;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  font-size: 0.8rem;
  border: 1px solid var(--border);
  gap: 6px;
}

.status-badge.status-active {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.4);
}

.pill-button {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pill-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.pill-button:not(:disabled):hover {
  border-color: var(--primary);
  color: var(--primary);
}

.user-page .header {
  margin-bottom: 20px;
}

.back-row {
  margin-bottom: 10px;
}

.back-link {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

.back-link:hover {
  color: var(--text);
}

.user-heading {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 20px;
}

.user-avatar {
  width: 70px;
  height: 70px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(252, 191, 71, 0.2) 0%, rgba(96, 165, 250, 0.15) 100%);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  background-size: cover;
  background-position: center;
  overflow: hidden;
}

.user-avatar.has-photo {
  background-color: var(--surface);
  border-color: rgba(255, 255, 255, 0.1);
  color: transparent;
}

.user-meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.user-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 15px;
}

.section {
  margin-bottom: 25px;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

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

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 15px;
}

.stat-grid.user-stat-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}

.posts-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}

.post-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.post-text {
  white-space: pre-line;
  margin-bottom: 8px;
}

.link-button {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  padding: 0;
  font-weight: 600;
}

.meta-chip.link-chip {
  text-decoration: none;
  border-color: rgba(252, 191, 71, 0.25);
  color: var(--primary);
}

.meta-chip.link-chip:hover {
  border-color: var(--primary);
  color: #ffd966;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.empty,
.error {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
}

.error {
  border-color: rgba(248, 113, 113, 0.4);
  color: #fca5a5;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--surface);
}

::-webkit-scrollbar-thumb {
  background: var(--surface-light);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border);
}
