@use "~/styles/variables" as *;

.toggle-switch-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: $spacing-md;
  border-radius: $border-radius-md;
  cursor: pointer;
  transition: $transition-base;
  position: relative;

  &::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
      135deg,
      var(--success-color) 0%,
      transparent 80%
    );
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  &:hover:not(.disabled) {
    background: var(--background-hover);

    &::before {
      opacity: 0.05;
    }
  }

  &.disabled {
    opacity: 0.6;
    cursor: not-allowed;
  }
}

.label-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: $spacing-xs;
  margin-right: $spacing-md;
}

.toggle-label {
  font-size: $font-size-sm;
  color: var(--text-secondary);
  transition: color 0.3s ease;
  font-weight: 500;
  z-index: 1;
}

.toggle-status {
  font-size: $font-size-xs;
  font-weight: 500;

  .status-text {
    display: flex;
    align-items: center;
    gap: $spacing-xs;

    &.enabled {
      color: var(--success-color);
    }

    &.disabled {
      color: var(--text-tertiary);
    }

    .status-icon {
      animation: bounce 1s infinite;
    }
  }
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: $border-radius-full;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1;

  &::before {
    content: "";
    position: absolute;
    inset: -2px;
    border-radius: $border-radius-full;
    background: linear-gradient(
      135deg,
      var(--success-color),
      var(--success-hover)
    );
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .toggle-track {
    position: absolute;
    inset: 0;
    border-radius: $border-radius-full;
    background: var(--disabled-color);
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;

    .track-icon {
      color: white;
      opacity: 0.5;
      transition: opacity 0.3s ease;
      z-index: 1;

      &.left {
        margin-left: 2px;
      }

      &.right {
        margin-right: 2px;
      }
    }

    .track-background {
      position: absolute;
      inset: 0;
      border-radius: inherit;
      background: linear-gradient(
        45deg,
        var(--success-color),
        var(--success-hover)
      );
      opacity: 0;
      transition: opacity 0.3s ease;
    }
  }

  input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
  }

  .toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background-color: white;
    border-radius: 50%;
    box-shadow: $shadow-sm;
    transition: $transition-base;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;

    .toggle-icon {
      position: absolute;
      color: var(--success-color);
      line-height: 0;

      &.disabled-icon {
        color: var(--error-color);
      }
    }

    .slider-ring {
      position: absolute;
      inset: -2px;
      border-radius: inherit;
      border: 2px solid var(--success-color);
      opacity: 0;
      transition: all 0.3s ease;
    }
  }

  &.enabled {
    .toggle-track {
      background: var(--success-color);
      animation: pulse 2s infinite;

      &::before {
        content: "";
        position: absolute;
        inset: -4px;
        border-radius: inherit;
        background: var(--success-color);
        opacity: 0.2;
        animation: ripple 1.5s infinite;
      }
    }

    &::before {
      opacity: 0.5;
    }

    .toggle-slider {
      background-color: white;
      box-shadow: $shadow-md;
    }
  }

  &:hover:not(.disabled) {
    &::before {
      opacity: 0.2;
    }
  }
}

@keyframes glow {
  0%,
  100% {
    box-shadow: 0 0 5px var(--success-shadow);
  }
  50% {
    box-shadow: 0 0 15px var(--success-shadow);
  }
}

@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-2px);
  }
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.02);
  }
}

@keyframes ripple {
  0% {
    transform: scale(1);
    opacity: 0.2;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}
