@import (reference) "../defs.less";


@img_base: '../../images';


/*
 * A mixin to help animate an element when going in or out of mobile
 * sidebar mode.
 */
.mobile-menu-animation() {
  .transition-transform(@mobile-menu-animate-duration,
                        @mobile-menu-animate-timing-func);
}


body {
  background-color: #F9F9F9;
  color: black;
  font-family: Verdana, Arial, Helvetica, Sans-Serif;
  font-size: 11px;
  margin: 0;
  padding: 0;

  .on-mobile-medium-screen-720({
    &.mobile-menu-open {
      /*
       * When opening the mobile sidebar menu, lock the viewport so the user
       * can't scroll, and shift everything on the page over by the menu's
       * width. This will animate them, using the transitions set on the
       * elements.
       */
      .no-page-scroll();

      #container,
      #mobile_menu_mask,
      #mobile_navbar_container {
        .transform(translate(@mobile-navbar-width, 0));
      }
    }
  });

  /*
   * Set the page to not scroll and have all content take up the maximum
   * height.
   */
  &.full-page-content {
    .no-page-scroll();

    #content_container,
    #content {
      height: 100%;
      margin-bottom: 0;
      vertical-align: top;
    }
  }
}

h1 {
  font-size: 10pt;
}

h3 {
  margin-top: 2em;
}

img {
  border: 0;
}

pre, textarea, .CodeMirror, .editable.field-text-area {
  font-size: @textarea-font-size;
  font-family: @textarea-font-family;
  line-height: @textarea-line-height;
}

textarea {
  resize: none;
}


/*
 * The account and support menu drop-down region of the header bar.
 */
#accountnav {
  list-style: none;
  margin: 0;
  padding: 0;
  z-index: @z-index-base;
  float: right;

  .desktop-only();

  li {
    border: 1px transparent solid;
    border-top: 0;
    display: block;
    float: right;
    margin: -@headerbar-padding 0;
    padding: 0;
    position: relative;
    white-space: nowrap;

    &:hover {
      border-color: #888;

      ul {
        border: 1px #888 solid;
        display: block;
        margin-right: -1px;
        z-index: @z-index-menu;

        li {
          border: 0;
        }
      }
    }

    a {
      color: inherit;
      display: block;
      font-size: 110%;
      margin: 0;
      padding: 0 1em;
      text-decoration: none;
      height: 32px;
      vertical-align: middle;
      line-height: 32px;

      &.user-nav-item {
        padding-left: 0.2em;
      }
    }

    img {
      display: inline;
      vertical-align: top;
      margin: 0;
      padding: 0;
    }

    ul {
      display: none;
      margin: 0;
      min-width: @headerbar-menu-min-width;
      padding: 0;
      position: absolute;
      right: 0;
      .border-radius(0 0 @box-border-radius @box-border-radius);

      li {
        float: none;
        margin: 0;
        padding: 0;
        text-align: right;

        &:last-child {
          .border-radius(0 0 @box-border-radius @box-border-radius);
        }

        a {
          margin: 0;
        }
      }
    }
  }
}


/*
 * The "Loading..." indicator shown during AJAX operations.
 */
#activity-indicator {
  display: none;
  position: fixed;
  left: 50%;
  top: 0;
  text-align: center;
  font-weight: bold;
  background-color: #fce94f;
  border: 1px #c4a000 solid;
  border-top: 0;
  width: 8em;
  margin-left: -4em;
  padding: 0.5em 0.5em;
  z-index: @z-index-spinner;

  span {
    vertical-align: middle;
    line-height: 16px;
  }

  .fa-spinner {
    font-size: 16px;
  }

  &.error {
    background-color: #ffcd9c;
    width: 28em;
    margin-left: -14em;
    background-image: none;
    padding-left: 0.6em;

    a {
      margin-left: 1em;
      color: #0000CC;
      text-decoration: none;
    }
  }
}

#container {
  .on-mobile-medium-screen-720({
    position: relative;

    .mobile-menu-animation();
  });
}

#content_container {
  position: relative;
}

/*
 * The error information shown when an AJAX operation fails.
 */
#error {
  div {
    background: #ffcd9c;
    border: 1px #9a4306 solid;
    margin-bottom: 10px;
    padding: 8px 10px;
  }

  h1 {
    display: inline;
    margin: 0;
    padding: 0;
  }

  input[type='submit'] {
    margin-left: 10px;
  }
}


/*
 * The header bar at the top of the page. This contains the branding,
 * search field, and the accountnav element.
 *
 * This has the following children:
 *
 *    * #rbinfo
 *    * #accountnav
 *    * #search
 */
