@import "theme-colors.css";

html {
  scroll-behavior: smooth;
  background-color: var(--bg-primary);
}

body {
  font-family: Roboto, Arial;
  background-color: var(--bg-primary);
  margin: 0;
  position: relative;
  padding-top: 60px;
  color: var(--text-primary);
}

h1 {
  font-size: 40px;
}

.heading {
  margin-left: 8%;
  margin-bottom: 16px;
  margin-top: 16px;

  display: flex;  
  align-items: center;
  justify-content: space-between;
  width: 85%;
}

.sort-by {
  font-size: 19px;
  font-weight: 200;
  color: var(--text-muted);
}

.sort-buttons {
  display: flex;
  gap: 10px;
  align-items: center;
}

.sort-btn {
  background-color: var(--bg-card);
  border: none;
  border-radius: 8px;
  color: var(--text-primary);
  padding: 6px 14px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

.sort-btn:hover {
  background-color: var(--bg-secondary);
}

.sort-btn-chosen {
  background-color: var(--bg-accent);
}

.section {
  padding: 80px 20px;
  text-align: center;
  color: var(--text-primary);
  box-shadow: 0 -10px 15px var(--shadow);
}

.table {
  background-color: var(--bg-secondary);
  min-width: 700px;
  width: 90%;
  padding-right: 12px;
  max-height: calc(100vh - 268px);
  overflow-y: auto;

  display: flex;
  justify-content: flex-start;
  margin: 10px auto;
  margin-top: 0px;
  border-radius: 12px;
}

.subject-rows {
  border-radius: 12px;
  height: 100%;
  background-color: var(--bg-tertiary);
  padding-top: 0;

  padding-bottom: 12px;

  display: flex;
  flex-direction: column;
  flex: 0 0 140px;
}

.subject-row {
  width: 80%;
  height: 60px;
  margin: 12px 10%;
  margin-bottom: 0;
  background-color: var(--bg-card);
  border-radius: 12px;
  font-weight: bold;

  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2px;
  overflow-wrap:normal;

  text-align: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis; /* shows "..." if too long */
  box-shadow: 5px 5px  10px var(--shadow);
}
.subject-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subject-average {
  font-weight: 200;
  text-align: center;
  position: relative;
}

.subject-info {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  width: 100%;
}

.subject-final {
  font-weight: bold;
  font-size: 20px;
  text-align: center;
}

.grade-rows {
  margin-left: 2%;
  width: 88%;
  height: 100%;
  margin-right: 12px;
  margin-left: 12px;

  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.grade-row {
  margin-top: 12px;
  margin-right: 12px;
  width: 100%;
  height: 60px;
  background-color: var(--bg-tertiary);
  border-radius: 12px;

  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 20px;
  padding-left: 12px;

  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;

  box-sizing: border-box; /* keeps padding inside width */
}

/* ===== Scrollbar Style For Rows ===== */
.grade-row::-webkit-scrollbar {
  height: 8px;
}

.grade-row::-webkit-scrollbar-track {
  background: var(--scroll-track);
  border-radius: 8px;
}

.grade-row::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 8px;
}

.grade-row::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover);
}

.grade-group {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  position: relative;
}

.grade {
  font-size: 30px;
  font-weight: bold;
  line-height: 1;
}


.weight {
  font-size: 16px;
  font-weight: 200;
  margin-left: 4px;
  line-height: 1;
  color: var(--text-secondary);
}

/* ===== Scrollbar Style ===== */
.table::-webkit-scrollbar {
  width: 10px;
}

.table::-webkit-scrollbar-track {
  background: var(--scroll-track);
  border-radius: 8px;
}

.table::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 8px;
  transition: background 0.3s;
}

.table::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover);
}


/* Firefox support *//*
.table {
  scrollbar-width: thin;
  scrollbar-color: #6c6c6c #3a3a3a;  thumb color | track color 
} */

.final-row {
  background-color: var(--bg-secondary);
  min-width: 700px;
  width: 90%;
  padding-right: 12px;
  height: 80px;
  max-height: 100px;
  min-height: 50px;

  display: flex;
  justify-content: flex-start;
  margin: 10px auto;
  margin-top: 0px;
  border-radius: 12px;
}

