@import "../../../themes/ionic.globals.md";

// Material Design Checkbox
// --------------------------------------------------

/// @prop - Border bottom width of the checkbox
$checkbox-md-border-bottom-width: 1px !default;

/// @prop - Border bottom style of the checkbox
$checkbox-md-border-bottom-style: solid !default;

/// @prop - Border bottom color of the checkbox
$checkbox-md-border-bottom-color: $list-md-border-color !default;

/// @prop - Opacity of the disabled checkbox
$checkbox-md-disabled-opacity: 0.3 !default;

/// @prop - Background color of the checkbox icon when off
$checkbox-md-icon-background-color-off: $list-md-background-color !default;

/// @prop - Background color of the checkbox icon when on
$checkbox-md-icon-background-color-on: color($colors-md, primary) !default;

/// @prop - Size of the checkbox icon
$checkbox-md-icon-size: 16px !default;

/// @prop - Width of the checkbox icon checkmark
$checkbox-md-icon-checkmark-width: 2px !default;

/// @prop - Style of the checkbox icon checkmark
$checkbox-md-icon-checkmark-style: solid !default;

/// @prop - Color of the checkbox icon checkmark
$checkbox-md-icon-checkmark-color: color-contrast($colors-md, $checkbox-md-icon-background-color-on) !default;

/// @prop - Border width of the checkbox icon
$checkbox-md-icon-border-width: 2px !default;

/// @prop - Border style of the checkbox icon
$checkbox-md-icon-border-style: solid !default;

/// @prop - Border radius of the checkbox icon
$checkbox-md-icon-border-radius: 2px !default;

/// @prop - Border color of the checkbox icon when off
$checkbox-md-icon-border-color-off: darken($list-md-border-color, 40%) !default;

/// @prop - Border color of the checkbox icon when on
$checkbox-md-icon-border-color-on: color($colors-md, primary) !default;

/// @prop - Transition duration of the checkbox
$checkbox-md-transition-duration: 280ms !default;

/// @prop - Transition easing of the checkbox
$checkbox-md-transition-easing: cubic-bezier(0.4, 0, 0.2, 1) !default;

/// @prop - Margin top of the start checkbox item
$checkbox-md-item-start-margin-top: $item-md-padding-media-top !default;

/// @prop - Margin end of the start checkbox item
$checkbox-md-item-start-margin-end: 36px !default;

/// @prop - Margin bottom of the start checkbox item
$checkbox-md-item-start-margin-bottom: $item-md-padding-media-bottom !default;

/// @prop - Margin start of the start checkbox item
$checkbox-md-item-start-margin-start: 4px !default;

/// @prop - Margin top of the end checkbox item
$checkbox-md-item-end-margin-top: 11px !default;

/// @prop - Margin end of the end checkbox item
$checkbox-md-item-end-margin-end: 10px !default;

/// @prop - Margin bottom of the end checkbox item
$checkbox-md-item-end-margin-bottom: 10px !default;

/// @prop - Margin start of the end checkbox item
$checkbox-md-item-end-margin-start: 0 !default;

.checkbox-md {
  position: relative;
  display: inline-block;
}

// Material Design Checkbox Outer Square: Unchecked
// -----------------------------------------

.checkbox-md .checkbox-icon {
  position: relative;
  width: $checkbox-md-icon-size;
  height: $checkbox-md-icon-size;
  background-color: $checkbox-md-icon-background-color-off;
  border-color: $checkbox-md-icon-border-color-off;
  border-style: $checkbox-md-icon-border-style;
  border-width: $checkbox-md-icon-border-width;
  transition-timing-function: $checkbox-md-transition-easing;
  transition-duration: $checkbox-md-transition-duration;
  transition-property: background;
  
  @include border-radius($checkbox-md-icon-border-radius);
}

// Material Design Checkbox Outer Square: Checked
// -----------------------------------------

.checkbox-md .checkbox-checked {
  background-color: $checkbox-md-icon-background-color-on;
  border-color: $checkbox-md-icon-border-color-on;
}

// Material Design Checkbox Inner Checkmark: Checked
// -----------------------------------------

.checkbox-md .checkbox-checked .checkbox-inner {
  position: absolute;
  width: 5px;
  height: 10px;
  border-color: $checkbox-md-icon-checkmark-color;
  border-style: $checkbox-md-icon-checkmark-style;
  border-width: $checkbox-md-icon-checkmark-width;
  border-top-width: 0 !important;
  border-left-width: 0 !important;
  transform: rotate(45deg);
  
  @include position(0, null, null, 4px);
}

// Material Design Checkbox: Disabled
// -----------------------------------------

.checkbox-md.checkbox-disabled,
.item-md.item-checkbox-disabled .ion-label {
  pointer-events: none;
  opacity: $checkbox-md-disabled-opacity;
}

// Material Design Checkbox Within An Item
// -----------------------------------------

.item.item-md .checkbox-md {
  position: static;
  display: block;
  
  @include margin($checkbox-md-item-start-margin-top, $checkbox-md-item-start-margin-end, $checkbox-md-item-start-margin-bottom, $checkbox-md-item-start-margin-start);
}

.item.item-md .checkbox-md[item-right], // deprecated
.item.item-md .checkbox-md[item-end] {
  @include margin($checkbox-md-item-end-margin-top, $checkbox-md-item-end-margin-end, $checkbox-md-item-end-margin-bottom, $checkbox-md-item-end-margin-start);
}

.checkbox-md + .item-inner .ion-label {
  @include margin-horizontal(0, null);
}

// Material Design Checkbox Color Mixin
// --------------------------------------------------

@mixin checkbox-theme-md($color-name, $color-base, $color-contrast) {
  .checkbox-md-#{$color-name} .checkbox-checked {
    background-color: $color-base;
    border-color: $color-base;
  }
  
  .checkbox-md-#{$color-name} .checkbox-checked .checkbox-inner {
    border-color: $color-contrast;
  }
  
}

// Generate Material Design Checkbox Colors
// --------------------------------------------------

@each $color-name, $color-base, $color-contrast in get-colors($colors-md) {
  @include checkbox-theme-md($color-name, $color-base, $color-contrast);
}