#headerbar {
  margin: 0;
  padding: @headerbar-padding;
  height: 22px;
  vertical-align: middle;
  z-index: @z-index-mobile-headerbar;

  .on-mobile-medium-screen-720({
    border-bottom: 1px solid;
    height: auto;
    position: relative;
    text-align: center;

    .mobile-menu-animation();
  });

  br {
    clear: both;
    height: 0;
  }

  #logo {
    position: absolute;
    top: 3px;
    left: @headerbar-logo-padding-horiz;
    z-index: @z-index-logo;

    .on-mobile-medium-screen-720({
      position: relative;
      top: 0;
      height: 32px;
      width: 32px;
      z-index: @z-index-mobile-headerbar;
    });
  }

  #nav_toggle {
    @icon-size: 32px;
    @font-size: (@icon-size / 2);

    color: rgba(0, 0, 0, 0.8);
    cursor: pointer;
    font-size: @font-size;
    padding: ((@icon-size - @font-size) / 2);
    position: absolute;
    top: 0;
    left: 0;
    width: @icon-size;
    height: @icon-size;

    .mobile-only();

    .fa {
      vertical-align: middle;
    }
  }

  #title {
    color: inherit;
    display: inline;
    font-weight: normal;
    font-size: 125%;
    margin: 0;
    padding: 0;
    vertical-align: middle;

    .on-mobile-medium-screen-720({
      margin-left: 0.5em;
    });

    a {
      color: inherit;
      font-size: 120%;
      text-decoration: none;
    }

    .version {
      font-weight: normal;
      font-size: 90%;

      .desktop-only();
    }
  }

  #search {
    float: right;
    margin: 0 1em;

    .on-mobile-medium-screen-720({
      float: none;
      margin: 0.5em 0.5em 0 0.5em;
      .box-sizing(border-box);
    });

    input {
      border: 1px #CCC solid;
      margin: 0;
      padding: 2px;
      .border-radius(6px);
      background-color: #EEEEEE;
      font-size: 1.2em;

      .on-mobile-medium-screen-720({
        /*
         * Style the search input to appear more like the saerch bars on
         * most mobile apps and sites, giving more breathing room.
         */
        background-color: white;
        padding: 4px 8px;
        margin: 0;
        width: 100%;
        .box-sizing(border-box);
      });
    }
  }
}


/*
 * The branding section of the headerbar, containing the logo and versioning
 * information.
 */
#rbinfo {
  float: left;
  position: absolute;
  left: 0;
  padding-top: 0.2em;
  padding-left: @headerbar-padding-left;

  .on-mobile-medium-screen-720({
    /*
     * Reset positioning and floating so that on mobile, this will take the
     * full width of the page.
     */
    float: none;
    position: relative;
    padding: 0;
  });

  img {
    display: inline;
    vertical-align: middle;
  }
}

/*
 * The mobile navbar section containing the username, Log In/Out, Register,
 * and My Account links.
 */
#mobile_account_menu {
  @icon-size: 18px;

  background: rgba(0, 0, 0, 0.80);
  color: #EEE;
  border-bottom: 1px rgba(0, 0, 0, 0.3) solid;
  font-size: 120%;
  height: @mobile-menu-header-height;
  overflow: hidden;
  padding: 0;
  white-space: nowrap;
  vertical-align: middle;

  .mobile-only();

  img {
    display: inline-block;
    vertical-align: middle;
  }

  ul {
    float: right;
    font-size: 10px;
    line-height: inherit;
    list-style: none;
    margin: 4px 8px 0 0;
    padding: 0;
    white-space: nowrap;

    li {
      display: inline-block;
      margin: 0 0 0 2em;
      padding: 4px 0;
      text-align: center;

      a {
        color: inherit;
      }

      span {
        line-height: inherit;
      }

      .fa {
        font-size: @icon-size;
        vertical-align: middle;
      }
    }
  }

  .username {
    vertical-align: middle;
  }
}

/*
 * The footer of the mobile menu, containing Docs, Support, and possibly
 * Admin links.
 */
#mobile_account_menu_footer {
  background: @mobile-menu-header-bg-color;
  border-top: 1px @mobile-menu-header-border-color solid;
  font-size: 0;
  height: @mobile-menu-footer-height;
  list-style: none;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  margin: 0;
  padding: 0;

  &.has-admin li {
    /*
     * If there's an admin link, we need to give each item a third of the
     * width of the page.
     */
    width: 33%;
  }

  li {
    display: inline-block;
    font-size: 12px;
    text-align: center;

    /*
     * By default, we have two links, so give each half of the width
     * of the page.
     */
    width: 50%;

    a {
      .box-sizing(border-box);
      display: inline-block;
      padding: 1em;
      width: 100%;
    }
  }
}

/*
 * An event mask overlaying the content of the page. It's shown only when
 * the mobile menu is shown. There is nothing visible, allowing the page
 * content to fully show through.
 */
