/* ===== GLOBAL STYLES ===== */
body {
  font-family: 'Inter', Arial, sans-serif;
  background-color: #151515;
  color: #FFFFFF;
  margin: 0;
  padding: 0;
  transition: background-color 0.3s, color 0.3s;
  width: 100%;
}

body.light-mode {
  background-color: #FFFFFF;
  color: #202020;
}

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

.loading-message {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: grid;
  justify-content: center;
  align-items: center;
  background-color: #1A1A1A;
  z-index: 1;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 0.4; }
}

body.light-mode .loading-message {
  background-color: #fefefe;
}

/* ===== HEADER STYLES ===== */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid #3B3B3B;
}

header.light-mode {
  background-color: #BFBFBF;
}

.logo img {
  height: 40px;
}

/* Logo inversion for dark/light modes */
body.light-mode .logo img {
  filter: invert(0);
}

body:not(.light-mode) .logo img {
  filter: invert(1) brightness(2);
}

/* ===== DARK MODE TOGGLE ===== */
.dark-mode-toggle {
  display: flex;
  align-items: center;
}

#theme-toggle {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  width: 24px;
  height: 24px;
  position: relative;
  color: white;
}

#theme-toggle .sun-icon {
  display: none;
}

body.light-mode #theme-toggle .moon-icon {
  display: none;
}

body.light-mode #theme-toggle .sun-icon  {
  display: block;
  color: black;
}

#theme-toggle svg {
  width: 24px;
  height: 24px;
  transition: transform 0.3s ease;
}

#theme-toggle:hover svg {
  transform: scale(1.1);
}

/* ===== VIEW TOGGLE STYLES ===== */
.view-toggle {
  display: flex;
  align-items: center;
  font-family: 'Inter', Arial, sans-serif;
}

.toggle-container {
  position: relative;
  display: flex;
  background-color: #2A2A2A;
  border-radius: 24px;
  height: 32px;
}

body.light-mode .toggle-container {
  background-color: #e0e0e0;
}

.toggle-highlight {
  position: absolute;
  background-color: #444444;
  border-radius: 24px;
  height: 32px;
  transition: transform 0.3s ease, width 0.3s ease;
  z-index: 0;
}

body.light-mode .toggle-highlight {
  background-color: #BFBFBF;
}

.toggle-tabs {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
  z-index: 1;
}

.toggle-tab {
  padding: 7px 16px;
  font-size: 14px;
  font-weight: 500;
  color: #878787;
  cursor: pointer;
  border-radius: 6px;
  transition: color 0.3s ease;
  white-space: nowrap;
}

.toggle-tab.active {
  color: #FFFFFF;
}

body.light-mode .toggle-tab.active {
  color: #202020;
}

/* ===== TABLE STYLES ===== */
.table-container {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 20px;
  border-radius: 8px;
  background-color: #151515;
}

body.light-mode .table-container {
  background-color: #ffffff;
}

#token-table {
  min-width: 1000px;
  width: 100%;
  border-collapse: collapse;
  margin-top: 0;
}

#token-table th, 
#token-table td {
  white-space: nowrap;
}

th, td {
    text-align: left;
    padding: 12px;
    border-bottom: 1px solid rgb(68, 68, 68);
}

#token-table th:first-child,
#token-table td:first-child,
#token-table th:nth-child(2),
#token-table td:nth-child(2) {
  position: sticky;
  left: 0;
  z-index: 1;
}

#token-table th:nth-child(2),
#token-table td:nth-child(2) {
  left: -2px;
}

.table-container::-webkit-scrollbar {
  height: 8px;
}

.table-container::-webkit-scrollbar-track {
  background: #1F1F1F;
  border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb {
  background: #444444;
  border-radius: 4px;
}

body.light-mode .table-container::-webkit-scrollbar-track {
  background: #e0e0e0;
}

body.light-mode .table-container::-webkit-scrollbar-thumb {
  background: #4CAF50;
}

#token-table th {
  background-color: #151515;
  color: #FFFFFF;
  font-weight: 400;
  font-size: 13px;
  padding: 20px 12px;
}

