:root {
  --legend-width: 333px;
  --legend-background-color: rgba(255, 255, 255, 0.836);
  --weatherCodeIconWidth: 27;
  --night-background-color: rgba(128, 128, 128, 0.2);
}

@media (prefers-color-scheme: dark) {
  :root {
    --night-background-color: hsl(0, 0%, 4%);
    --legend-background-color: rgba(0, 0, 0, 0.836);
  }
}

body {
  min-height: 100vh;

  .fullWidthContainer:has(header) {

    .container {
      padding-left: 5px;
    }
  }

  .fullWidthContainer:has(main) {
    flex: 1;
  }

  .fullWidthContainer:has(main) {
    .container {
      display: flex;
      flex-direction: column;
      flex: 1;
      padding-left: 0px;
      padding-right: 0px;

      main {
        flex: 1;
      }

      #charts-daily>footer,
      #charts-hourly>footer {
        padding-left: 15px;
        padding-right: 15px;
      }
    }
  }

  main {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;

    /* max-width: 1200px; */
    main.container {
      flex: 1;
      display: flex;
      flex-direction: column;
    }
  }
}

.header {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;

  .left {
    display: flex;
    align-items: center;
    cursor: pointer;

    .locationName {
      /* font-size: 12px; */
      flex: 1;
    }

    svg {
      margin-left: 5px;
      height: 16px;
      width: 16px;
    }
  }

  .right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    position: relative;

    .trialCallout {
      display: flex;
      align-items: center;
      gap: 8px;
      font-size: 13px;
      white-space: nowrap;

      .trialButton {
        background: #f1c40f;
        color: #000;
        padding: 4px 10px;
        border-radius: 4px;
        font-weight: 600;
        cursor: pointer;
        border: none;
        transition: background-color 0.2s;
        font-size: 13px;

        &:hover {
          background: #f39c12;
        }
      }

      .trialText {
        opacity: 0.8;
      }
    }

    .gearMenu {
      position: relative;

      .gearIcon {
        cursor: pointer;
        display: flex;
        align-items: center;

        svg {
          height: 20px;
          width: 20px;
        }
      }

      .menuPopup {
        position: absolute;
        top: 100%;
        right: 0;
        margin-top: 8px;
        background: var(--background-color);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        min-width: 200px;
        z-index: 1000;
        overflow: hidden;

        .menuItem {
          display: block;
          padding: 12px 16px;
          color: var(--text-color);
          text-decoration: none;
          cursor: pointer;
          transition: background-color 0.2s;

          &:hover {
            background: var(--hover-color, rgba(0, 0, 0, 0.05));
          }

          &:not(:last-child) {
            border-bottom: 1px solid var(--border-color);
          }
        }
      }
    }

  }
}


.initializing {

  .headerContainer,
  .historyContainer,
  .charts {
    display: none !important;
  }
}

.interestCard {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  width: 100%;
  background: var(--card-background-color);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 8px 0 24px;
  box-shadow: var(--drop-shadow);
  font-size: 14px;

  .interestText {
    flex: 1;
    min-width: 0;

    .interestHeading {
      font-weight: 600;
      margin-bottom: 4px;
    }

    .interestList {
      margin: 0;
      padding-left: 20px;
      list-style: disc;

      li {
        margin: 0;
        line-height: 1.4;
      }
    }
  }

  .notifyButton {
    background: var(--button-primary-background-color);
    color: var(--button-primary-text-color);
    padding: 6px 14px;
    border-radius: 4px;
    font-size: 14px;
    border: none;
    cursor: pointer;
  }

  .notifyForm {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;

    .notifyInput {
      padding: 6px 10px;
      border-radius: 4px;
      border: 1px solid var(--input-border-color);
      background: var(--input-background-color);
      color: var(--input-text-color);
      font-size: 14px;
      min-width: 180px;
    }

    .notifySubmit {
      background: var(--button-primary-background-color);
      color: var(--button-primary-text-color);
      padding: 6px 14px;
      border-radius: 4px;
      font-size: 14px;
      border: none;
      cursor: pointer;
    }

    .notifySubmit:disabled {
      opacity: 0.5;
      cursor: not-allowed;
    }

    .notifyError {
      color: var(--red-color);
      font-size: 12px;
      flex-basis: 100%;
    }
  }

  .notifyThanks {
    flex: 1;
    color: var(--green-color);
    font-weight: 500;
  }

  .notifyClose {
    background: none;
    border: none;
    color: var(--text-color);
    opacity: 0.6;
    font-size: 22px;
    line-height: 1;
    padding: 4px 8px;
    cursor: pointer;
    margin-left: auto;
  }

  .notifyClose:hover {
    opacity: 1;
  }
}

