//  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.

/* Forms & Buttons */
// -------------------------
.btn-toolbar {
  margin-top: 0;
  margin-bottom: $vSpace;
}

.btn {
  color: $blueDark;

  &:hover,
  &:focus,
  &:active {
    color: $white;
    background: $purple;
    text-shadow: 0 -1px 1px false $purpleDark;
    border-color: $purpleDark;

    .icon,
    [class^="icon-"],
    [class*=" icon-"] {
      background-image: url("../../images/glyphicons-halflings-white.png");
    }

    .caret {
      border-top-color: $white;
    }
  }


  .icon,
  [class^="icon-"],
  [class*=" icon-"] {
    background-image: url("../../images/glyphicons-halflings-green.png");
  }

  .caret {
    border-top-color: $blueDark;
  }

  &.btn-primary, &.btn-primary:hover,
  &.btn-warning, &.btn-warning:hover,
  &.btn-danger, &.btn-danger:hover,
  &.btn-success, &.btn-success:hover,
  &.btn-info, &.btn-info:hover,
  &.btn-inverse, &.btn-inverse:hover {
    color: $white;

    .icon,
    [class^="icon-"],
    [class*=" icon-"] {
      background-image: url("../../images/glyphicons-halflings-white.png");
    }
  }
}

.btn-primary {
  color: $white;
  background: $blue;
  border-color: $blue;
  text-shadow: 0 -1px 1px false $blueDark;
}

.btn-group.open .btn.dropdown-toggle {
  background: $purpleDark;
  color: $white;
  border-color: $purpleDark;
}

.table-display-dropdown li {
  display: flex;
  padding-left: 5px;
}

.table-display-dropdown label {
  padding-left: 5px;
  padding-right: 10px;
}

.dropdown-menu .dropdown-menu-subtitle {
  padding: 0px 20px;
}

a.btn.disabled,
a.btn[disabled="disabled"] {
  pointer-events: none;
}

a.green {
  .icon,
  [class^="icon-"],
  [class*=" icon-"] {
    background-image: url("../../images/glyphicons-halflings-green.png");
  }
}

.form-horizontal .control-group {
  margin-bottom: 0;
}

.form-inline-search .control-group {
  display: inline-block;
}
@include responsive(mediaPhone) {
  .form-horizontal .btn-toolbar {
    margin-left: 180px;
  }
  .form-horizontal.form-noindent .btn-toolbar,
  .form-horizontal.tabbed .btn-toolbar.top {
    margin-left: 0;
  }

}

@-webkit-keyframes highlight {
  0%   { background: $green; }
  100% { background: none; }
}
@keyframes highlight {
  0%   { background: $green; }
  100% { background: none; }
}

fieldset {
  margin-bottom: 9px;

  $content-padding: 10px;
  padding-top: $content-padding / 2;
  padding-bottom: $content-padding / 2;
  margin-left: - $content-padding;
  margin-right: - $content-padding;
  padding-left: $content-padding;
  padding-right: $content-padding;

  @include responsive(mediaTablet){
    $content-padding: 20px;
    padding-top: $content-padding / 2;
    padding-bottom: $content-padding / 2;
    margin-left: - $content-padding;
    margin-right: - $content-padding;
    padding-left: $content-padding;
    padding-right: $content-padding;
  }
}

.tab-content fieldset {
  // fieldset in tab must not draw outside its area
  // drawing outside would trigger scrollbars
  margin-left: 0;
  margin-right: 0;
  padding-left: 0;
  padding-right: 0;
}

.form-striped {
  fieldset:nth-of-type(2n) {
  background-color: $grayLighter;
}

}

legend {
  margin-bottom: 10px;
}

legend + * {
  -webkit-margin-top-collapse : separate;
  margin-top: 10px;
}

td {
  select,
  input[type="text"],
  input[type="number"]  {
  margin-bottom: 0 !important;
  }
}

.form-subtitle {
  margin-left: 180px;
}

