// responsive.css

@import "./Variables.scss";

/*----------------------------------------*\
  RESPONSIVE CSS
\*----------------------------------------*/

/*
  CONTENTS

  A) BASIC MOBILE RESETS
  B) HEADER & TOP MENUS
  C) MAIN CONTENT & SIDEBAR
  D) TOGGLE BUTTON & FLYOUT MENU
  E) UX ELEMENTS
  F) PAGE SPECIFIC STYLES
  G) FORMS
*/

// Hide new elements (toggle button and flyout menu) above 900px
.mobile-toggle-button,
.flyout-menu {
  display: none;
}

/*
  redmine's body is set to min-width 900px
  add first breakpoint here and start adding responsiveness
*/

@media screen and (max-width: 899px) {
  /*----------------------------------------*\
    A) BASIC MOBILE RESETS
  \*----------------------------------------*/

  /*
    apply natural border box, see http://www.paulirish.com/2012/box-sizing-border-box-ftw/
    this helps us to better deal with percentages and padding / margin
  */
  *,
  *:before,
  *:after {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
  }

  body, html {
    height: 100%;
    margin: 0;
    padding: 0;
  }

  html {
    overflow-y: auto;               // avoid 2nd scrollbar on desktop
    -webkit-text-size-adjust: 100%; // prevent font scaling in landscape mode on webkit
  }

  body {
    min-width: 0; // reset the min-width of 900px
    -webkit-overflow-scrolling: touch;
  }

  // Font follows user environment
  // body,
  // input,
  // select,
  // textarea,
  // button {
  //   font-size: 14px; // Set font-size for standard elements to 14px
  // }

  select {
    max-width: 100%;  // prevent long names within select menues from breaking content
  }

  #wrapper {
    position: relative;
    overflow-x: hidden; // hide horizontal overflow
    max-width: 100%;
    margin: 0;
  }

  /*----------------------------------------*\
    B) HEADER & TOP MENUS
  \*----------------------------------------*/

  #header {
    width: 100%;
    height: 64px; // the height of our header on mobile
    min-height: 0;
    margin: 0;
    padding: 0;
    border: none;
    background-color: $color_indigo_dark;
    position: fixed;
    z-index: 9999;
  }

  // Hide project name on mobile (project name is still visible in select menu)
  #header h1 {
    display: none !important;
  }

  // reset #header a color for mobile toggle button
  #header a.mobile-toggle-button {
    color: $color_gray_light_c;
  }


  // Hide top-menu and main-menu on mobile, because it's placed in our flyout menu
  #top-menu, #header #main-menu {
    display: none;
  }

  // the quick search within header holding search form and #project_quick_jump_box box
  #header #quick-search {
    float: none;
    clear: none;     // there are themes which set clear property, this resets it;
    max-width: 100%; // reset max-width;
    margin: 0;
    background: inherit;
  }

  // styles for combobox within quick-search (#project_quick_jump_box)
  #project-jump.drdn {
    position: absolute;
    top: 0;
    left: 0;

    width: 100%;
    max-width: 100%;
    height: 2em;
    height: 64px;
    padding: 5px;
    padding-right: 72px;
    padding-left: 20px;
  }
  #project-jump .drdn-trigger {
    font-size: 1.5em;
    font-weight: bold;
    display: block;
    width: 100%;
    color: $color_white;
    padding: .3em .3em .3em 1.5em;
    background: none;
    height: 50px;
    line-height: 40px;
    border: 0;
  }
  #project-jump .drdn-trigger:before {
    // set a font-size in order to achive same result in different themes
    font-family: Verdana, sans-serif;
    font-size: 1.5em;

    position: absolute;
    left: 0;
    padding: 0 .5em;
    // achieve dropdwon arrow by scaling a caret character
    content: '^';
    -webkit-transform: scale(1,-.8);
    -ms-transform: scale(1,-.8);
    transform: scale(1,-.8);
    text-align: right;
    pointer-events: none;

    opacity: .6;
  }
  #project-jump.expanded .drdn-trigger:before {
    -webkit-transform: scale(1,.8);
    -ms-transform: scale(1,.8);
    transform: scale(1,.8);
    padding-top: 8px;
  }

  #project-jump .drdn-content {
    position: absolute;
    left: 0;
    top: 64px;
    width: 100%;
    font-size: 15px;
    font-weight: normal;
  }
  #project-jump .drdn-content .autocomplete {
    height: 40px;
    font-size: 20px;
  }
  #project-jump .drdn-content a {
    padding: 8px;
  }

  #header #quick-search form {
    display: none;
  }

  /*----------------------------------------*\
    C) MAIN CONTENT & SIDEBAR
  \*----------------------------------------*/

  #main {
    padding: 64px 0 0 // padding-top equals header height;
  }

  #main.nosidebar #content,
  div#content {
    width: 100%;
    min-height: 0; // reset min-height of #content
    margin: 0;
  }

  // hide sidebar and sidebar switch panel, since it's placed in mobile flyout menu
  #sidebar, #sidebar-switch-panel {
    display: none;
  }

  .splitcontentleft, #list-left {
    width: 100%;
  }

  .splitcontentright, #list-right {
    width: 100%;
  }

  /*----------------------------------------*\
    D) TOGGLE BUTTON & FLYOUT MENU;
  \*----------------------------------------*/

  .mobile-toggle-button {
    font-size: 42px;
    line-height: 64px;

    position: relative;
    z-index: 10;

    display: block; // remove display none of non-mobile version;
    float: right;

    width: 60px;
    height: 64px;
    margin-top: 0;

    text-align: center;

    border-left: 1px solid $color_gray_light_a;
  }

  .mobile-toggle-button:hover, .mobile-toggle-button:active {
    text-decoration: none;
  }

  .mobile-toggle-button:after {
    font-family: Verdana, sans-serif;
    display: block;
    margin-top: -3px;
    content: '\2261';
  }

  // search magnifier icon
  .search-magnifier {
    font-family: Verdana, sans-serif;
    color: $color_gray_dark;

    cursor: pointer;
    -webkit-transform: rotate(-45deg);
    -moz-transform: rotate(45deg);
    -o-transform: rotate(45deg);
    transform: rotate(-45deg);
  }

  .search-magnifier--flyout {
    font-size: 25px;
    line-height: 54px;

    position: absolute;
    z-index: 1;
    left: 12px;
  }

  // Flyout Menu

  .flyout-menu {
    position: absolute;
    right: -250px;

    display: block; // remove display none of non-mobile version
    overflow-x: hidden;

    width: 250px;
    height: 100%;
    margin: 0;  // reset margin for themes that define it
    padding: 0; // reset padding for themes that define it

    color: $color_white;
    background-color: $color_indigo;
  }

  // avoid zoom on search input focus for ios devices
  .flyout-menu input[type='text'] {
    font-size: 16px;
  }

  .flyout-menu h3 {
    font-size: 11px;
    line-height: 19px;

    height: 20px;
    margin: 0;
    padding: 0;

    letter-spacing: .1em;
    text-transform: uppercase;

    color: white;
    border-top: 1px solid $color_indigo_light;
    border-bottom: 1px solid $color_indigo_light;
    background-color: $color_indigo_dark;
  }

  .flyout-menu h4 {
    color: white;
  }

  .flyout-menu h3,
  .flyout-menu h4,
  .flyout-menu > p,
  .flyout-menu > a,
  .flyout-menu ul li a,
  .flyout-menu__search,   .flyout-menu__sidebar > div,
  .flyout-menu__sidebar > p,
  .flyout-menu__sidebar > a,
  .flyout-menu__sidebar > form,
  .flyout-menu > div,
  .flyout-menu > form {
    padding-left: 8px;
  }

  .flyout-menu .flyout-menu__avatar {
    margin-top: -1px; // move avatar up 1px
    padding-left: 0;
  }

  .flyout-menu__sidebar > form {
    display: block;
  }

  .flyout-menu__sidebar > form h3 {
    margin-left: -8px;
  }

  .flyout-menu__sidebar > form label {
    display: inline-block;
    margin: 8px 0;
  }

  .flyout-menu__sidebar > form br br {
    display: none;
  }

  // Targets list containing checkboxes (e.g. activities sidebar) in flyout menu
  .flyout-menu__sidebar  form > ul {
    margin-left: -8px;
    padding-left: 0;
  }

  .flyout-menu__sidebar form > ul li {
    line-height: 39px;
    display: block;
    padding-left: 8px;
    border-top: 1px solid rgba(255,255,255,.1);
  }

  .flyout-menu__sidebar form > ul li:first-child {
    border-top: none;
  }

  .flyout-menu__sidebar form > ul li label {
    margin: 0;
  }

  .flyout-menu__sidebar form > ul li label a {
    line-height: 1;
    display: inline;
    padding-left: 0;
    border: none;
  }

  .flyout-menu ul {
    margin: 0;
    padding: 0;
    list-style: none;

    li:hover {
      background-color: $color_indigo_light;
    }
  }

  .flyout-menu #watchers {
    display: -webkit-flex;
    display: -ms-flexbox;
    display: -webkit-box;
    display: flex;
    flex-direction: column;

    -webkit-flex-direction: column;
    -ms-flex-direction: column;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
  }

  .flyout-menu #watchers .contextual {
    -webkit-box-ordinal-group: 4;
    -webkit-order: 3;
    -ms-flex-order: 3;
    order: 3;
  }

  .flyout-menu #watchers h3 {
    margin-left: -8px;
  }

  .flyout-menu #watchers ul li {
    display: -webkit-flex;
    display: -ms-flexbox;
    display: -webkit-box;
    display: flex;
    flex-direction: row;

    -webkit-flex-direction: row;
    -ms-flex-direction: row;
    -webkit-box-orient: horizontal;
    -webkit-box-direction: normal;
    -webkit-align-items: center;
    -ms-flex-align: center;
    -webkit-box-align: center;
    align-items: center;
  }

  .flyout-menu ul li a {
    line-height: 40px;
    display: block;
    overflow: hidden;
    //height: 40px;
    white-space: nowrap;
    text-overflow: ellipsis;
    border-top: 1px solid rgba(255,255,255,.1);
  }

  .flyout-menu ul li:first-child a {
    line-height: 39px;
    height: 39px;
    border-top: none;
  }

  .flyout-menu a {
    color: white;
  }

  .flyout-menu ul li a:hover {
    text-decoration: none;
  }

  .flyout-menu ul li a.new-object,
  .new-object ~ .menu-children {
    display: none;
  }

  // Left flyout search container
  .flyout-menu__search {
    line-height: 54px;
    height: 64px;
    padding-top: 3px;
    padding-right: 8px;
  }

  .flyout-menu__search input[type='text'] {
    line-height: 2;

    width: 100%;
    height: 38px;
    padding-left: 27px;

    vertical-align: middle;

    border: none;
    -webkit-border-radius: 3px;
    border-radius: 3px;
    background-color: $color_white;
  }

  .flyout-menu__avatar {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    width: 100%;
    border-top: 1px solid rgba(255,255,255,.1);
  }

  .flyout-menu__avatar img.gravatar {
    width: 40px;
    height: 40px;
    padding: 0;
    vertical-align: top;
    border-width: 0;
  }

  .flyout-menu__avatar a {
    line-height: 40px;
    height: auto;
    height: 40px;
    text-decoration: none;
    color: white;
  }

  // avatar
  .flyout-menu__avatar a:first-child {
    line-height: 0;
    width: 40px;
    padding: 0;
  }

  .flyout-menu__avatar .user {
    padding-left: 15px;
    padding-right: 15px;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    -webkit-flex-grow: 1;
    -ms-flex-grow: 1;
    flex-grow: 1;
  }

  // user link when no avatar is present
  .flyout-menu__avatar--no-avatar a.user {
    line-height: 40px;
    padding-left: 8px;
  }

  // minimalflat2 icons
  .flyout-menu {
    .projects:before {
      @include iconbase();
      @include icon($icon_app, $color_yellow);
    }

    .activity:before {
      @include iconbase();
      @include icon($icon_stats, $color_yellow);
    }

    .issues:before {
      @include iconbase();
      @include icon($icon_ticket, $color_yellow);
    }

    .time-entries:before {
      @include iconbase();
      @include icon($icon_time, $color_yellow);
    }

    .gantt:before {
      @include iconbase();
      @include icon($icon_unbq, $color_yellow);
    }

    .calendar:before {
      @include iconbase();
      @include icon($icon_calendar, $color_yellow);
    }

    .overview:before {
      @include iconbase();
      @include icon($icon_list, $color_yellow);
    }

    .news:before {
      @include iconbase();
      @include icon($icon_news, $color_yellow);
    }

    .documents:before {
      @include iconbase();
      @include icon($icon_textfield, $color_yellow);
    }

    .wiki {
      // Override the padding of `.wiki` page.
      padding: 0 .3em;

      &:before {
        @include iconbase();
        @include icon($icon_wiki_edit, $color_yellow);
      }
    }

    .files:before {
      @include iconbase();
      @include icon($icon_file_copy, $color_yellow);
    }

    .repository:before {
      @include iconbase();
      @include icon($icon_server_key, $color_yellow);
    }

    .settings:before {
      @include iconbase();
      @include icon($icon_config, $color_yellow);
    }

    .query:before {
      @include iconbase();
      @include icon($icon_search, $color_yellow);
    }

    .register:before {
      @include iconbase();
      @include icon($icon_add, $color_yellow);
    }

    .home:before {
      @include iconbase();
      @include icon($icon_home, $color_yellow);
    }

    .my-page:before {
      @include iconbase();
      @include icon($icon_user, $color_yellow);
    }

    .administration:before {
      @include iconbase();
      @include icon($icon_config, $color_yellow);
    }

    .help:before {
      @include iconbase();
      @include icon($icon_help_2, $color_yellow);
    }

    .my-account:before {
      @include iconbase();
      @include icon($icon_config, $color_yellow);
    }

    .login:before {
      @include iconbase();
      @include icon($icon_arrow_right, $color_yellow);
    }

    .logout:before {
      @include iconbase();
      @include icon($icon_arrow_left, $color_yellow);
    }
  }

  .flyout-is-active body {
    overflow: hidden; // for body not to have scrollbars when left flyout menu is active
  }

  html.flyout-is-active {
    overflow: hidden;
  }

  .flyout-is-active #wrapper, .flyout-is-active #header{
    right: 250px; // when left flyout is active, move body and header to the right (same amount like flyout-menu's width)
  }

  .flyout-is-active #wrapper {
    overflow: visible;
    height: 100%;
  }

  .flyout-is-active .mobile-toggle-button:after {
    content: '\00D7'; // close glyph
  }

  .flyout-is-active #main {
     // only relevant for devices with cursor when flyout it active, in order to show,
     // that whole wrapper content is clickable and closes flyout menu
    cursor: pointer;
  }

  #admin-menu {
    padding-left: 0;
  }

  #admin-menu li {
    padding-bottom: 0;
  }

  #admin-menu a,
  #admin-menu a.selected {
    line-height: 40px;
    padding-left: 32px !important;
    background-position: 8px 50%;

    // Override icon fonts, disable left padding.
    &.icon-projects, &.icon-user,
    &.icon-group, &.icon-roles,
    &.icon-issue, &.icon-issue-edit,
    &.icon-workflows, &.icon-custom-fields,
    &.icon-list, &.icon-settings,
    &.icon-server-authentication, &.icon-plugins,
    &.icon-help {
      padding: .3em !important;
    }
  }

  /*----------------------------------------*\
    E) UX ELEMENTS
  \*----------------------------------------*/

  .mobile-hide {
    display: none;
  }

  .mobile-show {
    display: initial;
  }

  // Contextual Buttons

  #content >.contextual {
    width: 100%;
    margin-bottom: .5em;
    padding-left: 0; // reset left padding in order to use whole space
    white-space: normal;
  }

  #content > .contextual a,
  #content>.contextual .drdn,
  p.buttons a {
    font-weight: normal;

    display: inline-block;

    margin: .5em 0;
    padding: .3em !important;

    border: 1px solid $color_indigo;
    -webkit-border-radius: .2em;
    border-radius: .2em;
    background-color: $color_indigo;

    color: $color_white;
    font-size: .9em;

    &:hover {
      opacity: .8;
    }
  }

  // #content>.contextual a.icon,
  // p.buttons a.icon {
  //   padding-left: 25px;
  // }

  .flyout-menu .contextual {
    float: none;
  }

  // loading indicator
  #ajax-indicator {
    width: 60%;
    left: 20%;
  }

  // jquery ui dialogs
  .ui-dialog {
    max-width: 98%;
    margin: 1%;
  }

  .ui-dialog .ui-dialog-content {
    padding-left: 0;
    padding-right: 0;
  }

  #filters-table {
    width: 100%;
    float: none;
  }

  .add-filter {
    width: 100%;
    float: none;
    text-align: left;
    margin-top: 8px;
  }

  /*----------------------------------------*\
    F) PAGE SPECIFIC STYLES
  \*----------------------------------------*/

  // some themes add a margin to login page, remove it on mobile
  .action-login #main {
    margin: 0;
  }

  div#activity dl, #search-results {
    margin-left: 0;
  }

  .version-overview table.progress {
    width: 75%;
  }
  div#version-summary {
    float: none;
    width: 100%;
    margin-left: 0;
  }
  body.controller-versions.action-show div#roadmap .related-issues {
    width: 100%;
  }

  /* History and Changeset */
  div#issue-changesets {
    float: none;
    width: auto;
    margin-left: 0;
    padding-left: 0;
    margin-bottom: 2em;
  }

  div#issue-changesets div.changeset {
    padding-top: 1em;
  }

  /* Gantt charts */
  /*
   * [1] override inline styles with important
   * [2] keep border between subjects and gantt area
   * [3] remove whitespace between subjects and gantt area
   * [4] maintain width due to [3]
   */
   .gantt_subjects_column {
    width: 60% !important; // [1]
  }

  .gantt_subjects_container {
    width: 100% !important;
    overflow: hidden;
  }

  .gantt_subjects_column .gantt_hdr {
    width: 100% !important;
    right: 0 !important; //[2]
    border-right: 1px solid $color_gray_dark;
  }

  #gantt_area {
    left: -2px; // [3]
    margin-right: -2px; // [4]
  }

  /*----------------------------------------*\
    G) FORMS
  \*----------------------------------------*/

  input, select, textarea {
    max-width: 100%;
  }

  // tabular forms resets for mobile
  .tabular p, .tabular.settings p {
    padding-left: 0;
  }

  .tabular label, .tabular.settings label {
    display: block;
    width: 100%;
    margin-left: 0;
    text-align: left;
  }

  .tabular input, .tabular select, .tabular textarea {
    width: 100%;
    max-width: 100%;
  }

  .tabular input[type="checkbox"], .tabular input.date {
    width: auto;
    max-width: 95%;
  }

  // new issue form
  #all_attributes p:first-child {
    float: none !important;
  }

  #all_attributes #issue_tracker_id {
    width: 90%;
  }

  #issue_is_private_label {
    display: inline;
  }

  span#watchers_inputs {
    width: 100%;
  }

  // issue edit form
  label[for='issue_description'] ~ a .icon-edit {
    word-wrap: normal;
  }

  // issues page
  body.controller-issues p.query-totals {
    margin-top: 0px;
    text-align: left;
  }

  // subtasks and related issues list on issue show
  #issue_tree .issues, #relations .issues {
    border-collapse: separate;
    border-spacing: 0 1em; // vertical space between tasks

    td {
      border: none;
    }
  }

  #issue_tree .issue > td:not(.checkbox), #relations .issue > td:not(.checkbox) {
    display: block;
    float: left;
    text-align: left;
    padding-right: 5px;
  }

  #issue_tree .issue > td:not(.subject), #relations .issue > td:not(.subject) {
    width: 20%; // three columns for all cells that are not subject
  }

  #issue_tree .issues, #issue_tree .issue,
  #relations .issues, #relations .issue {
    position: relative; // needed for .buttons positioning
  }

  // positioniong of unline button
  #issue_tree .issue > td.buttons,
  #relations .issue > td.buttons {
    text-align: right;
    position: absolute;
    right: 0;
    margin: 0;
    padding-right: 0;
  }

  #issue_tree .issue .buttons a,
  #relations .issue .buttons a {
    vertical-align: middle;
  }

  /* attachment upload form */
  .attachments_fields span {
    position: relative;
    clear: both;
    margin-bottom: 1em;
    white-space: normal;
  }
  .attachments_fields span a.remove-upload {
    position: absolute;
    top: 0;
    right: 0;
  }

  .attachments_fields input.description {
    margin-left: 0;
    width: 100%;
  } }

@media all and (max-width: 599px) {
  span.pagination {
    text-align: center;
  }
  .pagination ul.pages li {
    display: none;
  }
  .pagination ul.pages li.current,
  .pagination ul.pages li.previous,
  .pagination ul.pages li.next {
    display: inline-block;
    width: 32%;
    overflow: hidden;
  }

  #login-form {
    width: 100%;
    margin-top: 2em;
  }
}