#token-table th:hover {
  background-color: #444444;
}

body.light-mode #token-table th {
  background-color: #151515;
  color: #FFFFFF;
}

body.light-mode #token-table th:hover {
  background-color: #2a2a2a;
}

#token-table th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
}

#token-table th.sortable::after {
  content: "↕";
  position: absolute;
  left: 5px;
  opacity: 0.3;
  font-size: 0.8em;
  transition: opacity 0.2s;
}

#token-table th:hover.sortable::after {
  opacity: 0.8;
}

#token-table th.sorted-asc::after {
  content: "↑";
  opacity: 1;
}

#token-table th.sorted-desc::after {
  content: "↓";
  opacity: 1;
}

#token-table td {
  padding: 8px;
  text-align: center;
}

#token-table canvas {
  display: block;
  margin: 0 auto;
  width: 100px !important;
}

#token-table th:first-child,
#token-table td:first-child {
  text-align: center;
  width: 40px;
  padding-right: 0;
  color: #878787;
}

#token-table td:nth-child(3) {
  text-align: left;
  padding-right: 0px;
}

#token-table td:nth-child(2) {
  width: 40px;
  padding: 8px 4px;
  text-align: center;
}

#token-table td:nth-child(2) img {
  display: block;
  margin: 0 auto;
  max-width: 24px;
  max-height: 24px;
  background: #f0f0f0;
  border-radius: 50%;
}

body.light-mode #token-table td:nth-child(2) img {
  background: #e0e0e0;
}

#token-table tr {
  cursor: pointer;
}

tbody tr:hover {
  background-color: #3B3B3B;
}

body.light-mode tbody tr:hover {
  background-color: #e0e0e0;
}

.history-button {
  pointer-events: auto;
  border-radius: 24px;
  padding: 10px 16px;
  color: #d0d0d0;
  border-style: initial;
  background-color: #2a2a2a;
  cursor: pointer;
}

.history-button:hover {
  color: white;
}

.trend-up {
  color: #4CAF50;
}

.trend-down {
  color: #E63946;
}

/* Skeleton styles for main table */
#token-table .skeleton-chart {
  width: 150px;
  height: 50px;
  display: block;
  margin: 0 auto;
  border-radius: 4px;
}

#token-table .skeleton-circle {
  width: 24px;
  height: 24px;
  display: block;
  margin: 0 auto;
  border-radius: 50%;
}

#token-table tbody tr {
  height: 60px; /* Match your actual row height */
}

#token-table td {
  position: relative;
}

#token-table .skeleton-text {
  display: inline-block;
  width: 80%;
  height: 16px;
  margin: 0 auto;
}

#token-table td:nth-child(3) .skeleton-text {
  width: 100px;
}

#token-table td:nth-child(5) .skeleton-text,
#token-table td:nth-child(6) .skeleton-text,
#token-table td:nth-child(7) .skeleton-text,
#token-table td:nth-child(8) .skeleton-text,
#token-table td:nth-child(9) .skeleton-text,
#token-table td:nth-child(10) .skeleton-text,
#token-table td:nth-child(11) .skeleton-text {
  width: 60px;
}

#token-table td .skeleton-text {
  margin: 0 auto;
  display: block;
}


.skeleton {
  display: inline-block;
  height: 1em;
  width: 100%;
  background: linear-gradient(90deg, #202020 25%, #2B2B2B 50%, #202020 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}

.skeleton-circle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
}

.skeleton-chart {
  width: 150px;
  height: 50px;
}

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

/* skeleton modal */
.skeleton {
  background-color: #2A2A2A;
  border-radius: 4px;
  animation: pulse 1.5s ease-in-out infinite;
}

body.light-mode .skeleton {
  background-color: #e0e0e0;
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 0.3; }
}

.skeleton-text {
  height: 1em;
  width: 80%;
  margin-bottom: 0.5em;
  display: inline-block;
}

