:root {
  --bg-color: #084770;
  --active-bg-color: #fafab3;
  --active-border: 1px dotted #000;
  --light-text-color: #999;
  --lighter-text-color: #ddd;
  --light-border-color: #eee;
  --mid-border-color: #555;
  --required-color: #6a9bc9;
  --control-button-color: #f1f1f1;
  --text-light-background: #f7f7f7;
  --table-head-background-color: #b8b3c0;
  --table-row-head-background-color: #e2e0e6;
  --table-row-background-color-even: #e2e0e6;
  --table-row-background-color-odd: #fff;
  --table-row-background-color-hover: #fafab3;
  --action-button-color: #084770;
  --submit-button-color: #81a2ed;
}

body {
  font-family: sans-serif;
  margin: 0;
  padding: 0;
  background-color: var(--bg-color);
  font-size: 1em;
}

button,
[hx-delete],
[hx-get] {
  cursor: pointer;
}

h2,
h3,
h4 {
  text-align: center;
}

h3 ul {
  list-style: none;
}

p.note {
  font-size: smaller;
  color: var(--light-text-color);
  border-top: 2px solid var(--light-border-color);
  padding-top: 0.5em;
}

item-header {
  display: block;
  border-bottom: 1px solid var(--light-border-color);
  max-width: 50%;
  margin: auto;
  margin-bottom: 2em;
}

item {
  display: block;
  max-width: 50%;
  margin: auto;
}

/* Form Styles */
form {
  padding: 2em;
  max-width: 50%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1em; /* Space between form elements */

  .form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1em 1.5em;
  }
}

fieldset {
  border: none;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 1.5em;

  legend {
    font-weight: bold;
    margin-right: 1em;
  }
}

label {
  display: flex;
  flex-direction: column;
  font-weight: bold;
}

label:has(input:required) span::after,
label:has(textarea:required) span::after,
label:has(select:required) span::after {
  content: ' *';
  color: var(--required-color);
}

fieldset:has(input:required) legend::after,
fieldset:has(select:required) legend::after,
fieldset:has(textarea:required) legend::after {
  content: ' *';
  color: var(--required-color);
}

label:has(input[type='radio']),
label:has(input[type='checkbox']) {
  display: inline;
}

label p {
  font-weight: initial;
  font-size: smaller;
  margin-top: 0.5em;
  margin-bottom: 1.5em;
}

input[type='text'],
input[type='email'],
input[type='password'],
textarea,
select {
  padding: 0.5em;
  border: 0.0625em solid var(--light-border-color);
  border-radius: 0.3125em;
  font-size: 1em;
  background-color: #fff;
}

button.action {
  background-color: var(--action-button-color);
  color: #fff;
  border: none;
  padding: 0.625em 1.25em;
  font-size: 1em;
  cursor: pointer;
  border-radius: 0.3em;
}

button[type='submit'] {
  background-color: var(--submit-button-color);
  border: none;
  padding: 0.625em 1.25em;
  font-size: 1em;
  cursor: pointer;
  border-radius: 0.3em;
}

button[type='submit']:hover {
  background-color: #6a9bc9;
}

#app-container {
  display: flex;
  flex-direction: column;
  width: 95%;
  min-height: 95%;
  margin: 20px auto;
  background-color: #fff;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
}

header.user {
  padding: 0.5em;
  justify-content: space-between;

  div {
    display: flex;

    icon {
      margin: 0 0.5em;
    }
  }
}

header {
  background-color: #fff;
  padding: 20px;
  border-bottom: 1px solid var(--light-border-color);
  display: flex;
  align-items: center;
  justify-content: space-evenly;

  nav {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    border: 2px solid #000;
    border-radius: 8px;
    padding: 0.5em;
    background-color: var(--control-button-color);

    ul {
      list-style: none;
      padding: 0;
      margin: 0;
      display: flex;
      justify-content: space-evenly;
      width: 100%;
    }

    li {
      width: 4em;
      background-color: #fff;
      text-align: center;
      padding: 0.5em;
      margin: 0 0.2em;
      border: 1px solid var(--mid-border-color);
      border-radius: 8px;

      p {
        white-space: nowrap;
        font-size: 75%;
        margin: 0;
      }

      img {
        margin: 0;
        width: 3em;
        height: 3em;
      }
    }

    li:hover {
      border: 1px solid #000;
    }

    .active {
      background-color: var(--active-bg-color);
      border: var(--active-border);
    }
  }
}