select,
textarea,
input[type="text"],
input[type="password"],
input[type="datetime"],
input[type="datetime-local"],
input[type="date"],
input[type="month"],
input[type="time"],
input[type="week"],
input[type="number"],
input[type="email"],
input[type="url"],
input[type="search"],
input[type="tel"],
input[type="color"],
.uneditable-input {
  display: inline-block;
  height: 30px;
  padding: 4px 6px;
  margin-bottom: 9px !important;
  font-size: 14px;
  line-height: 20px;
  color: $black;

  &::placeholder,
  &::-webkit-input-placeholder
  {
    color: $gray;
  }

  &:-ms-input-placeholder, &:-moz-placeholder {
    color: $gray;
  }


  &:focus {
    border-color: $focusColor;
    @include box-shadow(inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px $focusColor);
  }
}

.input-append .add-on, .input-prepend .add-on {
  height: 30px;
}

.input-loading {
  background-image: url("../../images/spinner.gif");
  background-size: 16px;
  background-position:right 5px center;
  background-repeat: no-repeat;
}

select {
  height: 30px;
  line-height: 30px;
}

.form-inline {
  select,
  textarea,
  input[type="text"],
  input[type="password"],
  input[type="datetime"],
  input[type="datetime-local"],
  input[type="date"],
  input[type="month"],
  input[type="time"],
  input[type="week"],
  input[type="number"],
  input[type="email"],
  input[type="url"],
  input[type="search"],
  input[type="tel"],
  input[type="color"],
  .uneditable-input {
    margin-bottom: 0px !important;
  }

  .control-group {
    display: inline-block;
  }
}

select.time {
  width: 55px;
  height: 30px;
}

select[class*="span"][multiple] {
  height: 120px;
}

label.checkbox,
label.radio {
  font-size: 14px;
  line-height: 20px;
  margin-right: 10px;
}

.label-columns .controls {
  label {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    margin-left: 0 !important;

    &:hover {
      background: $grayLighter;
    }
  }
}

.label-columns .control-group + .control-group {
  margin-top: 2em;
}

// Browsers without CSS Grid support
.label-columns .controls {
  overflow: hidden; // clearfix

  label {
    float: left;
    width: 200px;
  }
}

// Browsers with CSS Grid support
@supports (display: grid) {
  .label-columns .controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, 200px);

    label {
      width: auto;
    }
  }
}

.controls div.inline,
.controls p.inline {
  padding-top: 5px;
  display: inline-block;
}

.controls .help-inline {
  margin-left: 10px;
  padding-bottom: 8px;
}

.controls .inline + .help-inline {
  padding-bottom: 0;
}

textarea {
  height: auto;
}

.fields-separation hr {
  margin: 7px 0 15px;
  border-top-color: $grayLight;
}

.control-group.required > label {
  transform: translate(5pt);
  &::after {
    content: '*';
    color: $orange;
    font-size: 9pt;
  }

  @media all and (max-width: $mediaPhone) {
    transform: none;
  }
}

.control-group .fields {
  .controls-row {
    border-bottom: 1px solid $grayLight;
    margin-bottom: 10px;
    padding-top: 10px;
    padding-bottom: 5px;
  }

  .help-inline {
    float: right;
  }
}

.form-horizontal .controls .help-block {
  margin: -8px 0 10px 0;
  font-size: 90%;
}

.controls > .text {
  line-height: 29px;
  padding-bottom: 8px;
  vertical-align: middle;
  display: inline-block;
}

.remove_nested_fields {
  color: $red;
  margin: 0;
  padding: 0;
  i {
    margin: 5px;
  }
  &:hover {
    color: darken($red, 10%);
  }
}

.hp {
  position: absolute;
  left: -9999px;
}

td.issue, td.revoke {
  width: 25px;

}
.disabled {
  opacity: 0.3;
  -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";
  filter: alpha(opacity=30);
}
.popover {
  max-width: 650px;
  width: 650px;
}
.popover-small {
  .popover {
    max-width: 350px;
    width: 350px;
  }
}

.filter_toggle {
   cursor: pointer;
   cursor: hand;
}

li.form {
  margin-top: 5px;

  &:first-child {
    margin-top: 0;
  }
}