.skeleton-text-sm {
  height: 0.8em;
  width: 60%;
  display: inline-block;
}

.skeleton-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.skeleton-chart {
  width: 100%;
  height: 200px;
}

.skeleton-table-row {
  display: flex;
  margin-bottom: 10px;
}

.skeleton-table-cell {
  height: 20px;
  margin-right: 10px;
  flex-grow: 1;
}

.skeleton-table-cell:last-child {
  margin-right: 0;
}

/* ===== MODAL STYLES ===== */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0);
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  transition: 
    opacity 0.4s cubic-bezier(0.42, 0, 0.34, 1.2),
    background-color 0.4s cubic-bezier(0.42, 0, 0.34, 1.2);
  will-change: opacity, background-color;
  overflow-y: auto;
}

.modal.open {
  display: flex;
  opacity: 1;
  background-color: rgba(0, 0, 0, 0.7);
}

.modal-content {
  background-color: #1A1A1A;
  padding: 20px;
  border-radius: 10px;
  max-width: 800px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
  transform: translateY(20px) scale(0.96);
  opacity: 0;
  transition: 
    transform 0.4s cubic-bezier(0.42, 0, 0.34, 1.2),
    opacity 0.4s cubic-bezier(0.42, 0, 0.34, 1.2);
  will-change: transform, opacity;
}

.modal.open .modal-content {
  transform: translateY(0) scale(1);
  opacity: 1;
  transition-delay: 0.1s;
}

body.light-mode .modal-content {
  background-color: #fefefe;
  color: #202020;
}

.modal-content::-webkit-scrollbar {
  width: 4px;
}

.modal-content::-webkit-scrollbar-track {
  background: transparent;
  margin-top: 10px;
  margin-bottom: 10px;
}

/* Handle */
.modal-content::-webkit-scrollbar-thumb {
  background: #313131;
  border-radius: 30px;
}

/* Handle on hover */
.modal-content::-webkit-scrollbar-thumb:hover {
  background: #555;
}

.close {
  color: #FFFFFF;
  float: right;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  position: absolute;
  right: 20px;
  top: 14px;
}

.close:hover {
  color: #BFBFBF;
}

body.light-mode .close {
  color: #202020;
}

body.light-mode .close:hover {
  color: #444444;
}

.modal-header {
  display: flex;
  flex-direction: column;
}

.modal-header > h2 {
  color: #818384;
  font-weight: 400;
  font-size: 20px;
  margin-top: 0px;
  margin-bottom: 24px;
}

.token-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  width: 100%;
  border-bottom: 1px solid #444444;
  padding-bottom: 14px;
  flex-wrap: wrap;
  gap: 24px;
}

body.light-mode .token-header {
  border-bottom-color: #FFFFFF;
}

.token-subtitle {
  font-size: 14px;
  color: #878787;
  font-weight: 400;
  margin-top: 4px;
}

body.light-mode .token-subtitle {
  color: #666;
}

.token-subtitle .holder-count {
  color: #FFFFFF;
  font-size: 16px;
}

body.light-mode .token-subtitle .holder-count {
  color: #202020;
}

.token-subtitle .timestamp {
  color: #878787;
}

body.light-mode .token-subtitle .timestamp {
  color: #666;
}

#modal-token-name {
  font-weight: 600;
  font-size: 2.5em;
}

.token-name-container {
  display: flex;
  align-items: center;
  gap: 6px;
}

#modal-token-img {
  display: block;
}

.token-info img {
  border-radius: 50%;
}

