* {
  box-sizing: border-box;
  font-family: "Saira", sans-serif;
}

body {
  margin: 0;
  padding: 0;
  color: #222;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: #333;
  width: 100%;
  padding: 1rem 2rem;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;

  & h1 {
    color: #fff;
    margin: 0;
    font-size: 1.5rem;
  }

  & ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 0.5rem;
  }

  & li {
    display: inline;
  }

  & a {
    display: inline-block;
    padding: 0.5rem 1rem;
    background-color: #555;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    transition: background-color 0.15s ease;

    &:hover {
      background-color: #666;
    }
  }
}

main {
  flex: 1;
  padding: 2rem;
  background: #ddd;
}

h1 {
  margin-top: 0;
}

.error {
  color: #c53030;
}

footer {
  font-size: 0.85rem;
  color: #888;
  border-top: 1px solid #ddd;
  padding: 2rem;

  & p {
    margin: 0;
  }

  & .footer-detail {
    margin-top: 0.25rem;
    color: #a33;
  }

  & a {
    color: #2c7be5;
    font-weight: 500;
    text-decoration: none;

    &:hover {
      text-decoration: underline;
    }
  }
}

table {
  width: 100%;
  max-width: 56rem;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);

  & thead {
    background-color: #5a67d8;
    color: white;

    & th {
      padding: 0.4rem 0.4rem;
      text-align: left;
      font-weight: 600;
      font-size: 0.9rem;
      letter-spacing: 0.025em;
    }

    & .col-type {
      width: 8%;
    }

    & .col-asset {
      width: 50%;
    }

    & .col-price {
      width: 15%;
      text-align: right;
    }

    & .col-prev-price {
      width: 15%;
      text-align: right;
    }

    & .col-change {
      width: 12%;
      text-align: right;
    }
  }

  & tbody {
    & tr {
      min-height: 1rem;
      background-color: #fff;
      cursor: pointer;

      &.even-row {
        background-color: #eee;
      }

      &:hover {
        background-color: #ff8;
      }

      &:last-child td {
        border-bottom: none;
      }
    }

    & td {
      padding: 0.2rem 0.4rem;
      color: #444;
    }

    & .col-type {
      font-size: 0.75rem;
      color: #888;
    }

    & .col-asset {
      & details {
        & summary {
          cursor: pointer;
          list-style: none;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;

          &::-webkit-details-marker {
            display: none;
          }
        }

        & p {
          margin: 0.25rem 0;
        }
      }
    }

    & .col-price {
      font-family: "Martian Mono", monospace;
      font-size: 1rem;
      font-weight: 500;
      text-align: right;
    }

    & .col-prev-price {
      font-family: "Martian Mono", monospace;
      font-size: 1rem;
      font-weight: 500;
      text-align: right;
      color: #666;
    }

    & .col-change {
      font-family: "Martian Mono", monospace;
      font-size: 0.8rem;
      text-align: right;
      font-weight: 600;

      &.positive {
        color: #16a34a;
      }

      &.negative {
        color: #dc2626;
      }
    }
  }

  & .timestamp-sub {
    font-family: "Saira", sans-serif;
    font-size: 0.7rem;
    font-weight: 300;
    color: #aaa;
    margin-top: 0.2rem;
  }

  & .asset-short {
    font-family: "Saira", sans-serif;
  }

  & .asset-medium {
    font-family: "Saira Condensed", sans-serif;
  }

  & .asset-long {
    font-family: "Saira Condensed", sans-serif;
    letter-spacing: -0.04em;
  }

  & .asset-verylong {
    font-family: "Saira Condensed", sans-serif;
    letter-spacing: -0.04em;
  }
}

.filters {
  margin-bottom: 1rem;
  display: flex;
  gap: 1rem;

  & input {
    border: none;
    border-radius: 6px;
    padding: 0.25rem 0.5rem;
    font-size: 0.9rem;
    background: #f0f0f0;

    &:focus {
      border: none;
      outline: none;
      background: #fff;
    }
  }

  .toggle {
    & input {
      display: none; /* hide real checkbox */
    }

    & label {
      display: inline-block;
      padding: 6px 14px;
      border-radius: 6px;
      border: 1px solid #ccc;
      cursor: pointer;
      background: #f3f3f3;
      transition: all 0.15s ease;
      font-size: small;

      &:hover {
        background: #e6e6e6;
      }
    }

    & input:checked + label {
      background: #2c7be5;
      color: white;
      border-color: #2c7be5;
    }
  }
}

/* Mobile responsive layout */
@media (max-width: 768px) {
  table {
    border-radius: 0;
    box-shadow: none;

    & thead {
      display: none; /* Hide table headers on mobile */
    }

    & tbody {
      & tr {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        grid-template-rows: auto auto;
        gap: 0.5rem 0.75rem;
        padding: 0.75rem;
        margin-bottom: 0.5rem;
        border-radius: 8px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);

        &:last-child {
          margin-bottom: 0;
        }
      }

      & td {
        padding: 0;
        border: none;
      }

      /* First row: Type and Asset */
      & .col-type {
        grid-column: 1;
        grid-row: 1;
        font-size: 0.7rem;
        padding-right: 0.5rem;
        align-self: start;
      }

      & .col-asset {
        grid-column: 2 / 4;
        grid-row: 1;
        font-size: 0.95rem;
      }

      /* Second row: Price, Prev Close, Change - equal width columns */
      & .col-price {
        grid-column: 1;
        grid-row: 2;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        font-size: 0.85rem;

        &::before {
          content: 'Price';
          font-size: 0.65rem;
          color: #888;
          font-family: "Saira", sans-serif;
          font-weight: 400;
          margin-bottom: 0.15rem;
        }
      }

      & .col-prev-price {
        grid-column: 2;
        grid-row: 2;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        font-size: 0.85rem;

        &::before {
          content: 'Prev';
          font-size: 0.65rem;
          color: #888;
          font-family: "Saira", sans-serif;
          font-weight: 400;
          margin-bottom: 0.15rem;
        }
      }

      & .col-change {
        grid-column: 3;
        grid-row: 2;
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        font-size: 0.85rem;
      }

      & .timestamp-sub {
        font-size: 0.6rem;
      }
    }
  }
}