.custom-file {
  display: inline-block;
  position: relative;
  overflow: hidden;

  input[type=file] {
    position: absolute;
    top: 0;
    right: 0;
    min-width: 100%;
    min-height: 100%;
    font-size: 10px;
    text-align: right;
    filter: alpha(opacity=0);
    opacity: 0;
    outline: none;
    cursor: pointer;
    display: block;
  }
}


@media screen and (max-width: 480px) {
  .input-append-fix {
    .input-append {
      width: calc(100vw - 120px);
      input {
        width: 100%;
      }
    }
  }
}

@media screen and (min-width: 480px) and (max-width: 768px) {
  .input-append-fix {
    .input-append {
      white-space: normal;
      width: 80vw;
      input {
        width: 60%;
      }
    }
  }
}

@media screen and (min-width: 768px) and (max-width: 980px) {
  input.span6,
  textarea.span6 {
    width: calc(100vw - 550px);
  }
}


input.switcher {
  max-height: 0;
  max-width: 0;
  opacity: 0;

  & + label {
    display: inline-block;
    position: relative;
    box-shadow: inset 0 0 0px 1px #d5d5d5;
    text-indent: -5000px;
    height: 20px;
    width: 40px;
    top: 10px;
    border-radius: 10px;
  }

  // switcher active background
  & + label:before {
    content: "";
    position: absolute;
    display: block;
    height: 20px;
    width: 20px;
    top: 0;
    left: 0;
    border-radius: 10px;
    background: $green;
    -moz-transition: .25s ease-in-out;
    -webkit-transition: .25s ease-in-out;
    transition: .25s ease-in-out;
  }

  // switcher knob
  & + label:after {
    content: "";
    position: absolute;
    display: block;
    height: 20px;
    width: 20px;
    top: 0;
    left: 0px;
    border-radius: 10px;
    background: $white;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .2), 0 1px 2px rgba(0, 0, 0, .2);
    -moz-transition: .25s ease-in-out;
    -webkit-transition: .25s ease-in-out;
    transition: .25s ease-in-out;
  }

  &:checked + label:before {
    width: 40px;
    background: $green;
  }

  &:checked + label:after {
    left: 20px;
    box-shadow: inset 0 0 0 1px $green, 0 1px 2px rgba(0, 0, 0, .2);
  }
}

.accordion-heading {
  .header {
    font-size: 1.2em;
    font-weight: 600;
  }

  a {
    color: $black;
  }

  a:hover {
    text-decoration: none;
  }
}

.accordion-body {
  legend {
    border-bottom: 0;
    font-size: 1.12em;
  }

  fieldset:last-child {
    margin-bottom: 0;
  }
  &.in.shown {
    overflow: visible;
  }
}
.chosen-drop {
  height: 0;
  overflow: hidden;
}
.shown .chosen-drop {
  height: auto;
}

#roles {
  legend + .layer {
    margin-top: 0;
  }

  .layer {
    + .layer {
      margin-top: 2em;
    }

    .control-group {
      margin-top: 0;
    }

    h4, h5 {
      cursor: pointer;
    }
  }
}

.has-clear {
  position: relative;
  input::-ms-clear { display: none; }

  [data-clear] {
    cursor: pointer;
    opacity: 0.3;
    pointer-events: auto;
    position: absolute;
    right: 5px;
    top: 30px;

    &:hover {
      opacity: 0.5;
    }
  }

  &.has-empty-value {
    [data-clear] { display: none; }
  }
}

.controls-row [class*="span"] + ul.typeahead + [class*="span"] {
  margin-left: 30px;
}

.chosen-container-multi .chosen-choices .search-field input {
  margin: 4px 0 !important;
}

.course-group-filter .control-group {
  width: 100%;

  .controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: flex-start;
    width: 100%;
  }

  .select {
    max-width: 370px;
    flex-grow: 1;
    margin-right: 0.5rem;
  }

  .group-filter-quick-add-tags {
    margin: 0;
    flex-grow: 1;

    button {
      margin-right: 0.5rem;
      margin-bottom: 0.5rem;
    }
  }
}

.hide-last:last-child {
  display: none;
}