.holder-gains {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.gains-label {
  color: #818384;
  font-size: 14px;
  font-weight: 400;
}

.gains-value {
  font-size: 32px;
  font-weight: 700;
}

.gains-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.gains-net {
  font-size: 32px;
  font-weight: 700;
}

.gains-percent {
  font-size: 24px;
  font-weight: 600;
}

.token-stats {
  display: flex;
  gap: 24px;
  margin-top: 62px;
  flex-wrap: wrap;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-label {
  color: #818384;
  font-size: 14px;
  font-weight: 400;
}

.stat-value {
  font-size: 22px;
  font-weight: 400;
}

.market-cap {
  font-weight: 600;
  font-size: 1.1em;
}

/* Error State Styles */
.chart-error {
  background-color: #2a2a2a;
  border-radius: 8px;
  font-size: 14px;
  height: 100%;
  display: grid;
  justify-content: center;
  align-items: center;
}

body.light-mode .chart-error {
  background-color: #e0e0e0;
}

/* Modal Styles - Mobile Full Screen */
@media only screen and (max-width: 768px) {
  .modal-content {
    max-width: 100%;
    max-height: 100vh;
    height: 100%;
    width: 100%;
    border-radius: 0;
    padding: 20px 15px;
  }
  
  .modal {
    align-items: flex-start;
    padding-top: 0;
    overflow-y: auto;
  }

  .holder-gains {
      align-items: flex-start;
  }
  
  .close {
    position: fixed;
    top: 15px;
    right: 15px;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
  }
  
  .modal-chart-container {
    min-height: 200px; 
    position: relative;
  }
  
  #history-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    font-size: 14px;
  }

  #history-table th,
  #history-table td {
  min-width: 70px;
  }
  
  #history-table th {
    position: sticky;
    top: 0;
  }
  
  .token-stats {
    gap: 15px;
  }
  
  .stat-item {
    min-width: 84px;
  }

  .modal-header > h2 {
    font-size: 16px;
    margin-bottom: 16px;
  }

  #modal-token-name {
    font-size: 1.5em;
  }

  .gains-value {
    font-size: 22px;
  }

  .token-subtitle {
      margin-top: 8px;
  }

  .token-header {
      gap: 16px;
  }

  .logo img {
      height: 26px;
  }

  header {
    padding: 12px 16px;
  }

  h1 {
      font-size: 24px;
      margin-block-start: 0px;
      margin-block-end: 24px;
  }

  .header-with-controls {
      gap: 0px !important;
  }

  .container {
      padding: 16px;
  }
}

/* Prevent body scroll when modal is open on mobile */
body.modal-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
}

/* ===== HOLDER DISTRIBUTION STYLES ===== */
.holder-distribution {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 14px 0px 0px 0px;
  padding: 0px;
}

body.light-mode .holder-distribution {
  background-color: initial;
}

.distribution-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  padding: 6px 6px;
  border-radius: 24px;
  position: relative;
  cursor: help;
}

.distribution-item img {
  border-radius: 50%;
}

.distribution-count {
  font-weight: 600;
}

/* Tooltip styles */
.distribution-item::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 5px);
  left: 50%;
  transform: translateX(-50%);
  background-color: #333;
  color: white;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  z-index: 10;
  pointer-events: none;
}

.distribution-item:hover::after {
  opacity: 1;
  visibility: visible;
}

body.light-mode .distribution-item::after {
  background-color: #555;
  color: #fff;
}

/* ===== CHART STYLES ===== */
.modal-chart-container {
  position: relative;
  width: 100%;
  height: 200px;
  margin: 20px 0;
}

.chart-time-filters {
  display: flex;
  gap: 5px;
  margin-top: 14px;
  justify-content: flex-end;
  position: absolute;
  bottom: -45px;
  right: 0;
}

.chart-time-filters button {
  order: 1;
  padding: 6px 12px;
  font-size: 14px;
  border-radius: 24px;
  border: none;
  background-color: #444444;
  color: white;
  cursor: pointer;
  transition: all 0.2s;
}

.chart-time-filters button[data-days="7"] {
  order: 0;
}

.chart-time-filters button:hover {
  background-color: #555;
}

.chart-time-filters button.active {
  background-color: #F1F1F1;
  color: #101010;
}

body.light-mode .chart-time-filters button {
  background-color: #e0e0e0;
  color: #202020;
}

body.light-mode .chart-time-filters button:hover {
  background-color: #d0d0d0;
}

body.light-mode .chart-time-filters button.active {
  background-color: #202020;
  color: white;
}

