
:root {
  --font: 'Montserrat', sans-serif;
  --transition-short: 0.1s;
  --yellow: #FFD966;
  --red: #C00000;
  --green: #92D050;
  --gray: #2b2b2b;
  --blue: #33bce8;

  --b-red: #C00000;
  --b-green: #1aa814;
  --b-blue: #33bce8;
  --b-olive: #8f910f;
  --b-olive-light: #c3be14;

  --br-large: 11px;
  --br-small: 6px;
}

body {
  font-family: var(--font);
  color: var(--gray);
  background: linear-gradient(40deg, #ffffff 0%, #f5f5e8 50%, #e8e8d0 100%);
  min-height: 100vh;
  margin: 0;
}

button,
input[type=submit] {
  font-family: var(--font);
  background: white;
  border-radius: var(--br-small);
  padding: .5rem 1.5rem;
  border: none;
  box-shadow: 0px 2px 10px 0px rgba(0,0,0,0.3);
  cursor: pointer;
}

input {
  font-family: var(--font);
}

button.colored,
input[type=submit].colored {
  color: white;
  background: var(--b-green);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  transition: all var(--transition-short);
}

button.colored:hover,
input[type=submit].colored:hover {
  background: #22c41c;
  transform: translateY(-2px);
  box-shadow: 0px 4px 15px 0px rgba(26, 168, 20, 0.4);
}

/* #region general */

.container {
  max-width: 1024px;
  margin: 2rem auto;
  position: relative;
}

@media only screen and (max-width: 1088px) {
  .container {
    margin: 2rem;
  }
}

/* #endregion */

/* #region stopwatch */

#stopwatch {
  width: 100%;
  height: 4rem;
  /* background: red; */
  position: relative;
  margin: 2rem auto;
  margin-top: 3rem;
  border-radius: var(--br-large);
  overflow: hidden;
  box-shadow: 0px 2px 18px 0px rgba(0,0,0,0.3);
}

#stopwatch.hide {
  filter: grayscale(70%);
}

#stopwatch-bg {
  display: flex;
  width: 100%;
  height: 100%;
}

#stopwatch-fg {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}

.stopwatch-stage {
  position: absolute;
  top: 50%;
  /* transform: translate(1rem, -50%); */
  color: white;
  font-weight: bold;
  display: inline-block;
  white-space: nowrap;
}

.stopwatch-stage.move {
  /* left: 50%;
  transform: translate(-50%, -50%); */
}
.stopwatch-stage.background {
  color: black;
  visibility: hidden;
}

.stopwatch-bar {
  width: 10%;
  height: 100%;
  /* background: green; */
  position: relative;
  transition: background var(--transition-short);
  box-shadow: 0px 2px 18px 0px rgba(0,0,0,0.3);
}

.stopwatch-bar.main {
  position: absolute;
  top: 0;
  /* background: yellow; */
  overflow: hidden;
}

#stopwatch-bg .region {
  opacity: 0.5;
}
#stopwatch-bg .region:nth-child(1) {
  background: var(--yellow);
  flex-grow: 25;
}
#stopwatch-bg .region:nth-child(2) {
  background: var(--red);
  flex-grow: 25;
}
#stopwatch-bg .region:nth-child(3) {
  background: var(--green);
  flex-grow: 10;
}

/* #endregion */


/* #region table */

#data-table {
  width: 100%;
  border-radius: var(--br-small);
  overflow: hidden;
  /* border: solid 0.1rem transparent; */
}

#table {
  transition: transform var(--transition-short);
}

#table-container {
  height: 30rem;
  overflow: hidden;
}

#table input {
  padding: 0;
  margin: 0;
}

.table-row,
.table-header {
  display: flex;
  width: 100%;
}

.table-header {
  color: white;
  box-shadow: 0px 2px 18px 0px rgba(0,0,0,0.3);
  z-index: 5;
  position: relative;
}

.table-row > *,
.table-header > * {
  flex: 1;
  text-align: center;
  width: 33.3333333333%;
}

.table-row:nth-child(1) .table-cell:first-child {
  background-color: #FFD966;
}
.table-row:nth-child(1) .table-cell {
  background-color: #FFE699;
}
.table-row:nth-child(31) .table-cell:first-child {
  background-color: #0DB0F1;
  color: white;
}
.table-row:nth-child(31) .table-cell {
  background-color: #BDD7EE;
}

