/* Base styles (original) */
body,
html {
  font-family: Arial, sans-serif;
  background-color: #333 !important;
  color: #727ff5;
  background: #333 !important;
  margin: 0;
  padding: 0;
}

nav {
  background-color: #333;
  overflow: hidden;
  position: relative;
}

nav a {
  float: left;
  display: block;
  color: #f2f2f2;
  text-align: center;
  padding: 10px;
  color: #727ff5;
  text-decoration: none;
}

nav a:hover {
  background-color: #445484;
  color: black;
}

/* Hide nav toggle by default (desktop) */
.nav-toggle {
  display: none;
}

/* Show nav links by default (desktop) */
.nav-links {
  display: block;
  width: 100%;
}

#table_container {
  max-width: 800px;
  margin: auto;
  background: #282930;
  padding-top: 20px;
  padding-left: 10px;
  padding-right: 10px;
  /* box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); */
}

#search_container {
  text-align: center;
  margin-bottom: 10px;
}

#search_box {
  padding: 8px;
  width: 60%;
  font-size: 1em;
  color: #727ff5;
  background-color: #333;
  border: 1px solid #12387e;
}

#search_btn,
#clear_btn {
  padding: 8px 16px;
  font-size: 1em;
  color: #727ff5;
  background-color: #333;
  border: 1px solid #12387e;
  cursor: pointer;
  display: inline-block;
  text-align: center;
  margin: 0 5px;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
}

th,
td {
  text-align: left;
  padding: 12px;
  border-bottom: 1px solid #12387e;
  cursor: pointer;
  color: #727ff5;
}

th {
  background-color: #354053;
  color: #727ff5;
}

caption {
  font-size: 1.5em;
  margin-bottom: 10px;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center; 
  color: #727ff5;
  padding: 3px;
  margin: 15px 0;
}

.pagination button {
  margin: 0 5px;
  font-size: 1em;
  color: #727ff5;
  background-color: #333;
  padding: 8px 16px;
  border: 1px solid #12387e;
  cursor: pointer;
  display: inline-block;
  text-align: center;
}

#page_indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 0 10px;
}

th.sort-asc::after {
  content: " ↑";
}

th.sort-desc::after {
  content: " ↓";
}

/* Mobile responsive styles */
@media screen and (max-width: 768px) {
  /* Navigation */
  nav {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  nav a {
    float: none;
    width: 100%;
    text-align: center;
  }

  /* Table container */
  #table_container {
    width: 95%;
    margin: 0 auto;
    padding: 20px 10px;
  }

  /* Search */
  #search_container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
  }

  #search_box {
    width: 90%;
    margin-bottom: 10px;
  }

  #search_btn,
  #clear_btn {
    width: 90%;
    margin: 5px 0;
    padding: 10px;
    display: block;
  }

  /* Table */
  table {
    display: table;
    width: 100%;
    table-layout: fixed;
    font-size: 0.9em;
    margin: 20px auto;
  }

  th,
  td {
    padding: 8px 5px;
  }

  /* Specific column widths for better display */
  th:nth-child(1),
  td:nth-child(1) {
    /* Position */
    width: 15%;
  }

  th:nth-child(2),
  td:nth-child(2) {
    /* Username */
    width: 30%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  th:nth-child(3),
  td:nth-child(3) /* Unique */,
  th:nth-child(4),
  td:nth-child(4) /* Duplicate */,
  th:nth-child(5),
  td:nth-child(5) {
    /* Total */
    width: 15%;
    text-align: center;
  }

  th:nth-child(6),
  td:nth-child(6) {
    /* Ratio */
    width: 10%;
    text-align: center;
  }

  caption {
    font-size: 1.2em;
    text-align: center;
    width: 100%;
  }

  .pagination {
    width: 100%;
    display: flex;
    justify-content: center;
  }

  .pagination button {
    padding: 10px 15px;
    min-width: 100px;
  }
}

/* Specific styles for medium screens (480px-768px) */
@media screen and (min-width: 481px) and (max-width: 768px) {
  /* Table improvements for this specific range */
  #table_container {
    width: 95%;
    margin: 0 auto;
    padding: 20px 10px;
    box-sizing: border-box;
  }

  table {
    width: 100%;
    margin: 0 auto;
    table-layout: fixed;
    font-size: 0.85em;
    overflow-x: auto;
    display: block;
  }

  /* Make the table scrollable horizontally */
  #leaderboard_table {
    min-width: 100%;
    overflow-x: auto;
  }

  /* Adjust column widths to be proportional */
  th:nth-child(1),
  td:nth-child(1) {
    /* Position */
    width: 60px;
    min-width: 60px;
  }

  th:nth-child(2),
  td:nth-child(2) {
    /* Username */
    width: 30%;
    min-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  th:nth-child(3),
  td:nth-child(3) /* Unique */,
  th:nth-child(4),
  td:nth-child(4) /* Duplicate */,
  th:nth-child(5),
  td:nth-child(5) {
    /* Total */
    width: 15%;
    min-width: 70px;
    text-align: center;
  }

  th:nth-child(6),
  td:nth-child(6) {
    /* Ratio */
    width: 10%;
    min-width: 60px;
    text-align: center;
  }

  /* Improve pagination for this range */
  .pagination {
    flex-wrap: wrap;
    width: 100%;
  }

  .pagination button {
    min-width: 80px;
    padding: 8px 10px;
  }
}

/* For very small screens, stack the button controls */
@media screen and (max-width: 480px) {
  .pagination {
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }

  .pagination button {
    width: 90%;
    margin: 5px 0;
    padding: 10px;
    display: block;
  }

  #page_indicator {
    margin: 5px 0;
  }

  /* Table needs to be scrollable on very small screens */
  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

/* Hamburger menu for very small screens */
@media screen and (max-width: 480px) {
  nav {
    padding: 10px 0;
    min-height: 45px;
  }

  .nav-toggle {
    display: block;
    background: none;
    border: none;
    color: #727ff5;
    font-size: 1.5em;
    position: absolute;
    right: 10px;
    top: 10px;
    cursor: pointer;
    z-index: 10;
  }

  .nav-links {
    display: none;
    width: 100%;
  }

  .nav-links a {
    padding: 12px;
    border-bottom: 1px solid #12387e;
  }

  .nav-links a:last-child {
    border-bottom: none;
  }

  .nav-links.active {
    display: flex;
    flex-direction: column;
    margin-top: 35px;
  }

  /* Add a visible header for the collapsed menu */
  nav::before {
    content: "Menu";
    display: block;
    position: absolute;
    left: 15px;
    top: 13px;
    font-weight: bold;
    color: #727ff5;
  }
}

