// Slide-toggle (mat-slide-toggle, class sln-mat-slide-toggle) — docplat_new

$slide-switch-width: 30px;
$slide-switch-height: 16px;
$slide-handle-size: 12px;

.sln-core-field-bool {
  padding: 18px 0 10px;
}

.sln-mat-slide-toggle.sln-mat-slide-toggle--no-border {
  border-color: transparent;
  background: transparent;

  .mdc-form-field {
    padding: 0;
  }

  &:hover:not(:disabled):not(.sln-mat-slide-toggle-disabled):not(.mat-mdc-slide-toggle-disabled) {
    border-color: transparent;
  }

  &:disabled,
  &.sln-mat-slide-toggle-disabled,
  &.mat-mdc-slide-toggle-disabled {
    background: var(--INPUT-DISABLED-BG) !important;
  }
}

.sln-mat-slide-toggle {
  // размеры Material slide-toggle под наш switch 30×16
  --mat-slide-toggle-track-width: #{$slide-switch-width};
  --mat-slide-toggle-track-height: #{$slide-switch-height};
  --mat-slide-toggle-handle-width: #{$slide-handle-size};
  --mat-slide-toggle-handle-height: #{$slide-handle-size};
  --mat-slide-toggle-selected-handle-size: #{$slide-handle-size};
  --mat-slide-toggle-unselected-handle-size: #{$slide-handle-size};
  --mat-slide-toggle-with-icon-handle-size: #{$slide-handle-size};
  --mat-slide-toggle-pressed-handle-size: #{$slide-handle-size};
  --mat-slide-toggle-selected-handle-horizontal-margin: 0;
  --mat-slide-toggle-selected-with-icon-handle-horizontal-margin: 0;
  --mat-slide-toggle-selected-pressed-handle-horizontal-margin: 0;
  --mat-slide-toggle-unselected-handle-horizontal-margin: 0;
  --mat-slide-toggle-unselected-with-icon-handle-horizontal-margin: 0;
  --mat-slide-toggle-unselected-pressed-handle-horizontal-margin: 0;

  display: flex !important;
  min-height: var(--INPUT-HEIGHT);
  border: 1px solid var(--SLIDE-OUTER-BORDER, #3469f426);
  border-radius: var(--INPUT-RADIUS);
  align-items: center;
  background: var(--SLIDE-OUTER-BG, #3469f40d);
  width: 100%;
  overflow: visible;
  transition: border-color 0.15s ease;

  &:hover:not(:disabled):not(.sln-mat-slide-toggle-disabled) {
    border-color: #3469f44d;
  }

  &:disabled,
  &.sln-mat-slide-toggle-disabled,
  &.mat-mdc-slide-toggle-disabled {
    border-color: var(--LIGHT-GRAY);
    background: var(--INPUT-DISABLED-BG) !important;
    cursor: auto;
  }

  .mdc-label {
    font-size: 14px;
    color: var(--DARK-GREY) !important;
    font-family: var(--font-medium);
  }

  .mdc-form-field {
    display: flex;
    flex-direction: row-reverse;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0 12px;
    gap: 12px;

    button.mdc-switch,
    .mdc-switch {
      position: relative;
      flex: 0 0 $slide-switch-width;
      width: $slide-switch-width !important;
      height: $slide-switch-height !important;
      min-width: $slide-switch-width;
      border-radius: $slide-switch-height;
      background: var(--SLIDE-TRACK-OFF);
      padding: 0;
    }
  }

  // Да / Нет — слева от switch, вне трека
  .mdc-switch::before {
    content: 'Нет';
    position: absolute;
    right: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    white-space: nowrap;
    font-size: 14px;
    line-height: 1;
    font-family: var(--font-medium);
    color: var(--DARK-GREY);
    pointer-events: none;
  }

  .mdc-switch--selected::before,
  .mdc-switch--checked::before {
    content: 'Да';
  }

  .mdc-switch__icon {
    display: none;
  }

  .mdc-switch__track {
    width: 100% !important;
    height: $slide-switch-height !important;
    border-radius: $slide-switch-height;
    background-image: none !important;
  }

  .mdc-switch--selected .mdc-switch__track,
  .mdc-switch--checked .mdc-switch__track,
  .mdc-switch--unselected .mdc-switch__track,
  .mdc-switch:not(.mdc-switch--checked) .mdc-switch__track {
    background-image: none !important;
  }

  .mdc-switch__handle-track {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
  }

  .mdc-switch__handle,
  .mdc-switch__handle:has(.mdc-switch__icons),
  .mdc-switch--selected .mdc-switch__handle,
  .mdc-switch--checked .mdc-switch__handle,
  .mdc-switch--selected .mdc-switch__handle:has(.mdc-switch__icons),
  .mdc-switch--checked .mdc-switch__handle:has(.mdc-switch__icons),
  .mdc-switch--unselected .mdc-switch__handle,
  .mdc-switch:not(.mdc-switch--checked) .mdc-switch__handle {
    width: $slide-handle-size !important;
    height: $slide-handle-size !important;
    margin: 0 !important;
  }

  .mdc-switch__icons {
    width: $slide-handle-size !important;
    height: $slide-handle-size !important;
    top: 0 !important;
    right: 0 !important;
    left: 0 !important;
    transform: none;
    background: var(--SLIDE-HANDLE);
    border-radius: 50%;
    box-shadow:
      0 0 1px rgba(25, 31, 41, 0.08),
      0 1px 3px rgba(68, 83, 113, 0.16);
  }

  .mdc-switch--selected .mdc-switch__handle-track,
  .mdc-switch--checked .mdc-switch__handle-track {
    transform: translateX(calc(#{$slide-switch-width} - #{$slide-handle-size} - 2px));
  }

  .mdc-switch--unselected .mdc-switch__handle-track,
  .mdc-switch:not(.mdc-switch--checked) .mdc-switch__handle-track {
    transform: translateX(2px);
  }

  .mdc-switch--selected,
  .mdc-switch--checked {
    background: var(--SLIDE-TRACK-ON) !important;

    .mdc-switch__track::before,
    .mdc-switch__track::after {
      background: none;
    }
  }

  .mdc-switch.mdc-switch--unselected:disabled .mdc-switch__icon,
  .mdc-switch:not(.mdc-switch--checked):disabled .mdc-switch__icon {
    display: none;
  }

  .mdc-switch.mdc-switch--unselected:disabled .mdc-switch__icons,
  .mdc-switch:not(.mdc-switch--checked):disabled .mdc-switch__icons {
    opacity: 1;
  }

  .mdc-switch.mdc-switch--selected:disabled .mdc-switch__icons,
  .mdc-switch.mdc-switch--checked:disabled .mdc-switch__icons {
    opacity: 0.85;
  }

  .mdc-switch:disabled .mdc-switch__track {
    opacity: 0.55;
  }

  .mdc-switch:disabled::before {
    opacity: 0.55;
  }

  .mdc-switch__track::before,
  .mdc-switch__track::after {
    border: none;
  }
}

.sln-mat-slide-toggle-label {
  display: flex;
  align-items: center;
  padding-right: 5px;
  color: var(--MIDLE-GRAY);
  font-family: var(--font-medium);
  font-size: 14px;
  line-height: 1.4;
}

.sln-mat-slide-toggle.sln-mat-slide-toggle--no-border:disabled,
.sln-mat-slide-toggle.sln-mat-slide-toggle--no-border.sln-mat-slide-toggle-disabled,
.sln-mat-slide-toggle.sln-mat-slide-toggle--no-border.mat-mdc-slide-toggle-disabled {
  border-color: transparent;
  background: var(--INPUT-DISABLED-BG) !important;
}

// компактные размеры поля — switch остаётся 30×16
core-field-bool.sln-bool-xs,
core-field-bool.sln-bool-s {
  .sln-mat-slide-toggle {
    min-height: var(--INPUT-HEIGHT-S);
  }

  .sln-mat-slide-toggle-label {
    font-size: 13px;
  }
}