.table-row:hover {
  opacity: 0.8;
}

.table-cell {
  background: #E2EFD9;
  /* border: solid 0.05rem white; */
  /* border: solid 0.1rem black; */
  box-sizing: border-box;
}
.table-cell:first-child {
  background: #A8D08D;
}
.table-header .table-cell {
  background: #137F0E;
}

.water,
.toilet,
.yawning {
  cursor: pointer;
  position: relative;
  pointer-events: auto;
}

input[type=checkbox] {
  cursor: pointer;
}

.water:hover::before {
  content: "Water";
}
.toilet:hover::before {
  content: "Toilet";
}
.yawning:hover::before {
  content: "Yawning";
}

.water::before,
.toilet::before,
.yawning::before {
  position: absolute;
  background: rgba(0,0,0,0.8);
  color: white;
  border-radius: var(--br-small);
  padding: 0.5rem 1rem;
  left: 0.5rem;
  top: 0.5rem;
  transform: translate(-100%, -100%);
  opacity: 0;
  transition: opacity var(--transition-short);
  pointer-events: none;
}

.water:hover::before,
.toilet:hover::before,
.yawning:hover::before {
  opacity: 1;
}

#test-help,
#test-help-close {
  background: var(--b-blue);
  transition: transform var(--transition-short);
}
#test-help {
  font-weight: bold;
  font-size: 1.5rem;
  padding: 1rem 1.5rem;
  position: absolute;
  right: 2rem;
  top: 2rem;
}

#test-help-close {
  margin-top: 3rem;
}

#test-help:hover,
#test-help-close:hover {
  transform: scale(1.1);
}

#test-help-page {
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-short);
  background: white;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  width: 100%;
  height: 100%;
  overflow: auto;
}

#test-help-page.show {
  opacity: 1;
  pointer-events: auto;
}

#test-help-page .center {
  margin: 2rem auto;
  max-width: 1024px;
}

@media only screen and (max-width: 1088px) {
  #test-help-page .center {
    margin: 2rem;
  }
}

#test-help-page table {
  text-align: left;
  border: solid #BDD7EE 2px;
  border-radius: var(--br-large);
  border-spacing: 0;
}

#test-help-page table td,
#test-help-page table th {
  padding: 0.2rem;
}

#test-help-page table td:first-child,
#test-help-page table th:first-child {
  /* padding-left: 2rem; */
}

.row-primary {
  background-color: #BDD7EE;
}

.row-secondary {
  background-color: #DDEBF7;
  height: 2rem;
}

.cell-note {
  background-color: #8EA9DB;
}

/* #endregion */

/* #region substance */

#substance-popup {
  pointer-events: none;
  z-index: 10;
  background: rgba(0,0,0,0.3);
  opacity: 0;
  width: 100vw;
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
}

#substance-popup.show {
  pointer-events: auto;
  opacity: 1;
}

#substance-container {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: white;
  width: 25rem;
  max-width: 80%;
  padding: 4rem 2rem;
  box-sizing: border-box;
  border-radius: var(--br-large);
}

#substance-center {
  text-align: center;
  /* margin: auto;
  display: inline-block;
  position: absolute;
  left: 50%;
  transform: translate(-50%, -50%); */
}

#substance-display {
  display: inline;
  font-size: 1rem;
  font-weight: normal;
  margin: 2rem 2rem 0 0;
}

#substance-edit {
  display: block;
}

@media only screen and (min-width: 720px) {
  #substance-edit {
    display: inline-block;
  }
}

#test-complete {
  width: 100vw;
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  background: rgba(0,0,0,0.5);
  color: white;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-short);
  z-index: 8;
}
#test-complete.show {
  opacity: 1;
  pointer-events: auto;
}

#test-complete .center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

@keyframes test-complete {
  35% { transform: scale(1); }
  50% { transform: scale(1.5); }
  65% { transform: scale(1); }
}

#test-complete img {
  width: 5rem;
  height: 5rem;
  animation: test-complete 2s infinite;
  transform-origin: bottom;
}

#test-complete h2 {
  font-weight: normal;
}

#runtime {
  text-align: left;
  margin: 3rem auto;
  margin-top: 2rem;
  font-size: 2rem;
}