#mobile_menu_mask {
  .box-shadow(-1px 0 8px 4px rgba(0, 0, 0, 0.4));
  display: none;
  overflow: hidden;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: @z-index-nav-menu-mask;

  .mobile-menu-animation();
}

/*
 * The container for the entire mobile menu.
 *
 * This takes up the entire height of the page, but a fixed width, designed
 * to take up most but not all of the screen on a typical mobile phone.
 */
#mobile_navbar_container {
  background-color: @mobile-menu-bg-color;
  .box-sizing(border-box);
  color: @mobile-menu-text-color;
  border: 0;
  border-right: 1px @mobile-menu-border-color solid;
  display: none;
  position: absolute;
  top: 0;
  left: -@mobile-navbar-width;
  height: 100%;
  width: @mobile-navbar-width;

  .mobile-only();
  .mobile-menu-animation();

  a {
    color: inherit;
    text-decoration: none;
  }
}

/*
 * The main set of navigation links in the mobile navigation menu.
 *
 * This is designed around the structure of the datagrid sidebar, for
 * compatibilty. It's a fairly general design.
 *
 * Each item in the navigation list is in an <li>. It may optionally be
 * within a <span class="label"> within that, and may also have a
 * <span class="rb-icon"> and/or <span class="count">.
 *
 * The links can be grouped into sections by using <li class="section">.
 * Each section must have a <h3> with the section name, and a <ul> containing
 * other links.
 */
#mobile_page_nav {
  list-style: none;
  margin: 0;
  overflow-y: auto;
  padding: 0;
  position: absolute;
  top: @mobile-menu-header-height;
  bottom: @mobile-menu-footer-height;
  left: 0;
  right: 0;

  /* Section headers */
  .section h3 {
    .box-shadow(inset 0 0 8px 4px rbga(0, 0, 0, 0.8));
    background: @mobile-menu-header-bg-color;
    border-top: 1px @mobile-menu-header-border-color solid;
    border-bottom: 1px @mobile-menu-header-border-color solid;
    font-size: 120%;
    font-weight: normal;
    margin: 0;
    padding: 0.5em;
    text-transform: uppercase;
  }

  li {
    line-height: 20px;
    margin: 0;
    padding: 1em;
    position: relative;
    text-shadow: 0 0 2px black;

    &.has-count .label {
      margin-right: 4em;
    }

    &.section {
      padding: 0;

      &:not(:first-child) {
        margin-top: 1.5em;
      }

      h3.label {
        margin-left: 0;
      }
    }

    a {
      color: @mobile-menu-text-color;
    }

    .count {
      color: #BBB;
      font-size: 95%;
      padding-left: 8px;
      position: absolute;
      right: 1.5em;
    }

    .rb-icon {
      position: absolute;
      left: 0.8em;
      vertical-align: middle;
    }
  }

  ul {
    list-style: none;
    margin: 0;
    padding: 0;
  }
}

/*
 * The container for the desktop navigation bar. This is not shown when in
 * mobile mode.
 */
#navbar-container {
  a {
    font-size: 110%;
    text-decoration: none;
  }
}

/*
 * The navigation bar.
 *
 * This is the bar showing such items as "My Dashboard"< "New Review Request",
 * etc.
 */
#navbar {
  border-bottom: 1px solid;
  list-style: none;
  margin: 0;
  min-height: 1.5em;
  padding: @headerbar-padding;
  padding-left: @headerbar-padding-left;

  .on-mobile-medium-screen-720({
    display: none;
    padding-left: 10px;
    margin-top: 10px;
  });

  li {
    display: inline;
    height: 30px;
    margin: 0 1em 0 0;

    .on-mobile-medium-screen-720({
      display: block;
    });
  }

  .newreviewrequest {
    text-align: right;
  }
}

/*
 * The main container for the page's content.
 */
#page-container {
  padding: 0 @page-container-padding @page-container-padding
           @page-container-padding;

  .on-mobile-medium-screen-720({
    position: relative;
    .mobile-menu-animation();
  });
}

#topbar {
  margin: 0 0 @page-container-padding 0;
}


/*
 * The box containing information on an AJAX error.
 */
.server-error-box .response-data {
  margin-top: 2em;
}


/****************************************************************************
 * Page themes
 ****************************************************************************/

/*
 * Default color scheme, used for the dashboard, My Account page, and others
 * featuring largely blue-ish colors.
 */
.page-colors(@topbar-bg: #DAEBFF,
             @topbar-text-color: #000000,
             @topbar-faded-text-color: #5A646E);

.admin {
  .page-colors(@topbar-bg: #CCC,
               @topbar-faded-text-color: #555);
}

.reviewable-page {
  .page-colors(@topbar-bg: #EDE1B2,
               @topbar-link-color: #0700E8);
}