.average-info {
  border-radius: 12px;
  flex: 0 0 170px;
  height: 100%;
  background-color: var(--bg-accent);
  max-height: 100px;

  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.overall-average {
  font-weight: bold;
}

.container-of-name {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.refresh-btn {
  border:none;
  background-color: transparent;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 20px;
  font-weight: bold;
  padding: 10px;
  border-radius: 10px;
  transition: all 100ms ease-in-out;
}

.refresh-btn:hover {
  color: var(--bg-accent);
}

.refresh-btn:active {
  background-color: var(--bg-secondary);
  color: var(--bg-accent);
}


@media (max-width: 768px) {

  body {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
  }

  h1 {
    font-size: 24px;
  }

  .heading {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-left: 5%;
    width: 90%;
  }

  .sort-buttons {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 6px;
  }

  .sort-btn {
    font-size: 12px;
    padding: 4px 10px;
  }

  .table {
    flex-direction: row;
    width: 95%;
    min-width: auto;
    height: auto;
    max-height: calc(100vh - 268px);
    overflow-y: auto;
  }

  .subject-rows {
    flex-direction: column;
    flex-wrap: wrap;
    padding: 8px 6px;
    margin-right: 6px;
    background: transparent;
    flex: 0 0 90px;
    background-color: var(--bg-tertiary);
  }

  .subject-row {
    width: 100%;
    margin: 6px auto;
    height: 50px;
    font-size: 12px;
  }

  .grade-rows {
    width: 100%;
    margin: 2px 0;
  }

  .grade-row {
    height: 50px;
    font-size: 14px;
    gap: 10px;
    padding-left: 6px;
  }

  .grade {
    font-size: 20px;
  }

  .weight {
    font-size: 12px;
  }

  .final-row {
    flex-direction: row;
    width: 93%;
    min-width: auto;
    height: auto;
    padding: 12px;
    gap: 10px;
    justify-content: center;
    align-items: center;
    margin: 0;
  }

  .average-info {
    flex: 0 0 170px;
    width: auto;
    margin: 0;
    height: 50px;
  }

  .refresh-btn {
    font-size: 26px;
  }

  .container-of-name {
    gap: 6px;
    align-items: space-between;
    justify-content: space-between;
    width: 100%;
  }
}

/* Popup */
.popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.popup.hidden {
  display: none;
}

.popup-content {
  background: var(--popup-bg);
  padding: 20px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 20px;
}

.popup-row {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: end;
  gap: 20px;
  margin-bottom: 20px;
}

.popup-grade {
  font-size: 24px;
  font-weight: bold;
  color: var(--text-primary);
  text-align: center;
}

.popup-weight, .popup-subject {
  font-size: 16px;
  color: var(--text-primary);
  text-align: center;
  padding-bottom: 3px;
}


/* Add subject button */
.add-subject-btn {
  cursor: pointer;
  font-size: 30px;
  font-weight: bold;
  color: var(--text-primary);
  background-color: var(--bg-card);
  border-radius: 12px;
  width: 40px;
  height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background 0.2s;
  box-shadow: 5px 5px 10px var(--shadow);
}

.add-subject-btn:hover {
  background-color: var(--bg-secondary);
}

/* Grade row hover for add grade */
.grade-row {
  cursor: pointer;
  transition: background 0.2s;
}

.grade-row:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Delete buttons */
.delete-subject-btn, .delete-grade-btn {
  background: none;
  border: none;
  color: #ff4444;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  margin-left: 2px;
  vertical-align: middle;
}

.delete-subject-btn:hover, .delete-grade-btn:hover {
  color: #cc0000;
}
.delete-grade-btn {
  margin-left: -8px;
  margin-top: -32px;
}

.delete-subject-btn:hover, .delete-grade-btn:hover {
  color: #cc0000;
}

.delete-subject-btn:hover, .delete-grade-btn:hover {
  color: #cc0000;
}

.add-subject-row {
  cursor: pointer;
}

.add-subject-row:hover {
  background-color: var(--bg-secondary);
}

.add-subject-btn {
  font-size: 24px;
  font-weight: bold;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  grid-column: 1 / -1;
}

/* Popup inputs */
.input-row {
  display: flex;
  flex-direction: column;
  margin-bottom: 12px;
  gap: 4px;
  width: 80%;
  margin-left: -18px;
}

.input-row label {
  font-weight: bold;
  color: var(--text-primary);
  font-size: 14px;
}

.popup-content input {
  padding: 8px;
  border: 1px solid var(--text-secondary);
  border-radius: 4px;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  width: 100%;
}

.popup-content button {
  padding: 8px 16px;
  background-color: var(--bg-accent);
  color: var(--text-primary);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  width: 100%;
  margin-top: 10px;
}

.popup-content button:hover {
  background-color: var(--bg-secondary);
}