.App {
  position: relative !important;
  padding-top: var(--header-height);
  padding-bottom: 50px;
  min-height: 100vh;

  @media @phone {
    padding-top: var(--header-height-phone);
  }
}

// PHONES: Somewhere on the page there will be a .App-backControl, a
// .App-primaryControl, and a .App-titleControl. We will position these on the
// left, right, and center of the header respectively.
@media @phone {
  .App-navigation {
    .header-background();
    border-bottom: 0;
    position: absolute;

    .affix & {
      position: fixed;
    }

    .scrolled & {
      box-shadow: 0 2px 6px var(--shadow-color);
    }
  }
  .App-primaryControl, .App-titleControl, .App-backControl {
    position: absolute !important;
    z-index: calc(~"var(--zindex-header) + 1");
    top: 0 !important;
    margin: 0;

    .App.affix &, .Composer & {
      position: fixed !important;
    }

    > .Button {
      float: none;
      background: transparent !important;
      box-shadow: none !important;
      height: var(--header-height-phone);
      width: auto;
      padding: 13px !important;
      margin: 0 !important;

      &:active {
        opacity: 0.5;
      }
    }
    > .Button--icon {
      width: 40px;
    }
  }
  .App-primaryControl {
    width: auto;
    right: 0;

    &.Dropdown {
      .Button, .Button-caret {
        display: none !important;
      }
      .Dropdown-toggle, .Button-icon {
        display: block !important;
      }
    }
  }
  .App-primaryControl, .App-backControl {
    margin: 0 !important;

    > .Button {
      color: var(--header-control-color) !important;

      .Button-icon {
        display: block;
        font-size: 20px;
        margin: 0;
      }
      .Button-label {
        display: none;
      }
    }
  }

  .App-titleControl {
    width: 200px;
    left: 50%;
    margin-left: -100px;
    text-align: center;
    color: var(--header-color) !important;

    &,
    > .Button {
      font-size: 16px;
    }
    > .Button {
      color: var(--header-color);
      width: 100%;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    &--text {
      line-height: var(--header-height-phone);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      font-weight: normal;
    }
  }

  .App-backControl {
    left: 0;

    .Navigation-pin {
      display: none;
    }
  }
}

// ------------------------------------
// Drawer

// On phones, the drawer is displayed in its semantic sense: as a drawer on
// the left side of the screen. On other devices, the drawer has no specific
// appearance.
@media @phone {
  .App:not(.drawerOpen) .App-drawer {
    visibility: hidden;
  }
  .drawerOpen {
    overflow: hidden;
  }
  .App-drawer {
    background: var(--header-bg);
    width: var(--drawer-width);
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    box-shadow: 0 2px 6px var(--shadow-color);
    transform: translateX(calc(~"-6px - var(--drawer-width)"));
    transition: transform 0.2s;
    z-index: var(--zindex-modal);

    .drawerOpen & {
      -webkit-transform: none !important;
              transform: none !important;
    }
  }
  .drawer-backdrop {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: var(--zindex-modal-background);
    background-color: var(--overlay-bg);
    opacity: 0;
    transition: opacity 0.2s;

    &.in {
      opacity: 0.9;
    }
  }
}

// ------------------------------------
// Header

.Header-controls {
  margin: 0;
  padding: 0;
  list-style: none;
}
.Header-logo {
  max-height: 30px;
  vertical-align: middle;
}

// On phones, the header is displayed inside of the drawer. We lay its
// contents out vertically.
@media @phone {
  .App-header {
    .container {
      padding: 0;
    }
  }
  .Header-navigation {
    display: none;
  }
  .Header-title {
    padding: 13px 10px;
    font-size: 16px;
    font-weight: normal;
    margin: 0;
    text-align: center;
  }
  .Header-controls {
    margin-top: 10px;

    > li {
      padding: 0 10px 0;
    }
    .FormControl, .ButtonGroup, .Button {
      width: 100%;
      text-align: left;
    }
    .Dropdown-menu {
      .ButtonGroup, .Button {
        width: auto;
      }
    }
  }
  .Header-secondary .Search {
    margin: 10px 0;
  }
}

// On other devices, we stick the header up the top of the page, overlaying
// the page toolbar that we styled earlier. We lay its contents out
// horizontally.
@media @phone {
  .App-drawer {
    & when (@config-colored-header = true) {
      .light-contents(@name: 'header-colored');
    }
  }
}

@media @tablet-up {
  .App-navigation {
    display: none;
  }
  .App-header {
    .header-background();
    padding: 8px;
    position: absolute;
    border-bottom: 0;

    .affix & {
      position: fixed;
    }

    .scrolled & {
      box-shadow: 0 2px 6px var(--shadow-color);
    }

    & when (@config-colored-header = true) {
      .light-contents(@name: 'header-colored');
    }
  }

  .Header-navigation {
    float: left;
    margin-right: 25px;
  }
  .Header-controls {
    &, > li {
      display: inline-block;
      vertical-align: middle;
    }
  }
  .Header-primary {
    float: left;
  }
  .Header-title {
    float: left;
    vertical-align: top;
    font-size: 18px;
    font-weight: normal;
    margin: 0 15px 0 0;
    line-height: 34px;
  }
  .Header-secondary {
    float: right;

    .Search {
      margin-right: 10px;
    }
  }
}

@media @tablet {
  .Header-secondary .Search {
    input:not(:focus) {
      width: 1px;
      background: transparent;
    }
    &:not(.active) input {
      padding-right: 0;
    }
  }
}

// ------------------------------------
// Content Area

.App-content {
  border-top: 1px solid var(--control-bg);
}

// On phones, the content area overlays the drawer, so we must give it a
// background and min-height so it cannot be seen through. When the drawer is
// meant to be open, we slide the content to the right to reveal the drawer.
@media @phone {
  .App-content {
    background: var(--body-bg);
    width: 100%;
    min-height: 100vh;
    padding-bottom: 50px;
  }
}