.historyContainer {
  display: none;
  position: absolute;
  overflow-x: auto;
  padding-top: 20px;
  top: var(--header-height);
  left: 0px;
  right: 0px;
  bottom: 0px;
  z-index: 100;
  background: var(--background-color);
  flex-direction: column;
  align-items: center;




  .autocompleteContainer {
    .autoComplete_wrapper {
      width: 100%;

      input {
        width: 100%;
        background: var(--input-background-color);
        color: var(--input-text-color);
      }

      ul {
        li {
          background: var(--input-background-color);
          color: var(--input-text-color);
          border-radius: 0px;
        }

        li:hover,
        li[aria-selected="true"] {
          background-color: var(--selection-background-color);
          color: var(--selection-text-color);
        }
      }
    }
  }

  .currentLocation {
    display: flex;
    align-items: center;
    gap: 6px;

    svg {
      height: 16px;
      width: 16px;
    }
  }

  .historyList {
    margin-top: 10px;

    .historyItem {
      height: 40px;
      display: flex;
      align-items: center;
      cursor: pointer;
    }
  }
}

.historyContainer.searching {
  display: flex;
}

nav {
  .tools {
    /* position: absolute; */
    overflow-x: auto;
    /* top: var(--header-height);
    left: 0px;
    right: 0px;*/
    display: flex;
    align-items: center;
    justify-content: space-between;

    --radius: 80px;

    .tool {
      display: flex;
      border-radius: var(--radius);
      border-top: 1px solid var(--text-color);
      border-bottom: 1px solid var(--text-color);
      border-left: 1px solid var(--text-color);
      border-right: 1px solid var(--text-color);

      .toolButton {
        padding-top: 4px;
        padding-bottom: 4px;
        padding-left: 11px;
        padding-right: 11px;
        text-decoration: none;
        color: var(--text-color);
        display: flex;
        align-items: center;
        gap: 6px;
        cursor: default;
      }

      .toolButton svg {
        width: 16px;
        height: 16px;
      }

      .toolButton:first-child {
        border-top-left-radius: var(--radius);
        border-bottom-left-radius: var(--radius);
        padding-left: 14px;
        padding-right: 11px;
      }

      .toolButton:last-child {
        border-top-right-radius: var(--radius);
        border-bottom-right-radius: var(--radius);
        padding-left: 11px;
        padding-right: 14px;
      }

      .toolButton.active {
        background: var(--text-color);
        color: var(--background-color);
      }
    }
  }

  .left {}

  .center {}

  .right {
    .imagery {
      display: flex;
      align-items: center;
      padding-top: 2px;
      padding-bottom: 2px;

      svg {
        width: 24px;
        height: 24px;
      }
    }
  }


}

