@import "../../themes/ionic.globals";

// Checkbox
// --------------------------------------------------

:host {
  /**
   * @prop --background: Background of the checkbox icon
   * @prop --border-color: Border color of the checkbox icon
   * @prop --border-radius: Border radius of the checkbox icon
   * @prop --border-width: Border width of the checkbox icon
   * @prop --border-style: Border style of the checkbox icon
   * @prop --size: Size of the checkbox icon
   * @prop --transition: Transition of the checkbox icon
   * @prop --background-checked: Background of the checkbox icon when checked
   * @prop --border-color-checked: Border color of the checkbox icon when checked
   * @prop --checkmark-color: Color of the checkbox checkmark when checked
   */
  --background-checked: #{ion-color(primary, base)};
  --border-color-checked: #{ion-color(primary, base)};
  --checkmark-color: #{ion-color(primary, contrast)};

  display: inline-block;
  position: relative;

  user-select: none;
}

:host(.ion-color) {
  --background-checked: #{current-color(base)};
  --border-color-checked: #{current-color(base)};
  --checkmark-color: #{current-color(contrast)};
}

input {
  @include input-cover();
}

.checkbox-icon {
  @include border-radius(var(--border-radius));

  position: relative;

  width: var(--size);
  height: var(--size);

  transition: var(--transition);

  border-width: var(--border-width);
  border-style: var(--border-style);
  border-color: var(--border-color);

  background: var(--background);

  contain: strict;
}

.checkbox-inner {
  border-color: var(--checkmark-color);

  opacity: 0;
}

// Checked Checkbox
// ---------------------------------------------

:host(.checkbox-checked) .checkbox-icon {
  border-color: var(--border-color-checked);

  background: var(--background-checked);
}

:host(.checkbox-checked) .checkbox-inner {
  opacity: 1;
}

// Disabled Checkbox
// ---------------------------------------------

:host(.checkbox-disabled) {
  pointer-events: none;
}