/* #endregion */

/* #region login */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(40deg, #ffffff 0%, #f0f0e0 100%);
}

.login-container {
  background: white;
  padding: 3rem;
  border-radius: var(--br-large);
  box-shadow: 0px 4px 25px 0px rgba(0,0,0,0.15);
  text-align: center;
  max-width: 400px;
  width: 90%;
  margin: 2rem auto;
}

.login-container h1 {
  color: var(--b-green);
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-size: 2rem;
}

.login-container .subtitle {
  color: var(--b-olive);
  margin-bottom: 2rem;
  font-size: 0.9rem;
}

.login-container .logo {
  width: 80px;
  height: auto;
  margin-bottom: 1.5rem;
}

.login-form input[type="text"],
.login-form input[type="password"] {
  display: block;
  width: 100%;
  padding: 1rem;
  margin-bottom: 1rem;
  border: 2px solid #e0e0e0;
  border-radius: var(--br-small);
  box-sizing: border-box;
  font-size: 1rem;
  transition: border-color var(--transition-short);
}

.login-form input[type="text"]:focus,
.login-form input[type="password"]:focus {
  outline: none;
  border-color: var(--b-olive);
}

.login-form input[type="submit"] {
  width: 100%;
  padding: 1rem;
  font-size: 1rem;
  margin-top: 0.5rem;
}

.login-container .error {
  background: #ffe0e0;
  color: var(--b-red);
  padding: 0.75rem;
  border-radius: var(--br-small);
  margin-bottom: 1rem;
}

/* #endregion */

/* #region admin header */

.admin-header {
  background: linear-gradient(135deg, var(--b-green) 0%, #15850f 100%);
  color: white;
  padding: 1.5rem 2rem;
  margin: -2rem -2rem 2rem -2rem;
  border-radius: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

@media only screen and (min-width: 1088px) {
  .admin-header {
    margin: 0 0 2rem 0;
    border-radius: var(--br-large) var(--br-large) 0 0;
  }
}

.admin-header h1 {
  margin: 0;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-header-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.admin-header button {
  background: rgba(255,255,255,0.2);
  color: white;
  border: 2px solid rgba(255,255,255,0.5);
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

.admin-header button:hover {
  background: rgba(255,255,255,0.3);
  border-color: white;
}

.admin-card {
  background: white;
  border-radius: var(--br-large);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0px 2px 15px 0px rgba(0,0,0,0.08);
}

.admin-card h3 {
  margin-top: 0;
  color: var(--b-olive);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #f0f0e0;
}

.admin-container {
  max-width: 1024px;
  margin: 0 auto;
  padding: 2rem;
}

@media only screen and (min-width: 1088px) {
  .admin-container {
    background: white;
    border-radius: var(--br-large);
    box-shadow: 0px 4px 25px 0px rgba(0,0,0,0.1);
    margin: 2rem auto;
    padding: 0;
    overflow: hidden;
  }

  .admin-content {
    padding: 2rem;
  }
}

/* #endregion */

/* #region admin */

#loading {
  width: 100vw;
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  background: rgba(0,0,0,0.5);
  color: white;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-short);
  z-index: 8;
}
#loading.show {
  opacity: 1;
  pointer-events: auto;
}

#loading .center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

@keyframes loading {
  35% { transform: scale(1); }
  50% { transform: scale(1.5); }
  65% { transform: scale(1); }
}

#loading img {
  width: 5rem;
  height: 5rem;
  animation: loading 2s infinite;
  transform-origin: bottom;
}

#loading h2 {
  font-weight: normal;
}

#pagination {
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  display: inline-block;
}

#pagination-left,
#pagination-right {
  display: none;
}
#pagination-left.show,
#pagination-right.show {
  display: inline;
}

#search-container,
#search-result {
  /* display: inline-block; */
}

#search-result {
  display: block;
}

.user {
  display: block;
  width: calc(100% - 2rem);
  margin: 0.75rem;
  box-shadow: 0px 2px 10px 0px rgba(0,0,0,0.1);
  border-radius: var(--br-small);
  padding: 1rem;
  box-sizing: border-box;
  border-left: 4px solid var(--b-green);
  background: #fafafa;
  transition: all var(--transition-short);
}

.user:hover {
  box-shadow: 0px 4px 15px 0px rgba(0,0,0,0.15);
  transform: translateY(-2px);
}

