//  Copyright (c) 2012-2013, Jungwacht Blauring Schweiz. This file is part of
//  hitobito and licensed under the Affero General Public License version 3
//  or later. See the COPYING file at the top-level directory or at
//  https://github.com/hitobito/hitobito.

/* Layout */
// -------------------------

body {
  padding: 0;
  height: 100vh;
  background: $bodyBackground;
}

/* Header */
.logo {
  position: absolute;
  top: 1rem;
  left: 1rem;
  margin: 0;
  padding: 0.5rem;
  z-index: 100;
  // for a box around the logo, if the Logo cannot be directly on the page background:
  @if ($logoBackgroundColor != none) {
    padding: 10px;
    background-color: $logoBackgroundColor;
    border-radius: 6px;
  }
}

.logo-image {
  display: block;
  position: relative;

  width: $logoWidth;
  height: $logoHeight;
  object-fit: contain;
  object-position: center center;
  text-align: center;

  img {
    max-width: $logoWidth;
    max-height: $logoHeight;
  }
}

.dropdown-menu {
  a {
    text-decoration: none;
  }
  .active {
    a, a:hover {
      color: $white;
    }
  }
}

/* Content */
#page {
  padding: 3px 0 60px;
  @include responsive(mediaTablet){
    padding: 20px 1rem 90px;
  }
  margin: 0;
  width: 100%;
  background: $pageBackground;
  overflow-y: visible;

  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: flex-start;
  align-content: space-around;

  .nav-left {
    @if $logoWidth < 200px {
      min-width: 280px;
    } @else {
      min-width: ($logoWidth+40px);
    }
    width: 30%;
    max-width: 25rem;
    z-index: 1;
    margin-top: $logoHeight + 40px;
    margin-right: -1.5rem;
  }

  .container-fluid {
    z-index: 2;
    min-width: 70%;
    max-width: 100%;
    overflow-x: visible;
    overflow-y: visible;
    padding-bottom: 0px;
    padding-right: 5px;
    padding-left: 5px;
    @include responsive(mediaTablet){
      padding-bottom: 60px; // needs these paddings to accomodate further sheets
      padding-right: 20px;  // needs these paddings to accomodate further sheets
      padding-left: 15px;
    }
  }

  .is-logged-out &,
  &.is-nav-not-rendered {
    padding-top: 7rem;
  }
}

#page-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  margin-bottom: 5px;
  @include responsive(mediaTablet){
    margin-bottom: 1rem;
  }

  .toggle-nav {
    margin: -0.5rem 1rem -0.5rem 0rem;
    padding: 0.5rem;
    text-transform: uppercase;
    i {
      margin-top: 0.2rem;
      margin-right: 0.5rem;
    }
    a:hover i {
      text-decoration: none;
    }
  }
  .form-inline {
    flex: 1 0 auto;
    margin: 0;
  }

  & > a {
    flex: 0 0 auto;
    color: $white;
    margin-left: 1rem;
  }

  .is-logged-out & {
    justify-content: flex-end;
    a {
      color: $white;
    }
  }
}

.sheet,
#content {
  @include border-radius($borderRadius);
  color: $black;
}

.sheet.parent {
  padding-bottom: 1px;
  background: lighten($contentBackground, 3%);
  box-shadow: 0 2px 8px $shadowColor;
  .sheet {
    margin: 0 3px 3px;
    @include responsive(mediaTablet){
      margin: 0 -10px -30px 10px;
    }
    &.parent {
      background: lighten($contentBackground, 6%);
    }
  }
  .level { color: $gray; }
}

#content {
  box-shadow: 0 2px 8px $shadowColor;
  background: $white;
  padding: 10px 10px 20px;
  @include responsive(mediaTablet){
    padding: 16px 20px 20px;
  }

  aside {
    @include responsive(phone, $mediaDesktop) {
      margin-top: $vSpace;
    }
    margin-bottom: $vSpace;
  }

  section {
    @include clearfix;
    clear: both;
    margin-top: $vSpace;
    &:first-child { margin-top:0; }
  }

  .breadcrumb {
    margin: 0;
    padding: 5px 0 5px 15px;
  }
}

.contactable {
  @include clearfix;
  .profil-big {
    margin: 0 0 0 10px;
  }
}

#main {
  clear: both;
}


/* Footer */
#page-footer {
  padding-top: 0;
  color: $footerColor;
  margin-top: -3rem;
  background-color: $footerBackground;

  .footer_content {
    padding-top: 20px;
    padding-bottom: 20px;
    @include responsive(phone, $mediaTablet) {
      padding: 20px;
    }
    a {
      color: $footerColor;

      &:hover {
        color: $footerColorHover;
      }
    }
  }
}

.form-inline .quicksearch {
  width: 100%;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  .quicksearch-input {
    flex: 1 0 auto;
    -webkit-appearance: none;
  }
}


// Adaptions for phone size / Responsiveness


@include responsive(phone, $mediaTablet) {
  .logo {
    display: none;
    .is-logged-out & {
      display: block;
    }
  }

  #page {
    .nav-left {
      z-index: 100;
      margin-top: 0;
      position: fixed;
      top: 0;
      bottom: 0;
      border-radius: 0;
      left: -100%;
      overflow-x: visible;
      overflow-y: scroll;
      transition: all 300ms ease-in-out;
      &.is-visible {
        left: 0;
        width: 90%;
      }
    }

    .nav-left-overlay {
      position: fixed;
      content: '';
      top: 0;
      bottom: 0;
      left: 0;
      width: 0;
      z-index: -999999;
      transition: opacity 700ms ease-in-out;
      opacity: 0;
      cursor: pointer;
    }

    .nav-left > nav {
      z-index: 1;
      background-color: $grayLighter;
      width: 100%;
      height: 100%;
    }

    .nav-left.is-visible .nav-left-overlay {
      opacity: 1;
      width: 1000rem;
      z-index: -1;
      background-color: rgba(0,0,0,0.3);
    }


    .container-fluid {
      margin: 0rem;
    }

    .sheet.parent {
      a.level {
        margin-bottom: 0.5rem;
      }
      & > ul.nav.nav-sub {
        display: none;
      }
    }
  }

}

/* Shared */
// -------------------------

// Highlight
.highlight {
  background-color: #FFD;
}

// Flash
#flash .alert {
  clear: both;
}

.tooltip-inner {
  text-align: left;
}


#content section.roles {
  overflow: visible;
}

.contactable.well .contact {
  address { margin-left: 1em; }
  .social { margin-left: 1em; }
}

.profiler-results {
  opacity: 0.2;
  &:hover {
    opacity: 1;
  }
}
