html {
  overflow-y: auto;
}

.v-application.theme--light {
  background-color: rgb(234, 238, 240);
  color: rgba(0, 0, 0, 0.67);
}

.v-application--wrap {
  #Header {
    height: auto;
    padding-bottom: 16px;
    padding-left: 16px;
    padding-right: 16px;
    padding-top: 16px;
    position: relative;

    #Logo {
      height: 5.4vh;
      min-width: 40vw;
    }

    #ResponsiveNavigationHandle {
      left: 16px;
      position: fixed;
      top: auto;
      transform: none;
    }
  }

  .cmt-layout-wrapped,
  #Header.cmt-layout-wrapped {  
    margin: 0 auto;
    width: 100%;
  }

  .cmt-layout-wrapped #MainBox .Content {
    padding-left: 0.25em;
    padding-right: 0.25em;
  }

  #Navigation {
    display: flex;
    flex-direction: column;

    & > ul {
      height: auto;
      margin-top: 0;

      &:first-of-type {
        margin-top: 30px;
      }

      li {
        a {
          padding: 8px 12px;
        }
        
        ul li a {
          padding-left: 20px;
        }
      }
    }

    & > ul > li > ul {
      border-radius: 0;
      box-shadow: none;
      height: auto;
      opacity: 1;
      visibility: visible;
    }

    & > ul > li:first-child a {
      border-top: solid 1px #ccc !important;
    }
  }
}

@media (min-width: 960px) {
  .v-application--wrap {
    // .cmt-layout-wrapped {
    //   padding-left: calc((100% - 900px) / 2);
    //   padding-right: calc((100% - 900px) / 2);
    // }

    #Header + .MessageBox,
    #Navigation + .MessageBox,
    #MainBox {
      margin-left: calc((100% - 900px) / 2);
      margin-right: calc((100% - 900px) / 2);

      .Content {
        padding-left: 0;
        padding-right: 0;
      }
    }

    #Navigation > ul li ul li a {
      border-top-width: 1px;
      padding-left: 12px;
    }
  } 
}

@media (min-width: 1024px) {
  .v-application--wrap {
    #Header {
      display: initial;
    }

    .cmt-layout-wrapped,
    #Header.cmt-layout-wrapped {
      padding-left: calc((100% - 900px) / 2);
      padding-right: calc((100% - 900px) / 2);
    }

    #Navigation {
      display: initial;
  
      & > ul,
      & > ul:first-of-type {
        margin-top: 16px;
      } 

      & > ul > li > ul {
        border-radius: 0 0 4px 4px;
        box-shadow: $elevated-2-box-shadow;
        opacity: 0;
        visibility: hidden;
      }

      & > ul > li:first-child > a {
        border-top-width: 0px !important;
      }   
    }
  }
}

@media (min-width: 1264px) {
  .v-application--wrap {
    .cmt-layout-wrapped,
    #Header.cmt-layout-wrapped {
      padding-left: calc((100% - 1185px) / 2);
      padding-right: calc((100% - 1185px) / 2);
    }

    #Header + .MessageBox,
    #Navigation + .MessageBox,
    #MainBox {
      margin-left: calc((100% - 1185px) / 2);
      margin-right: calc((100% - 1185px) / 2);
    }
  }
}

@media (min-width: 1904px) {
  .v-application--wrap {
    .cmt-layout-wrapped,
    #Header.cmt-layout-wrapped {
      padding-left: calc((100% - 1785px) / 2);
      padding-right: calc((100% - 1785px) / 2);
    }

    #Header + .MessageBox,
    #Navigation + .MessageBox,
    #MainBox {
      margin-left: calc((100% - 1785px) / 2);
      margin-right: calc((100% - 1785px) / 2);
    }
  }
}

:not(.v-text-field__slot) {
  & > input[type="email"],
  & > input[type="password"],
  & > input[type="text"] {
    color: rgba(0, 0, 0, .87);
    border: solid 1px rgba(0, 0, 0, 0.38);
    padding: 0 12px;

    height: 40px;
    box-sizing: border-box;
  }
}

.cmt-datetimepicker {
  :not(.v-text-field__slot) > input[type="text"].dateTimePicker-dateInput,
  :not(.v-text-field__slot) > input[type="text"].dateTimePicker-timeInput {
    border-color: rgba(0, 0, 0, 0.38);
    font-size: initial;
    height: 40px;
    padding-left: 12px;
    padding-right: 12px;
  }
}

.v-textarea textarea {
  border: none;
  border-radius: none;
  font-family: inherit;
  font-size: inherit;

  &:focus {
    -webkit-box-shadow: none;
    box-shadow: none;
  }
}

//button,
button[type="submit"] {
  @include button;
  box-shadow:
    0 3px 1px -2px rgb(0 0 0 / 20%),
    0 2px 2px 0 rgb(0 0 0 / 14%),
    0 1px 5px 0 rgb(0 0 0 / 12%);
  border: thin solid;
  color: $primary-color;
  caret-color: $primary-color;
  font-size: initial;
  letter-spacing: 0.022em;
  padding: 4px 24px;
  text-transform: none;

  background-color: #5cbbf6;
  border-color: #5cbbf6;
  color: white;
  font-weight: 500;
  padding: 4px 24px !important;
}

label {
  color: rgba(0, 0, 0, .6);
}

.v-application--wrap {
  & > #Header     { order: 1; }
  & > #Navigation { order: 2; }
  & > .MessageBox { order: 3; }
  & > #MainBox    { order: 4; }
  & > #Footer     { order: 5; }
}