#modal-chart {
  width: 100%;
  height: 100%;
}

.chart-container {
  margin: 20px 0;
  background-color: #2A2A2A;
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

body.light-mode .chart-container {
  background-color: #FFFFFF;
}

.chart-cell {
  width: 150px;
  height: 50px;
}

/* ===== HISTORY TABLE STYLES ===== */
#history-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 36px;
  border-radius: 20px;
  overflow: hidden;
  display: block;
  overflow-x: auto;
  white-space: nowrap;
}

#history-table th,
#history-table td {
  padding: 10px;
  text-align: left;
  border-bottom: 1px solid #444444;
  min-width: 100px;
}

#history-table th {
  background-color: #232323;
  color: #FFFFFF;
  font-weight: 100;
  font-size: 12px;
  position: sticky;
  top: 0;
}

body.light-mode #history-table th {
  background-color: #e0e0e0;
  color: #202020;
}

#history-table td {
  color: white;
}

body.light-mode #history-table td {
  color: #202020;
}

#history-table .trend-up {
  color: #4CAF50;
}

#history-table .trend-down {
  color: #E63946;
}

#history-table .trend-up span,
#history-table .trend-down span {
  font-size: 14px;
  margin-right: 5px;
}

/* ===== MISC UTILITY STYLES ===== */
#last-updated {
  font-size: 0.9em;
  color: #666;
  margin-top: -10px;
  margin-bottom: 20px;
}

.header-with-controls {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 20px;
}

.controls-right {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-top: 5px;
}

/* ===== RESPONSIVE STYLES ===== */
@media only screen and (max-width: 600px) {
  #token-table th, #token-table td > canvas {
    width: 60px !important;
    height: 30px !important;
  }

  #token-table {
    font-size: 14px;
  }

  #token-table th, #token-table td {
    padding: 14px 22px 10px 0px;
    width: 22px !important;
  }
  #token-table td:nth-child(5) {
      padding-right: 0px;
  }
  #token-table td:nth-child(4) {
      padding-right: 0px;
  }
}

/* ===== FOOTER STYLES ===== */
footer {
  background-color: #151515;
  border-top: 1px solid #3B3B3B;
  padding: 20px;
  margin-top: 40px;
}

body.light-mode footer {
  background-color: #FFFFFF;
  border-top-color: #e0e0e0;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1400px;
  margin: 0 auto;
  flex-wrap: wrap;
  gap: 20px;
}

.footer-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: #878787;
}

.footer-logo {
  height: 20px;
  filter: invert(1) brightness(2);
}

body.light-mode .footer-logo {
  filter: invert(0);
}

.footer-right {
  display: flex;
  align-items: center;
}

.donation-message {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #878787;
  flex-wrap: wrap;
  justify-content: center;
}

.wallet-address {
  display: flex;
  align-items: center;
  gap: 4px;
  background-color: #2A2A2A;
  padding: 6px 10px;
  border-radius: 20px;
  font-family: monospace;
  font-size: 13px;
}

body.light-mode .wallet-address {
  background-color: #e0e0e0;
}

.copy-button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  color: #878787;
  transition: color 0.2s;
}

.copy-button:hover {
  color: #4CAF50;
}

.copy-button svg {
  display: block;
}

/* Tooltip for copy button */
.wallet-address {
  position: relative;
}

.wallet-address::after {
  content: "Copied!";
  position: absolute;
  bottom: calc(100% + 5px);
  left: 50%;
  transform: translateX(-50%);
  background-color: #333;
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  pointer-events: none;
}

.wallet-address.copied::after {
  opacity: 1;
  visibility: visible;
}

@media only screen and (max-width: 600px) {
  .footer-content {
    flex-direction: column;
    text-align: center;
  }
  
  .footer-left, .footer-right {
    justify-content: center;
    width: 100%;
  }
}

/* Hide 1h Change column on mobile using data-label */
@media only screen and (max-width: 768px) {
  #token-table th:nth-child(6),
  #token-table td:nth-child(6) {
    display: none !important;
  }
}