.chartsContainer {
  position: relative;
  flex: 1;

  .charts,
  .imageryView {
    position: absolute;
    overflow-x: auto;
    top: 0px;
    /*calc(var(--header-height) + 40px); */
    left: 0px;
    right: 0px;
    bottom: 0px;
    display: flex;
    visibility: hidden;
    flex-direction: column;
    padding-bottom: 10px;

    /* cursor: grab; */
    footer {
      position: sticky;
      left: 0px;
    }

  }

  .imageryView {
    footer {
      padding-left: 0px;
      padding-right: 0px;
    }
  }

  .charts.dragging {
    cursor: move;
    user-select: none;
  }

  .charts {


    .chartContainer {
      /* display: flex; */
      /* flex-direction: row; */
      position: relative;

      .nightTimeBackground {
        position: absolute;
        top: 1px;
        /* left: var(--legend-width); */
        bottom: 1px;
        background: var(--night-background-color);

        width: 18px;
      }

      .nightTimeBackgroundRight {
        position: absolute;
        top: 1px;
        right: 0;
        bottom: 1px;
        background: var(--night-background-color);

        width: 20px;
      }

      .chart {
        /* flex: 1;
        display: flex; */
        position: relative;

        margin-bottom: 0px;
        border-bottom: 1px solid var(--text-color);

        .legend {
          position: sticky;
          left: 0px;
          height: 20px;
          z-index: 15;
          display: flex;
          /* flex-direction: column; */
          align-items: flex-start;
          justify-content: flex-start;
          width: var(--legend-width);

          .label {
            /* background: var(--legend-background-color); */
            /* border-bottom-right-radius: 11px; */
            padding-top: 6px;
            padding-left: 6px;
            padding-right: 0px;
            padding-bottom: 0px;
            font-size: 12px;
            height: 20px;

            .labelText {}
          }

          .seriess {
            margin-top: 2px;
            margin-left: 7px;
            padding-top: 5px;
            display: flex;
            gap: 10px;
            align-items: center;

            .series {
              display: flex;
              font-size: 12px;
              line-height: 1;

              .seriesIcon {
                width: 12px;
                margin-right: 2px;
                display: flex;
                justify-content: center;
                align-items: center;
              }

              .seriesLabel {}
            }

            .infoIcon {
              display: flex;
              align-items: center;
              cursor: pointer;
              margin-left: 4px;

              svg {
                width: 14px;
                height: 14px;
                stroke: var(--text-color);
                opacity: 0.7;
                transition: opacity 0.2s;
              }

              &:hover svg {
                opacity: 1;
              }
            }
          }
        }
      }

      .attribution {
        position: fixed;
        bottom: 10px;
        right: 10px;
        max-width: 300px;
        padding: 10px;
        background-color: var(--background-color);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        font-size: 10px;
        color: var(--text-color);
        opacity: 0.8;
        z-index: 100;

        p {
          margin: 0 0 8px 0;
          line-height: 1.4;
        }

        a {
          display: block;
          text-align: right;

          img {
            height: 20px;
            width: auto;
          }
        }
      }

      .chart-height {

        margin-top: -20px;

        canvas {
          flex: 1;
          z-index: 10;
          background: transparent;
          position: absolute;
          left: 0px;
          right: 0px;
        }
      }

      .chart.Time {
        .chart-height {
          margin-top: 0px;
        }
      }

      .chart.WindCombined {
        display: flex;
        flex-direction: column;

        .chart-height:last-child {
          margin-top: 0px;
        }

        #WindDirection {
          border-bottom: 1px solid #dedede;
        }
      }
    }

    .chartContainer:has(.chart.Time) {
      position: sticky;
      top: 0px;
      background: var(--background-color);
      z-index: 30;

      .legend {
        /* height: 50px; */
      }
    }
  }

  .charts.active,
  .imageryView.active {
    visibility: visible;
  }
}

.loadingContainer {
  position: absolute;
  top: var(--header-height);
  left: 0px;
  right: 0px;
  bottom: 0px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--background-color);
  z-index: 50;

  .loadingSpinner {
    font-size: 20px;
    color: var(--text-color);
  }
}

.flightCategoryModal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;

  .modalContent {
    background: var(--background-color);
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);

    .modalHeader {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 20px;
      border-bottom: 1px solid var(--border-color);

      h3 {
        margin: 0;
        font-size: 20px;
        color: var(--text-color);
      }

      .closeButton {
        font-size: 32px;
        line-height: 1;
        cursor: pointer;
        color: var(--text-color);
        opacity: 0.7;
        transition: opacity 0.2s;
        background: none;
        border: none;
        padding: 0;
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;

        &:hover {
          opacity: 1;
        }
      }
    }

    .modalBody {
      padding: 20px;

      .categoryItem {
        display: flex;
        gap: 15px;
        margin-bottom: 20px;

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

        .categoryIcon {
          display: flex;
          align-items: flex-start;
          padding-top: 4px;

          svg {
            width: 16px;
            height: 16px;
          }

          &.blue {
            color: var(--blue-color);
          }

          &.red {
            color: var(--red-color);
          }

          &.purple {
            color: var(--purple-color);
          }
        }

        .categoryInfo {
          flex: 1;

          h4 {
            margin: 0 0 8px 0;
            font-size: 16px;
            color: var(--text-color);
          }

          p {
            margin: 0;
            font-size: 14px;
            color: var(--text-color);
            opacity: 0.8;
            line-height: 1.5;
          }
        }
      }
    }
  }

}

.fullWidthContainer {
  >footer {
    display: none;
  }
}

/* Imagery Styles */
.imageryView {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px;
  overflow-y: auto;
}

.imageryContainer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
}

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



.imageDisplay {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 300px;
}

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

.weatherImage {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.errorMessage {
  color: var(--red-color);
  text-align: center;
}


@media (max-width: 600px) {

  /* #charts-daily>footer,
  #charts-hourly>footer {
    padding-left: 15px;
  } */
}