#Header {
  align-items: flex-start;
  background-color: #fff;
  display: flex;

  #ResponsiveNavigationHandle {
    background: white;
    border-radius: 1.6em;
    height: 1.6em;
    left: 0;
    line-height: 1.6em;
    text-align: center;
    width: 1.6em;

    i.fa-bars {
      font-family: "Material Design Icons";
      
      &::before {
        content: mdi("menu");
      }
    }
  }
}

#Navigation {
  background-color: $navigation-background-color;
  box-shadow:
    0 2px 1px -1px rgba(0, 0, 0, .2),
    0 1px 1px 0 rgba(0, 0, 0, .14),
    0 1px 3px 0 rgba(0, 0, 0, .12);
  height: auto;

  // Pseudo-element to cover the slightly visible top part of box-shadow
  &::before {
    background-color: $navigation-background-color;
    content: "";
    height: 2px;
    left: 0;
    position: absolute;
    top: -2px;
    width: 100%;
  }
  
  ul {
    padding-left: 0;

    & > li {
      border-bottom: none;

      & > ul,
      ul {
        display: initial;
        visibility: hidden;
        opacity: 0;
        transition: opacity 0.2s ease-in-out;
      }
    }

    & > li:hover {
      background-color: $primary-color;

      & > ul,
      ul {
        display: initial;
        visibility: visible;
        opacity: 1;
      }
    }

    // This pseudoelement fills the gap between the contents
    // of the top-level item and the sub-level dropdown list (caused by
    // margin-top above the list), eliminating the problem that the list
    // disappeared when the pointer was placed inside the gap.
    // TODO: Copy-pasted from agent styles, could use some DRY
    li::after {
      content: "";
      float: none;
      background: transparent;
      height: 4px;
      margin: 0;
      position: absolute;
      width: 100%;
    }
  }

  li.Selected {
    background-color: transparent;
    
    & > a {
      border-bottom: solid 3px $primary-color;
    }
    
    &:hover {
      background: $primary-color;
    }
    
    a {
      color: rgba(0, 0, 0, 0.87);
    }
  }

  & > ul {
    // The icons in .Individual navigation items make them slightly higher,
    // this (and also setting the li height to 100%) is needed to match
    // that height inside the main navigation menu
    height: 100%;

    & > li {
      border-right: none;
      height: 100%;

      & > ul {
        top: initial;
      }

      & > a {
        border-bottom: solid 3px transparent;
        font-size: inherit;
        padding: 6px 12px;
        padding-bottom: calc(6px - 3px);
      }
    }
  }

  ul > li > ul {
    // background-color: $navigation-background-color;
    background-color: transparent;
    font-size: 87.5%;
    left: 0;
    overflow: hidden;
    padding-top: 0px;
    top: calc(100% + 3px);
  
    & > li {
      background-color: white;
      line-height: 145%;
      position: relative;

      &:last-child {
        border-radius: 0 0 4px 4px;
      }

      &:first-child {
        a {
          border-top: none;
        }
      }

      & {
        a.SubSelected::after {
          background-color: white;
          border-top: solid 1px rgba(33, 150, 243, 0.15);
          bottom: -1px;
          content: "";
          // height: 1px;
          left: 0px;
          position: absolute;
          width: 100%;
          z-index: 1;
        }
      }
  
      a {
        // background-color: $navigation-background-color;
        background-color: white;
        border-top: solid 1px #ddd;
        font-size: inherit;
        padding-bottom: 8px;
        padding-left: 12px;
        padding-right: 12px;
        padding-top: 8px;

        &:hover {
          background-color: $primary-color;
          color: white;
        }

        &.SubSelected {
          background-color: rgba(33, 150, 243, 0.15);
          border-top: none; // solid 1px rgba(33, 150, 243, 0.12);
        }
      }
    }  
  }

  ul.Individual {
    a[href$="Action=CustomerPreferences"] {
      &::before {
        color: #777;
        content: mdi("tune");
        font-family: "Material Design Icons";
        line-height: 1;
        margin-right: 0.25em;
        vertical-align: baseline;
      }

      &:hover::before {
        color: #ddd;
      }
    }

    a[href$="Action=Logout"] {
      &::before {
        color: #777;
        content: mdi("power");
        font-family: "Material Design Icons";
        line-height: 1;
        margin-right: 0.25em;
        vertical-align: baseline;
      }

      &:hover::before {
        color: #ddd;
      }
    } 
  }
}

#Header + .MessageBox,
#Navigation + .MessageBox {
  border-bottom: none;
  border-top: none;
  font-size: initial;
  position: relative;
  
  &.Error {
    @include msg-box("error");
  }
  
  &.Notice {
    @include msg-box("notice");
  }

  &.Success {
    @include msg-box("success");
  }

  &.Error span.Icon,
  &.Notice span.Icon,
  &.Success span.Icon {
    height: 100%;
    top: 50%;
    transform: translateX(-75%) translateY(-25%);

    &::before {
      vertical-align: baseline;
    }
  }

  &.Error p,
  &.Notice p,
  &.Success p {
    background-color: white;
    margin-left: 0;
    margin-right: 0;

    &::after {
      background-color: transparent;
    }
  }
}

#MainBox,
#MainBox.Login {
  .ErrorBox,
  .MessageBox,
  .SuccessBox {
    p {
      background-color: #fff;

      &::after {
        background-color: transparent;
        opacity: 0;
      }
    }
  }
}

#Footer {
  background-color: #fff;
  border-top: 1px solid #eee;
  padding-top: 0.5em;
}
