@import 'vars';

//for v4a-v4b;
$gray-base: $gray-800;
$gray-darkest: $gray-700;
$gray-darker: $gray-600;
$gray-dark: $gray-500;
$gray: $gray-400;
$gray-light: $gray-300;
$gray-lighter: $gray-200;
$gray-lightest: $gray-100;

// Datepicker for Bootstrap
// =============================================================

.datepicker {
  padding: 4px;
  margin: 0;
  border-radius: $border-radius;
  direction: ltr;

  &-inline {
    display: block !important; //for inline bug
    width: 220px;
  }

  &-rtl {
    direction: rtl;

    table tr td span {
      float: right;
    }
  }

  &-dropdown {
    top: 0;
    left: 0;
    padding: 4px;

    &:before {
      position: absolute;
      display: inline-block;
      content: "";
      border-top: 0;
      border-right: 7px solid transparent;
      border-bottom: 7px solid $dropdown-border;
      border-bottom-color: rgba(0, 0, 0, .2);
      border-left: 7px solid transparent;
    }

    &:after {
      position: absolute;
      display: inline-block;
      content: "";
      border-top: 0;
      border-right: 6px solid transparent;
      border-bottom: 6px solid $dropdown-bg;
      border-left: 6px solid transparent;
    }

    &.datepicker-orient-left:before {
      left: 6px;
    }

    &.datepicker-orient-left:after {
      left: 7px;
    }

    &.datepicker-orient-right:before {
      right: 6px;
    }

    &.datepicker-orient-right:after {
      right: 7px;
    }

    &.datepicker-orient-bottom:before {
      top: -7px;
    }

    &.datepicker-orient-bottom:after {
      top: -6px;
    }

    &.datepicker-orient-top:before {
      bottom: -7px;
      border-top: 7px solid $dropdown-border;
      border-bottom: 0;
    }

    &.datepicker-orient-top:after {
      bottom: -6px;
      border-top: 6px solid $dropdown-bg;
      border-bottom: 0;
    }
  }

  table {
    margin: 0;
    user-select: none;
    -webkit-touch-callout: none;

    th {
      font-weight: $font-weight-medium;
    }

    thead th, tfoot th {
      font-weight: $font-weight-medium;
      color: $gray-600;
    }

    tr {
      td, th {
        width: 30px;
        height: 30px;
        text-align: center;
        border: none;
        border-radius: $border-radius;
      }
    }
  }
  // Inline display inside a table presents some problems with
  // border and background colors.
  .table-striped & table tr {
    td, th {
      background-color: transparent;
    }
  }

  table tr td {
    &.old, &.new {
      color: $btn-link-disabled-color;
    }

    &.day:hover, &.focused {
      cursor: pointer;
      background: $gray-200;
    }

    &.disabled, &.disabled:hover {
      color: $btn-link-disabled-color;
      cursor: default;
      background: none;
    }

    &.highlighted {
      $highlighted-bg: $state-info-bg;
      @include button-variant(#000, $highlighted-bg, darken($highlighted-bg, 20%));
      border-radius: 0;

      &.focused {
        background: darken($highlighted-bg, 10%);
      }

      &.disabled, &.disabled:active {
        color: $btn-link-disabled-color;
        background: $highlighted-bg;
      }
    }

    &.today {
      $today-bg: lighten(orange, 30%);
      @include button-variant(#000, $today-bg, darken($today-bg, 20%));

      &.focused {
        background: darken($today-bg, 10%);
      }

      &.disabled, &.disabled:active {
        color: $btn-link-disabled-color;
        background: $today-bg;
      }
    }

    &.range {
      $range-bg: $gray-200;
      @include button-variant(#000, $range-bg, darken($range-bg, 20%));
      border-radius: 0;

      &.focused {
        background: darken($range-bg, 10%);
      }

      &.disabled, &.disabled:active {
        color: $btn-link-disabled-color;
        background: $range-bg;
      }
    }

    &.range.highlighted {
      $range-highlighted-bg: mix($state-info-bg, $gray-200, 50%);
      @include button-variant(#000, $range-highlighted-bg, darken($range-highlighted-bg, 20%));

      &.focused {
        background: darken($range-highlighted-bg, 10%);
      }

      &.disabled, &.disabled:active {
        color: $btn-link-disabled-color;
        background: $range-highlighted-bg;
      }
    }

    &.range.today {
      $range-today-bg: mix(orange, $gray-200, 50%);
      @include button-variant(#000, $range-today-bg, darken($range-today-bg, 20%));

      &.disabled, &.disabled:active {
        color: $btn-link-disabled-color;
        background: $range-today-bg;
      }
    }

    &.selected, &.selected.highlighted {
      @include button-variant($color-white, $gray-300, $gray-400);
      text-shadow: 0 -1px 0 rgba(0, 0, 0, .25);
    }

    &.active, &.active.highlighted {
      @include button-variant($btn-primary-color, $btn-primary-bg, $btn-primary-border);
      text-shadow: 0 -1px 0 rgba(0, 0, 0, .25);
    }

    span {
      display: block;
      float: left;
      width: 23%;
      height: 54px;
      margin: 1%;
      line-height: 54px;
      cursor: pointer;
      border-radius: $border-radius;

      &:hover, &.focused {
        background: $gray-200;
      }

      &.disabled, &.disabled:hover {
        color: $btn-link-disabled-color;
        cursor: default;
        background: none;
      }

      &.active, &.active:hover, &.active.disabled, &.active.disabled:hover {
        @include button-variant($btn-primary-color, $btn-primary-bg, $btn-primary-border);
        // text-shadow: 0 -1px 0 rgba(0, 0, 0, .25);
      }

      &.old, &.new {
        color: $btn-link-disabled-color;
      }
    }
  }

  .datepicker-switch {
    width: 145px;
  }

  .datepicker-switch, .prev, .next, tfoot tr th {
    cursor: pointer;

    &:hover {
      background: $gray-200;
    }
  }

  // Basic styling for calendar-week cells
  .cw {
    width: 12px;
    padding: 0 2px 0 5px;
    font-size: 10px;
    vertical-align: middle;
  }
}

.input-group.date .input-group-addon {
  cursor: pointer;
}

.input-daterange {
  width: 100%;

  input {
    text-align: center;
  }

  .input-group {
    float: left;
    width: 50%;

    &:first-child input {
      border-radius: 0;
    }

    &:not(:last-child) input {
      border-radius: 0;
    }

    &:not(:first-child):not(:last-child) .input-group-addon {
      border-right-width: 0;
      border-left-width: 0;
      border-radius: 0;
    }

    &:last-child {
      .input-group-addon {
        border-left-width: 0;
        border-radius: 0;
      }

      input {
        border-radius: 0 3px 3px 0;
      }
    }
  }

  .input-group-addon {
    width: auto;
    min-width: 16px;
    // @if not $enable-flex {
    //   padding: 4px 12px;
    //   margin-left:-5px;
    //   margin-right:-5px;
    // }
    font-weight: $font-weight-normal;
    line-height: $line-height-base;
    text-align: center;
    // text-shadow: 0 1px 0 $color-white;
    vertical-align: middle;
    background-color: $input-group-addon-bg;
    border: solid $input-group-addon-border-color;
    border-width: 1px 0;

    &:first-child {
      border-left-width: 1px;
    }

    &:last-child {
      border-right-width: 1px;
    }
  }
}