#all-form {
  display: flex;
  justify-content: space-evenly;

  div {
    width: 7em;
    background-color: #fafafa;
    text-align: center;
    padding: 0.5em;
    margin: 0 0.2em;
    border: 2px solid var(--mid-border-color);
    border-radius: 8px;
  }

  div:hover {
    background-color: var(--active-bg-color);
  }

  img {
    margin: 0;
    width: 5em;
    height: 5em;
  }
}

footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: smaller;
  background-color: #e5e5e5;
  padding: 10px;
  border-top: 1px solid var(--light-border-color);
  color: var(--light-text-color);

  a {
    color: var(--light-text-color);
  }

  button {
    border: 1px solid var(--light-text-color);
    padding: 5px 10px;
    background-color: #fff;
    border-radius: 5px;
    margin: 2px;
  }
}

.filter-buttons {
  display: flex;
  flex-wrap: wrap; /* Allow buttons to wrap */
  flex-basis: calc(25% - 4px); /* Adjust as needed */
  margin: auto 10px;
  border: 2px solid #000;
  border-radius: 8px;
  padding: 0.5em;
  white-space: nowrap;
  background-color: var(--control-button-color);
}

.filter-buttons button {
  border: 1px solid var(--light-text-color);
  padding: 5px 10px;
  background-color: #fff;
  border-radius: 5px;
  margin: 2px;
  flex-basis: calc(50% - 4px); /* Adjust as needed */
  box-sizing: border-box;
}

.filter-buttons button.active {
  background-color: var(--active-bg-color);
  border: var(--active-border);
}

em.add-mine {
  background-color: var(--active-bg-color);
  border: 2px solid #000;
  border-radius: 8px;
  padding: 0.5em;
  justify-content: center;
  align-items: center;
  text-align: center;
}

button.add-mine {
  background-color: var(--action-button-color);
  color: var(--lighter-text-color);
  border: 2px solid #000;
  border-radius: 8px;
  padding: 0 1em 0.5em 1em;

  display: flex;
  flex-direction: column; /* Stacks the image above the text */
  justify-content: center; /* Centers content vertically */
  align-items: center; /* Centers content horizontally */
  text-align: center;

  .text-icon {
    margin: 0;
    padding: 0;
    font-size: 300%;
    font-weight: bold;
  }
}

.contact-info {
  border: 1px dotted var(--mid-border-color);
  padding: 1.5em;
  width: fit-content;

  ul {
    list-style: none;
  }
}

main {
  padding: 20px;
  flex: 1;
  overflow-y: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0; /* Remove default table margin */
}

th,
td {
  padding: 10px;
  border: 1px solid #ddd;
  text-align: left;
}

th {
  font-weight: bold;
}

thead {
  background-color: var(--table-head-background-color);
  color: white;

  tr {
    border-bottom: 1px solid #007bff;
  }
}

tbody tr.odd {
  background-color: var(--table-row-background-color-odd);
}

tbody tr.even {
  background-color: var(--table-row-background-color-even);
}

tbody tr:hover {
  background-color: var(--table-row-background-color-hover);
}

/* Sticky column header */
table {
  overflow: scroll;
}

thead th {
  position: -webkit-sticky; /* for Safari */
  position: sticky;
  top: 0;
  z-index: 20;
}
/* END Sticky column header */

/* Sticky row "header" */
thead th:first-child {
  left: 0;
}

tbody th {
  position: -webkit-sticky; /* for Safari */
  position: sticky;
  left: 0;
  z-index: 10;
  border-right: 0.0625em solid var(--light-text-color);
  border-bottom: 0.0625em solid #bbb;
  background-color: var(--table-row-head-background-color);
  text-align: center;
  padding: initial;
}
/* END Sticky row "header" */

div.tos {
  border: 1px solid #bbb;
  background-color: var(--text-light-background);
  padding: 0.5em;
}

/* Responsive adjustments (example) */
@media (max-width: 768px) {
  form {
    max-width: 100%;

    .form-grid {
      grid-template-columns: 1fr;
    }
  }

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

  .filter-buttons {
    flex-direction: column;
    margin-right: 0;
    margin-bottom: 10px;
    width: 100%; /* Full width on smaller screens */
  }

  .filter-buttons button {
    flex-basis: calc(50% - 4px); /* Each button takes up roughly 50% of the container */
  }
}

alerts {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;

  div {
    opacity: 0;
    transform: translateY(8px);
    animation: alert-in 0.2s ease-out forwards;
  }
}

.error {
  padding: 0.5em 1em;
  margin: 0.3em 0;
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
  border-radius: 4px;
}

@keyframes alert-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}