@media only screen and (min-width: 720px) {
  #search-result {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-content: space-between;
  }
  .user {
    display: inline-block;
    width: calc(50% - 2rem);
  }
}

@media only screen and (min-width: 1088px) {
  #search-result {
  }

  .user {
    width: calc(33.3% - 2rem);
  }
}


.user-row {
  display: flex;
  justify-content: space-between;
}

.user-row:first-child {
  margin-bottom: 0.5rem;
}

#search-legend > *,
.user-row > * {
  flex: 1;
  text-align: center;
}

.user-row > button:first-child {
  margin-right: 0.5rem;
}

.user-link {
  background: var(--b-green) !important;
  color: white !important;
}

.user-delete {
  background: #f5f5f5 !important;
  color: var(--b-red) !important;
  border: 1px solid #ddd !important;
}

.user-delete:hover {
  background: var(--b-red) !important;
  color: white !important;
}

/* #logout position handled by admin-header-actions */

#search-form {
  padding-left: 1rem;
}

#create-form {
  margin: 3rem auto;
}

#search {
  width: 12rem;
}


#email-edit.hide,
#email-input.hide,
#email-save.hide {
  display: none;
}

.user-testing-label:hover {
  cursor: pointer;
}

/* #endregion */

/* #region dialogs */

#dialog-overlay {
  width: 100vw;
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  background: rgba(0,0,0,0.8);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-short);
  z-index: 100;
}

#dialog-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.dialog {
  background: white;
  width: 25rem;
  text-align: center;
  padding: 4rem 2rem;
  border-radius: var(--br-large);
  margin: auto;
  margin-top: 4rem;
}

#dialog-confirm {
  display: none;
}
#dialog-confirm.show {

  display: block;
}
#dialog-alert {

  display: none;
}
#dialog-alert.show {

  display: block;
}

.dialog-yes,
.dialog-no,
.dialog-ok {
  padding: 0.5rem 1rem;
  border-radius: var(--br-small);
  cursor: pointer;
}

.dialog-yes {
  background: var(--b-green);
}
.dialog-no {
  background: var(--b-red);
}
.dialog-ok {
  background: var(--b-blue);
}

/* #endregion */

/* #region password popup */

#password-popup {
  pointer-events: none;
  z-index: 100;
  background: rgba(0,0,0,0.5);
  opacity: 0;
  width: 100vw;
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  transition: opacity var(--transition-short);
}

#password-popup.show {
  pointer-events: auto;
  opacity: 1;
}

#password-container {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: white;
  width: 25rem;
  max-width: 90%;
  padding: 2rem;
  box-sizing: border-box;
  border-radius: var(--br-large);
  box-shadow: 0px 2px 18px 0px rgba(0,0,0,0.3);
}

#password-form {
  text-align: center;
}

#password-form h3 {
  margin-top: 0;
  margin-bottom: 1.5rem;
}

#password-form input[type="password"] {
  display: block;
  width: 100%;
  padding: 0.75rem;
  margin-bottom: 1rem;
  border: 1px solid #ccc;
  border-radius: var(--br-small);
  box-sizing: border-box;
  font-size: 1rem;
}

#password-error {
  color: var(--b-red);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

#password-error.hide {
  display: none;
}

/* #change-password position handled by admin-header-actions */

.btn-cancel {
  background: #f5f5f5;
  color: var(--b-red);
  border: 1px solid #ddd;
}

.btn-cancel:hover {
  background: var(--b-red);
  color: white;
}

.btn-save {
  margin-left: 0.5rem;
}

.error {
  color: var(--b-red);
}

/* #endregion */

/* #region test page */

.test-page {
  background: linear-gradient(40deg, #ffffff 0%, #f0f0e0 100%);
  min-height: 100vh;
}

.test-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0;
}

.test-header {
  background: linear-gradient(135deg, var(--b-green) 0%, #15850f 100%);
  color: white;
  padding: 1.5rem 2rem;
  text-align: center;
}

.test-header h1 {
  margin: 0;
  font-size: 1.8rem;
}

.test-header .subtitle {
  margin: 0.25rem 0 0 0;
  opacity: 0.9;
  font-size: 0.9rem;
}

.test-content {
  padding: 1.5rem;
}

.test-card {
  background: white;
  border-radius: var(--br-large);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0px 2px 15px 0px rgba(0,0,0,0.08);
}

.test-card h2 {
  margin-top: 0;
  font-size: 1.1rem;
  color: var(--gray);
}

.test-card h2 strong {
  color: var(--b-green);
}

.test-error {
  background: #ffe0e0;
  color: var(--b-red);
  padding: 2rem;
  border-radius: var(--br-large);
  text-align: center;
}

.test-error p {
  margin: 0;
  font-size: 1.1rem;
}

/* Runtime display */
#runtime {
  text-align: center;
  margin: 1rem 0;
}

#runtime-display {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--b-green);
  margin: 0;
  font-family: monospace;
}

/* Data table styling */
.test-card #data-table {
  margin: 0;
}

.test-card .table-header {
  background: var(--b-olive);
  color: white;
  border-radius: var(--br-small) var(--br-small) 0 0;
  font-weight: 600;
}

.test-card .table-row:nth-child(even) {
  background: #f8f8f0;
}

.test-card .table-row input[type="text"] {
  border: 1px solid #ddd;
  border-radius: var(--br-small);
  padding: 0.4rem;
  width: 100%;
  box-sizing: border-box;
}

.test-card .table-row input[type="text"]:focus {
  border-color: var(--b-olive);
  outline: none;
}

/* Substance popup */
#substance-popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.6);
  display: none;
  z-index: 100;
}

#substance-popup.show {
  display: block;
}

#substance-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  padding: 2rem;
  border-radius: var(--br-large);
  box-shadow: 0px 4px 25px 0px rgba(0,0,0,0.2);
  max-width: 400px;
  width: 90%;
}

#substance-center h3 {
  margin-top: 0;
  color: var(--b-green);
}

#substance-center input[type="text"],
#substance-center select {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid #e0e0e0;
  border-radius: var(--br-small);
  box-sizing: border-box;
  font-size: 1rem;
}

#substance-center input[type="text"]:focus,
#substance-center select:focus {
  border-color: var(--b-olive);
  outline: none;
}

/* Test complete overlay */
#test-complete {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(255,255,255,0.95);
  display: none;
  z-index: 100;
}

#test-complete.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

#test-complete .center {
  text-align: center;
  padding: 2rem;
}

#test-complete img {
  width: 80px;
  margin-bottom: 1rem;
}

#test-complete h2 {
  color: var(--b-green);
  margin-bottom: 0.5rem;
}

#test-complete p {
  color: var(--gray);
}

/* Help button */
#test-help {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  font-size: 1.5rem;
  padding: 0;
  z-index: 50;
}

/* Help page overlay */
#test-help-page {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.8);
  display: none;
  z-index: 100;
  overflow-y: auto;
}

#test-help-page.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.help-card {
  background: white;
  padding: 2rem;
  border-radius: var(--br-large);
  max-width: 600px;
  width: 90%;
  margin: 2rem auto;
}

.help-card h3 {
  margin-top: 0;
  color: var(--b-green);
  text-align: center;
}

.help-card table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
}

.help-card table th,
.help-card table td {
  padding: 0.5rem;
  text-align: left;
  border-bottom: 1px solid #eee;
}

.help-card table th {
  color: var(--b-olive);
  font-weight: 600;
}

.help-card .cell-note {
  background: #fff8e0;
  padding: 1rem;
  border-radius: var(--br-small);
  text-align: center;
}

.help-card button {
  display: block;
  width: 100%;
}

/* Report labels (W, T, Y) */
.test-card label.water,
.test-card label.toilet,
.test-card label.yawning {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: var(--br-small);
  margin: 0.1rem;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
}

.test-card label.water {
  background: #e0f0ff;
  color: #0066cc;
}

.test-card label.toilet {
  background: #f0e0ff;
  color: #6600cc;
}

.test-card label.yawning {
  background: #fff0e0;
  color: #cc6600;
}

.test-card label input[type="checkbox"] {
  display: none;
}

.test-card label.water:has(input:checked) {
  background: #0066cc;
  color: white;
}

.test-card label.toilet:has(input:checked) {
  background: #6600cc;
  color: white;
}

.test-card label.yawning:has(input:checked) {
  background: #cc6600;
  color: white;
}

/* #endregion */
